Setting Style (SetStlye Method) With API
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
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... :-D
-
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...
-
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...
-
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... :-D
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
-
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...