|
I was going to answer this question but you got to it first.
Alex Korchemniy
|
|
|
|
|
//VC++ :
wSizeReturned = MAKEWORD(*pDataBuffer, *(pDataBuffer+1));
what does the identical C# code look like?
|
|
|
|
|
MAKEWORD is a macro, which probably expands to something like this: *pDataBuffer + (*pDataBuffer+1)>>4) and the code is the same in C#.
The >> operator shifts the bits of the number, so that in binary, 1 >> 4 becomes 10000
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Uh, you need to shift a byte by 8, and left-shifts multiply - right-shifts divide. The C++ definition is pretty complex, ensuring that the values to be shifted are actually bytes (by masking).
Rough equivalent:
public static ushort MakeWord(byte a, byte b)
{
return (ushort)a | ((ushort)b << 8);
} It doesn't make much difference whether you use + or |, but the original macro uses |, so I have too.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi!Graus,
Thanks!I have got it.
By the way,
"I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's.",what
does this mean?;)
Best wishes!
momer
|
|
|
|
|
I dunno - someone else said it, I just thought it was funny.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
In .NET it is very easy to create a custom event and eventhadlers.You can add any number of parameter on your custom event. What you need to do is, Declare your delegate in such a way.
Eg:
<br />
Delegate declaration.<br />
<br />
public delegate void CustomDel(string a);<br />
<br />
event declaration of the type CustomDel<br />
<br />
private event CustomDel CustomDelEvt;<br />
<br />
Adding event handler.<br />
<br />
CustomdelEvt+=new CustomDel(Button_Devevt);<br />
<br />
Handler definision<br />
<br />
private void Button_Devevt(string a)<br />
{<br />
Messagebox.Show(a);<br />
}<br />
now you can call this event anywhere in your class file. This is how Custom event.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
iemand wrote:
btnMtnStandards = new LinkButton();
If this means you're using the System.Web.UI.WebControls.LinkButton class simply use the Command event in combination with the CommandName and/or CommandArgument property.
Take a look at the MSDN topic[^] for more information.
www.troschuetz.de
|
|
|
|
|
You can still use your OpenMtnStandards event handler for multiple buttons, you can simply cast the sender object back to a LinkButton to find out which button it came from.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thank Nick, but can You Show me some code how to cast the sender object back to a LinkButton??
Thnx
joost
|
|
|
|
|
A LinkButton question really belongs in the ASP.NET forum, however the concept really just applies to .NET. Here is an example for a Windows application, but the underlying code should work the same assuming you change the class from a Button to a LinkButton . HTH
public class test : System.Windows.Forms.Form
{
Button b, b2;
public test()
{
InitializeComponents();
}
public void InitializeComponents()
{
b = new Button();
b2 = new Button();
b.Text = "Some text";
b2.Text = "Some other text";
b2.Location = new Point(20, 20);
b.Click += new EventHandler(bClick);
b2.Click += new EventHandler(bClick);
this.Controls.AddRange(new Control[] {b, b2});
} fs
private void bClick(object sender, EventArgs e)
{
Button b = sender as Button;
if(b != null)
{
MessageBox.Show(b.Text);
}
}
[STAThread]
public static void Main()
{
Application.Run(new test());
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks a lot nick, it worked
|
|
|
|
|
You can't add a parameter. Event handlers (callbacks) must match the signature exactly for the events (multi-cast delegates).
For most events in the .NET BCL, however, you already have a way to do this. What do you think the sender (first parameter) is? It's the object that fired the event. So cast this to a LinkButton and then you can determine which LinkButton fired the event easily using a name or ID, or use referential equality to determine which LinkButton was clicked, or don't even care and just print what a LinkButton would define. Examples of all three are below:
linkButton1.Click += new EventHandler(OpenMtnStndards);
linkButton2.Click += new EventHandler(OpenMtnStndards);
linkButton3.Click += new EventHandler(OpenMtnStndards);
private void OpenMtnStandards(object sender, EventArgs e)
{
LinkButton lb = sender as LinkButton;
if (lb != null)
{
Trace.Warn(lb.Text);
switch (lb.ID)
{
case "lb1":
Trace.Warn("You clicked LinkButton 1");
break;
case "lb2":
Trace.Warn("You clicked LinkButton 2");
break;
case "lb3":
Trace.Warn("You clicked LinkButton 3");
break;
}
}
if (sender == linkButton1)
Trace.Warn("You clicked LinkButton number 1");
else if (sender == linkButton2)
Trace.Warn("You clicked LinkButton number 2");
else if (sender == linkButton3)
Trace.Warn("You clicked LinkButton number 3");
} If you read the documentation for the EventHandler class - the type of the Click event, it does tell you want the sender parameter is (you can declare it as any name you want, however).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Can anyone tell me how to add a parameter to an event handler??
this is the code(sharepoint):
btnMtnStandards = new LinkButton();
btnMtnStandards.Text = "Maintain Standards";
btnMtnStandards.Click += new EventHandler(this.OpenMtnStandards);
this.Controls.Add(btnMtnStandards);
I want to add a parameter to the event OpenMtnStandards so that I can use this event for more buttons and not only for one button.
Thanks
joost
|
|
|
|
|
Hi all, I've got a bit of a problem here, and maybe the solution is obvious but I cant seem to find it.
We are developing a client app that reads a whole lot of numerical data through keyboard input. The main input control is NET's base library DataGrid. This application will have to be localized in different countries which means that the decimal separator might be a comma or a period depending where the application is running.
The problem is that .NET's DataGrid will always recognize the numeric keypad decimal key as a period (unlike for example MS Excel, where it will always recongize it as the decimal separator no matter what the current culture info is).
This isn't too much of a problem in countries where the decimal separator is a period, but in countries where its a comma, the decimal key in the numericpad is useless, thus lowering the user's keyboard input performance.
Is there any way that I can intercept the keyboard event and change the input to a generic CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator string/char? Obviously DataGrid's key events dont work because they dont capture the events when editing a cell and I cant seem to hook up any event to a datagridcell.
I've been looking at windows messages and I'm not sure if the same thing is happening...messages in the messageloop of the currentcell are not going through the datagrid control ???
PD Changing OS Culture Info is not a valid solution.
any help would be appreciated, and sorry for any spelling mistakes, I'm not english spoken
thanks.
|
|
|
|
|
|
I am trying to develop an application using UPnP technologies.Well doing it in C# is not quite a piece of cake.Anyone working on the same field would be interested in cooperating so we can start using this technology with c#?
Thanks
Kill The Tester
|
|
|
|
|
Can anyone tell me if its possible and how to programatically (in c#) open a dialog on a secondary display monitor ? ie: The main app interface displays on the primary monitor and on certain events a dialog is opened/displayed on the secondary monitor ?
Any help will be greatly appreciated.
Cheers
Craig
|
|
|
|
|
You can use the Screen class to get the bounds of the second (if any) screen and set your window's location accordingly.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath,
Thanx for the info - will try that solution. Is there any chance of providing me with a code snippett ??
Cheers
Craig
|
|
|
|
|
Read the documentation for the Screen.PrimaryScreen property. Do the same for the second screen, if any, like so:
Rectangle area = Screen.PrimaryScreen.WorkingArea;
if (Screen.AllScreens.Length > 1)
area = Screen.AllScreens[1].WorkingArea; There are lots of examples of how to use the classes, members, etc. in the .NET BCL in the .NET Framework SDK (which gets installed by default with VS.NET, is downloable as separate documentation and tools, or is available online at http://msdn.microsoft.com/library[^]).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello,
I have a C# application l have just finished developing. And now l need to install it on the customer's computer. They have a P4 and running XP Pro. All they have installed is office 2000.
My program is a database application that uses C# with MS Access 2000.
What is the best way to start the installization? How do l create the install program (nn VB 6 i used Package and deployment wizard) What do l need to use with C#.
Do l need to install the .Net framework on their machine, in order for my application to run properly.
Many thanks in advance,
Steve
|
|
|
|
|
So your application using Access as backend. So you can create a DSN and use. So that part is clear.
Next, for running your your application in client machine you need to install .NET Framework. For better result try to install the Framework version that you developed your application.
And you can also use Setup And deployement project which is avilable in visual Studio.NET to create a setup file for your application,like what do you do for your vb application.hope you got what to do next.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Hello,
Thanks for your reply. Just one more question if l use the setup and deployment project, will that package the .Net framework into the setup project as well?
Thanks in advance,
Steve
|
|
|
|
|
No it won't package .NET Framework into your setup program.
Sreejith Nair
[ My Articles ]
|
|
|
|