Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Setting Style (SetStlye Method) With API

Setting Style (SetStlye Method) With API

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdotnetwpfjson
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    THEMYTH
    wrote on last edited by
    #1

    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

    P H 2 Replies Last reply
    0
    • T THEMYTH

      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

      P Offline
      P Offline
      Peter Ritchie
      wrote on last edited by
      #2

      The ControlSetStyle method *is* used to set the ControlStyles bits. Or, are you talking about a different API other than .NET? PeterRitchie.com

      T 1 Reply Last reply
      0
      • P Peter Ritchie

        The ControlSetStyle method *is* used to set the ControlStyles bits. Or, are you talking about a different API other than .NET? PeterRitchie.com

        T Offline
        T Offline
        THEMYTH
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • T THEMYTH

          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

          P Offline
          P Offline
          Peter Ritchie
          wrote on last edited by
          #4

          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

          T 1 Reply Last reply
          0
          • P Peter Ritchie

            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

            T Offline
            T Offline
            THEMYTH
            wrote on last edited by
            #5

            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

            P 1 Reply Last reply
            0
            • T THEMYTH

              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

              P Offline
              P Offline
              Peter Ritchie
              wrote on last edited by
              #6

              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

              T 1 Reply Last reply
              0
              • P Peter Ritchie

                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

                T Offline
                T Offline
                THEMYTH
                wrote on last edited by
                #7

                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

                P 1 Reply Last reply
                0
                • T THEMYTH

                  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

                  P Offline
                  P Offline
                  Peter Ritchie
                  wrote on last edited by
                  #8

                  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

                  T 1 Reply Last reply
                  0
                  • P Peter Ritchie

                    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

                    T Offline
                    T Offline
                    THEMYTH
                    wrote on last edited by
                    #9

                    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

                    H 1 Reply Last reply
                    0
                    • T THEMYTH

                      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

                      H Offline
                      H Offline
                      HumanOsc
                      wrote on last edited by
                      #10

                      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

                      T 1 Reply Last reply
                      0
                      • T THEMYTH

                        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

                        H Offline
                        H Offline
                        HumanOsc
                        wrote on last edited by
                        #11

                        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...

                        T 1 Reply Last reply
                        0
                        • H HumanOsc

                          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...

                          T Offline
                          T Offline
                          THEMYTH
                          wrote on last edited by
                          #12

                          Of course it comes from the usage of native drawing functions Best Regards Emre YAZICI

                          1 Reply Last reply
                          0
                          • H HumanOsc

                            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

                            T Offline
                            T Offline
                            THEMYTH
                            wrote on last edited by
                            #13

                            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

                            H 1 Reply Last reply
                            0
                            • T THEMYTH

                              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

                              H Offline
                              H Offline
                              HumanOsc
                              wrote on last edited by
                              #14

                              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...

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups