|
Hello,
I have a question I've been trying to answer and I just can't find anything. When I use an interop method, I know I must put it inside a NativeMethods class. I'm writing a little utility library for my company and I was wondering where should that NativeMethods class go: inside the class that uses it as a nested type, or only one globally for all classes that use any interop method in it?
By the way, can anyone explain to me what's the difference between SafeNativeMethods , UnsafeNativeMethods , and NativeMethods ? I just don't understand what MSDN says.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
You can group nativemethods in different classes.
for example, process related methods in NativeProcessMethods, GDI related methods in NativeGDIMethods.
where to put these classes is a raltive issue dependent in your design.
But I prefer to put all native methods classes in a class library to use it in another porject in the future to avoid rewriting the code.
Hope this helps
Hesham
|
|
|
|
|
Interesting comments, thanks!!
Yes, I think I'll move everything into a global class for easier reusability, with hopes that the library will grow.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
How to add a combo box in a datagrid column in vs 2003 in a windows application using C#
Suraj
|
|
|
|
|
There are tons of articles on this, both on this site, and the rest of hte web.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello All,
Actually I want to port a windows application written in C# to a user control so that i can embed that control in a web browser and be facilitated from all its feature without installing it.(Only the .Net framework is required).
Its working fine but gives me exception when i go beyond the scope of the browser for example i want to save a file in C:\ drive and do some registry operations.
It gives me System.Security.Permissions.FileIoPermission and etc.
Please tell me how to set all the permissions for this control so that i can have full control over the machine on which this control is running in a web browser.
Thanks alot in advance,
Best Regards,
Rizwan Ahmed.
|
|
|
|
|
Hi I need to active a remote class with remoting but I need a class object that retrieves remote satellite resource messages with my client UICulture not remote assembly default culture.
How can I perform that? Is posible to activate a remote object with my custom client culture like CreateInstance method (GetObject() method dosent let me to do that)?
Than you!!!
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Does anyone have an example in C# or know of a component that reproduces the behavior of the VS toolbar and being able to slide in and out/push pin functionality?
Thanks
|
|
|
|
|
|
I need to move a string of hex characters to a byte array. Here is my code:
Encoding en = Encoding.ASCII;<br />
byte[] HBReply = new byte[30];<br />
HBReply = en.GetBytes("\xFF\x00\xAA\x55");<br />
return HBReply;<br />
Is there a better way to do this? And I'm not seeing the hex characters when I do a quick watch on HBReply.
Thanks for the help.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You probably need to remove the quotes in GetBytes(\xFF\x00\xAA\x55).
|
|
|
|
|
What do you mean by "a string of hex characters"? Once the characters are in the string, there is nothing hexadecimal about them.
How do you do a "quick watch" on the array? It doesn't contain any characters at all, it's a byte array, not a char array.
The byte array will contain the ASCII codes of the characters in the string, which will be exactly the same as if the array was created with:
byte[] HBReply = new byte[] {255, 0, 170, 85};
Let's simplify the code somewhat, by the way. There is no need to create more than one byte array.
byte[] HBReply = Encoding.ASCII.GetBytes("\xFF\x00\xAA\x55");<br />
return HBReply;
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: What do you mean by "a string of hex characters"? Once the characters are in the string, there is nothing hexadecimal about them.
Each character in the sting array is a hex value. I need to show the character related to that value......Okay let me explain. I'm writing an interface that communicates over tcp/ip from a PC to a Mainframe. Everything must be sent in a byte array over this connection. However I'm having trouble creating the heartbeat which begins with hex ff00aa55.
Guffa wrote: How do you do a "quick watch" on the array? It doesn't contain any characters at all, it's a byte array, not a char array
While stepping thru my code i right click on the array HBReply and see what's in it.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom,
I think I found your problem. You use the System.Text.Encoding.ASCII encoder which, by definition in the .NET platform, is a seven-bit text representation. From the documentation:ASCII characters are limited to the lowest 128 Unicode characters, from U+0000 to U+007f. To do what you want, try the following:
System.Text.Encoding en = System.Text.Encoding.Unicode;
byte[] HBReply = new byte[ 30 ];
byte[] buffer = null;
string s = "\xFF\x00\xAA\x55";
buffer = en.GetBytes( s );
for( int i = 0; i < buffer.Length; i += 2 )
{
HBReply[ i / 2 ] = buffer[ i ];
}
return HBReply; This encodes the string as Unicode, gets every other entry, and puts that into the HBReply array.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
If you need a byte array with those values, just create that array. There is no need to mess around with a string. I showed the code for it in my previous post.
---
b { font-weight: normal; }
|
|
|
|
|
i make a project about image processing. I want to make image layers in program. How can i make it ? any idea ?
Help !...
-- modified at 16:19 Monday 16th January, 2006
|
|
|
|
|
You'll need to create a bitmap for each layer, either make one color that you don't allow on the bitmap ( for masking ) or manage your own masks, and do your own merging of layers to show your image.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks Christian...
it is a good idea but it doesnt fit my application. When i refresh all bitmaps to draw on the form, it flickers. I need layer which can be refresh on itself so i dont need to refresh all layers.
Any idea about this...
|
|
|
|
|
It's not 'a good idea', it's the only way it can be done. Perhaps you need to turn on double buffering, or perhaps C# just can't handle this sort of app. I've done it a few times, but in C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am teaching myself about custom controls so i am a newbie. I have made some basic user controls with success. But now i am having difficulty with components. After reading a CodeProject article i am coding a custom Textbox component. I have made a component class, inherited Textbox and overrode the WndProc to display key down messages in the Debug window. Pretty basic. How do i get this component to show up in the form designer like other textbox controls? In the CodeProject article the author managed to do this but i cannot figure out how it is done. I do not see the component in the toolbox and i cannot drag-and-dropon the form. Can someone provide me the HowTo?
|
|
|
|
|
Right click in the toolbox and select "Add/Remove Items...". Browse to the dll for the component.
---
b { font-weight: normal; }
|
|
|
|
|
Yep, that was the problem. I was trying to make a component inside the main project and use it. I could do this with user controls, but not components. I have to make that class DLL and then add it to the toolbox. When i looked at the CodeProject example i saw two projects, one for the component and one for the main form. I thought this was a code management decision by the author, i did not know it was a necessity... aHHHH... the subtleties of the NET framework...
|
|
|
|
|
Its not a necessity, its a nicety. You could have clicked Add/Remove Items and browsed for the .exe - which is an .NET assmbly itself.
|
|
|
|
|
Hi,
Just checking to see if there's a way to send a double click into a textbox.
Thanks!
Mel
|
|
|
|
|
Have you tried sending the WM_LBUTTONDBLCLK message to the control using the SendMessage[^] Win32 API?
That said, when you're resorting to faking mouse clicks, often times there's a better solution.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|