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. C / C++ / MFC
  4. How can I remove a Window border (title bar etc) using HWND via Win32 after the window has been created?

How can I remove a Window border (title bar etc) using HWND via Win32 after the window has been created?

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicsalgorithmshelp
7 Posts 5 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.
  • S Offline
    S Offline
    Steve_
    wrote on last edited by
    #1

    The graphics library I am using provides basic window functionality, painting, moving etc, but for anything more complex it provides the HWND to each window so we can call Win32 stuff. My Win32 knowledge is limited, how can I alter the window style using the HWND? I've done some searching but haven't found anything - probably because I'm looking for the wrong thing. Any help would be great! :) Steve

    CPalliniC 1 Reply Last reply
    0
    • S Steve_

      The graphics library I am using provides basic window functionality, painting, moving etc, but for anything more complex it provides the HWND to each window so we can call Win32 stuff. My Win32 knowledge is limited, how can I alter the window style using the HWND? I've done some searching but haven't found anything - probably because I'm looking for the wrong thing. Any help would be great! :) Steve

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      You may change the window style at runtime using SetWindowLong function [^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      S 1 Reply Last reply
      0
      • CPalliniC CPallini

        You may change the window style at runtime using SetWindowLong function [^]. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        S Offline
        S Offline
        Steve_
        wrote on last edited by
        #3

        Thanks, I have made the following call: SetWindowLong(window.getHWND(), GWL_EXSTYLE, WS_EX_CLIENTEDGE); I also call SetWindowPos as stated in the documentation to cause the changes to appear. The window visibly changes. How would I specify that I want to remove or hide the window border and title bar? I have looked at the documentation for Window Styles and CreateWindowEx but am unsure how to achieve this. I'm looking to achieve something similar to the result of the following .NET code: myForm.BorderStyle = FormBorderStyle.None; Thanks again! Steve

        C M 2 Replies Last reply
        0
        • S Steve_

          Thanks, I have made the following call: SetWindowLong(window.getHWND(), GWL_EXSTYLE, WS_EX_CLIENTEDGE); I also call SetWindowPos as stated in the documentation to cause the changes to appear. The window visibly changes. How would I specify that I want to remove or hide the window border and title bar? I have looked at the documentation for Window Styles and CreateWindowEx but am unsure how to achieve this. I'm looking to achieve something similar to the result of the following .NET code: myForm.BorderStyle = FormBorderStyle.None; Thanks again! Steve

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Try something similar to: SetWindowLong(window.getHWND(), GWL_STYLE, GetWindowLong(window.getHWND(), GWL_STYLE) & ~WS_BORDER); IF this doesn't work, try instead of WS_BORDER the other, border related styles like WS_DLGFRAME (see here[^] for window styles.)

          > The problem with computers is that they do what you tell them to do and not what you want them to do. <

          1 Reply Last reply
          0
          • S Steve_

            Thanks, I have made the following call: SetWindowLong(window.getHWND(), GWL_EXSTYLE, WS_EX_CLIENTEDGE); I also call SetWindowPos as stated in the documentation to cause the changes to appear. The window visibly changes. How would I specify that I want to remove or hide the window border and title bar? I have looked at the documentation for Window Styles and CreateWindowEx but am unsure how to achieve this. I'm looking to achieve something similar to the result of the following .NET code: myForm.BorderStyle = FormBorderStyle.None; Thanks again! Steve

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Something like this should remove any borders, unless I missed a border style...

            ::SetWindowLong(window.getHWND(), GWL\_STYLE, ::GetWindowLong(window.getHWND(), GWL\_STYLE) & ~(WS\_BORDER | WS\_DLGFRAME | WS\_THICKFRAME));
            ::SetWindowLong(window.getHWND(), GWL\_EXSTYLE, ::GetWindowLong(window.getHWND(), GWL\_EXSTYLE) & ~WS\_EX\_DLGMODALFRAME);
            

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            S 1 Reply Last reply
            0
            • M Mark Salsbery

              Something like this should remove any borders, unless I missed a border style...

              ::SetWindowLong(window.getHWND(), GWL\_STYLE, ::GetWindowLong(window.getHWND(), GWL\_STYLE) & ~(WS\_BORDER | WS\_DLGFRAME | WS\_THICKFRAME));
              ::SetWindowLong(window.getHWND(), GWL\_EXSTYLE, ::GetWindowLong(window.getHWND(), GWL\_EXSTYLE) & ~WS\_EX\_DLGMODALFRAME);
              

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              S Offline
              S Offline
              Steve_
              wrote on last edited by
              #6

              Hey thanks to both of you, the above code works perfectly! Steve

              U 1 Reply Last reply
              0
              • S Steve_

                Hey thanks to both of you, the above code works perfectly! Steve

                U Offline
                U Offline
                User 10350005
                wrote on last edited by
                #7

                Thank you, But it runs just fine in aero interface :(

                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