|
How to ping an IP address by using sockets in Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;828993
|
|
|
|
|
|
Hi coders,
I was wondering about the apis used while writing the SetStyle Method. I am creating an API control class using NativeWindow class in .net framework. I need to set styles of the window (like double buffer, userpaint, resize redraw...)
Some of these styles can be applied by using SET... apis (like instead of SetStyle Opaque, True ; SetBkMode api can be used)
I need to know the apis used for all other styles in ControlStyles enum.
Thank you for your time
Best Regards
Emre YAZICI
|
|
|
|
|
The ControlSetStyle method *is* used to set the ControlStyles bits.
Or, are you talking about a different API other than .NET?
PeterRitchie.com
|
|
|
|
|
Thank you for your answer. I know what the ControlStyle bits, and I know what is it doing, the reason why i am asking for a way to perform the SAME thing(as SetStyle does)
I think we are able to set the styles with API
e.g (As I mentioned) Instead of SetStyle (opaque,true) you can use the SetBkmode API, and (I am not sure) instead of Double buffer, you can use CreateCompatibleDC API. I am asking for the other ones' apis.
Do you know them?
Thanks
Best Regards
Emre YAZICI
|
|
|
|
|
Okay, you've misused the work API--which is an interface (or a group of functions/methods). You're looking for all the methods that perform the same thing as SetStyle for each bit...
There normally isn't a one-to-one correspondance with a style bit and a method or a function. Many of the styles shouldn't be changed after the window has been created, they're ment to be used as the window is being created where calling a dozen or so methods instead of SetStyle would be tedious. Even in other APIs like MFC hyou have to resort to SetStyle (which wraps SetWindowsLong(GWL_STYLE,...) ).
Some of the styles in ControlStyles are .NET specific; meaning they're only handled as a cohesive attribute in .NET.
I don't know of any exhaustive lists that would give you the information you want. Maybe you could detail what you want to do or why simply calling SetStyle doesn't suit your needs.
PeterRitchie.com
|
|
|
|
|
Well
Thank you for your answer
Your answer was just like i guess
SetWindowsLong api does not support all of these styles, we need to use others i think
Why dont I call the SeetStyle , because i do create a window using CreateWindowEx and all the other operations like Moving, Showing the window or drawing line, filling a rectangle will be performed by APIs. I want to do everything with apis. Because the way is faster!!
Thanks anyway..
Best Regards
Emre YAZICI
|
|
|
|
|
Are you using the Win32 API, via P/Invoke?
Why are you using .NET at all if you're simply doing everything via Win32 API?
PeterRitchie.com
|
|
|
|
|
I tried both, I mean
1 ) I have tried writing a grid control with usercontrol and .net frameworks' Graphics object( using Drawline, FillRect...)
2 ) I have tried the same thing with CreateWindowEx, LineTo, MoveToEx ....
When I compare them the second one was faster than the first one
This is why i want to use APIs
Best Regards
Emre YAZICI
|
|
|
|
|
If it's a stand-alone application (i.e. not client-server) then I would suggest just writing it in C++. The work involed in marshalling all the API structures and data just isn't work the time otherwise.
If speed is that much of an issue for you. Even with .NET 2.0 there are some performance differences between .NET applications and "native"/unmanaged.
see http://www.sysinternals.com/blog/#111409937327999900[^]
PeterRitchie.com
|
|
|
|
|
Of course, c++ is the best way of doing that, I was looking for a way to do it in VB.Net or C#.Net
Thank you anyway
Best Regards
Emre YAZICI
|
|
|
|
|
It'S funny... i have made some same tests... the better performance dosen't comes from the native window creation, beacause the control class do the same thing (only one time)...
The better Performance comes only from the usage of native drawing functions...
|
|
|
|
|
Of course it comes from the usage of native drawing functions
Best Regards
Emre YAZICI
|
|
|
|
|
Hello... At first... It don't exists any API Functions for setting Doublebuffer...
It's only implemented in the controls class to perform manged offscreen drawing operations...
It's a simple concept for flickerfree drawing...
There are many good articels about offscreen drawing at the Codeproject...
It's absolutly not recommend to completely rewrite a smarter Control Class which derived from the NativeWindow... They will come more and more problems when you implement multithreading situations...
When you only rewrite the control class to perform faster drawing operations
then create a class which derived from the system.windows.forms.control class
override or reimplement the OnPaint, OnPaintBackground method to perform native drawing operations and doublebuffering effect...
Everything else makes to much troubles in my mind...
Good Luck...
|
|
|
|
|
I am actually going to write a control class with only apis (without using nativewindow class)
For the Events, I will use the WindowProc Api to handle the events
For the drawings, I will use the MoveToEx LineTo DrawText FillRect... apis
For the styles and messages, I will use SetWindowLong and SendMessage apis
As I mentioned , the double buffer could be created by using the CreateCompatibleDC api, which creates an extra buffer for graphical operations.
Thank you
Best Regards
Emre YAZICI
|
|
|
|
|
Your concept is for me really clear...
It was only a hint in front of rewritting the complete control class, because it's absolutly enough work to implement (savely) the native drawing functions in the control class...
I don't believe that you really see the problems in front of native resources and the gabrage collection routine...
- You must manage ((re)allocating, deleting) all native Resources for all possible situations, which is not the problem but many code...
- They are also several handle protector meachanism in the control class for preventing memory leaks which can created during the gabrage collection routine...
You see it'S not so easy to create a save and stallable control in front of all these aspects...
Best regargs, and good luck...
|
|
|
|
|
OK i have already install the framework 2 redistributable package an then the framework 2 sdk beta 2 my problem is that i dont know how to use the framework 2 class library in the Visual studio 2003
note in the resource mannager the type of the net librarys its 1.0 not 2.0 for librarys like system.dll system.windows.dll
can anyone helpme with this stuff please
|
|
|
|
|
|
In order to compile against the .NET Framework 2.0, you need to use the Visual Studio .NET 2005 compilers. VS.NET 2003 won't do it. Remember, the compilers are built into the .NET Framework, not Visual Studio...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Why couldn't you simply download vs2005 beta2 express ?
|
|
|
|
|
In a project I'm developing, I need to duplicate the functionality of the Display Properties -> Screen Saver tab. Most importantly, I'd like to list the screensavers the person has installed on their computer, complete with descriptions. I know that screensavers are usually located in the "%windir%\system32\" folder (Usually C:\Windows\System32), but is there a possibility that a screensaver that's available in this list could be located elsewhere on the system? If so, then what method can I use to reliably list the screensavers available?
I've searched through the registry, and there don't seem to be any keys that I can enumerate to give me a list. The other problem I'm encountering is that I can't seem to locate the "title" of the screensaver. I assumed it would be visible through FileVersionInfo.GetVersionInfo, but that doesn't seem to be the case (unless I'm blind).
Can anybody point me in the right direction here?
|
|
|
|
|
Yep it just lists the *.SCR files that impelement the screen saver entry points.
PeterRitchie.com
|
|
|
|
|
But how can I extract the "title" of the screensaver to list them on my form? I'd like to use the same display title as the Display Settings window uses, if that's possible - I assume you have to be able to find that somewhere, since Windows does it.
|
|
|
|
|
The string resource with ID 1 is used as the title to display in Display control panel applet.
PeterRitchie.com
|
|
|
|
|
I guess I'm missing it here, but how do I extract a resource from another EXE file? Is there some code available to do this rather simply? Either VB or C# will do. Thanks for your help!
|
|
|
|