Announcement

Collapse
No announcement yet.

Removing window border with SetWindowLong

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing window border with SetWindowLong

    Code:
     GWL_STYLE [COLOR="#FF0000"]=[/COLOR] -[COLOR="#000000"]16[/COLOR]
     WS_BORDER [COLOR="#FF0000"]=[/COLOR] 0x00800000
     User32 [COLOR="#FF0000"]=[/COLOR] Library[COLOR="#FF0000"].[/COLOR]Load([COLOR="#800080"]"user32.dll"[/COLOR])
     [COLOR="#0000FF"]local[/COLOR] s [COLOR="#FF0000"]=[/COLOR] User32[COLOR="#FF0000"].[/COLOR]GetWindowLongA(whd[COLOR="#FF0000"],[/COLOR] GWL_STYLE)
     User32[COLOR="#FF0000"].[/COLOR]SetWindowLongA(whd[COLOR="#FF0000"],[/COLOR] GWL_STYLE[COLOR="#FF0000"],[/COLOR] s - WS_BORDER)
    This should apparently work to remove the borders from objects like the ListBox and ListView that have the WS_BORDER style but it does not, does anyone know why?

  • #2
    Can better do so?
    Code:
    [font=Courier New][size=2]GWL_EXSTYL          [color=#FF0000]=[/color] [color=#FF0000]-[/color]20;
    
    WS_EX_DLGMODALFRAME [color=#FF0000]=[/color] 0x00000001;
    WS_EX_CLIENTEDGE    [color=#FF0000]=[/color] 0x00000200;
    WS_EX_STATICEDGE    [color=#FF0000]=[/color] 0x00020000;
    
    SWP_FRAMECHANGED    [color=#FF0000]=[/color] 0x0020;
    SWP_NOMOVE          [color=#FF0000]=[/color] 0x0002;
    SWP_NOSIZE          [color=#FF0000]=[/color] 0x0001;
    SWP_NOZORDER        [color=#FF0000]=[/color] 0x0004;
    SWP_NOOWNERZORDER   [color=#FF0000]=[/color] 0x0200;
    
    User32 [color=#FF0000]=[/color] Library[color=#FF0000].[/color]Load([color=#800080]"user32.dll"[/color]);
    
    [color=#0000FF][b]local[/b][/color] hWnd [color=#FF0000]=[/color] Application[color=#FF0000].[/color]GetWndHandle();
    [color=#0000FF][b]local[/b][/color] nCurrStyle [color=#FF0000]=[/color] User32[color=#FF0000].[/color]GetWindowLongA(hWnd[color=#FF0000],[/color] GWL_EXSTYL);
    [color=#008000][i]-- remove the extended border styles[/i][/color]
    User32[color=#FF0000].[/color]SetWindowLongA(hWnd[color=#FF0000],[/color] GWL_EXSTYL[color=#FF0000],[/color] Bitwise[color=#FF0000].[/color]Xor(nCurrStyle[color=#FF0000],[/color] WS_EX_DLGMODALFRAME[color=#FF0000],[/color] WS_EX_CLIENTEDGE[color=#FF0000],[/color] WS_EX_STATICEDGE));
    [color=#008000][i]-- redraw with the changed styles[/i][/color]
    User32[color=#FF0000].[/color]SetWindowPos(hWnd[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] Bitwise[color=#FF0000].[/color]Or(SWP_FRAMECHANGED[color=#FF0000],[/color] SWP_NOMOVE[color=#FF0000],[/color] SWP_NOSIZE[color=#FF0000],[/color] SWP_NOZORDER[color=#FF0000],[/color] SWP_NOOWNERZORDER));[/size][/font]

    Comment


    • #3
      Its a bit better as my attempt messed up the window but yours does not remove the border but instead sets the window to look like the 3d border effect.

      Comment


      • #4
        I like the looks of this effect in WinXP. Another variant I don't know yet.

        Comment


        • #5
          There is a few examples and they all appear to do the same thing but not knowing bit-wise isn't helping lol.

          Comment


          • #6
            I wrote an example above.
            Code:
            [font=Courier New][size=2]GWL_STYLE           [color=#FF0000]=[/color] [color=#FF0000]-[/color]16;
            GWL_EXSTYLE         [color=#FF0000]=[/color] [color=#FF0000]-[/color]20;
            
            WS_EX_DLGMODALFRAME [color=#FF0000]=[/color] 0x00000001;
            WS_EX_CLIENTEDGE    [color=#FF0000]=[/color] 0x00000200;
            WS_EX_STATICEDGE    [color=#FF0000]=[/color] 0x00020000;
            WS_EX_WINDOWEDGE    [color=#FF0000]=[/color] 0x00000100;
            
            WS_BORDER           [color=#FF0000]=[/color] 0x00800000;
            WS_DLGFRAME         [color=#FF0000]=[/color] 0x00400000;
            WS_THICKFRAME       [color=#FF0000]=[/color] 0x00040000;
            
            SWP_FRAMECHANGED    [color=#FF0000]=[/color] 0x0020;
            SWP_NOMOVE          [color=#FF0000]=[/color] 0x0002;
            SWP_NOSIZE          [color=#FF0000]=[/color] 0x0001;
            SWP_NOZORDER        [color=#FF0000]=[/color] 0x0004;
            SWP_NOOWNERZORDER   [color=#FF0000]=[/color] 0x0200;
            
            RemoveBorder [color=#FF0000]=[/color] [color=#0000FF][b]function[/b][/color] (hWnd)
                [color=#0000FF][b]local[/b][/color] User32 [color=#FF0000]=[/color] Library[color=#FF0000].[/color]Load([color=#800080]"user32.dll"[/color]);
            
                [color=#0000FF][b]local[/b][/color] lngRetVal [color=#FF0000]=[/color] User32[color=#FF0000].[/color]GetWindowLongA(hWnd[color=#FF0000],[/color] GWL_STYLE);
                lngRetVal [color=#FF0000]=[/color] Bitwise[color=#FF0000].[/color]Xor(lngRetVal[color=#FF0000],[/color] WS_BORDER[color=#FF0000],[/color] WS_DLGFRAME[color=#FF0000],[/color] WS_THICKFRAME);
                User32[color=#FF0000].[/color]SetWindowLongA(hWnd[color=#FF0000],[/color] GWL_STYLE[color=#FF0000],[/color] lngRetVal);
            
                lngRetVal [color=#FF0000]=[/color] User32[color=#FF0000].[/color]GetWindowLongA(hWnd[color=#FF0000],[/color] GWL_EXSTYLE);
                lngRetVal [color=#FF0000]=[/color] Bitwise[color=#FF0000].[/color]Xor(lngRetVal[color=#FF0000],[/color] WS_EX_CLIENTEDGE[color=#FF0000],[/color] WS_EX_STATICEDGE[color=#FF0000],[/color] WS_EX_WINDOWEDGE);
                User32[color=#FF0000].[/color]SetWindowLongA(hWnd[color=#FF0000],[/color] GWL_EXSTYLE[color=#FF0000],[/color] lngRetVal);
            
                User32[color=#FF0000].[/color]SetWindowPos(hWnd[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] 0[color=#FF0000],[/color] Bitwise[color=#FF0000].[/color]Or(SWP_FRAMECHANGED[color=#FF0000],[/color] SWP_NOMOVE[color=#FF0000],[/color] SWP_NOSIZE[color=#FF0000],[/color] SWP_NOZORDER[color=#FF0000],[/color] SWP_NOOWNERZORDER));
            
                User32[color=#FF0000]:[/color]Close_();
            [color=#0000FF][b]end[/b][/color][/size][/font]
            But in AMS is working poorly.

            Comment


            • #7
              This should work. When you want to remove a flag from an int, just perform an AND with the NOT version of the flags.

              Code:
              user32 = Library.Load("user32.dll");
              
              GWL_STYLE			= -16;
              GWL_EXSTYLE			= -20;
              
              WS_CAPTION			= 0xC00000;
              WS_THICKFRAME		= 0x40000;
              WS_MINIMIZE			= 0x20000000;
              WS_MAXIMIZE			= 0x1000000;
              WS_SYSMENU			= 0x80000;
              
              WS_EX_DLGMODALFRAME	= 0x1;
              WS_EX_CLIENTEDGE	= 0x200;
              WS_EX_STATICEDGE 	= 0x20000;
              
              SWP_FRAMECHANGED	= 0x20;
              SWP_NOMOVE			= 0x2;
              SWP_NOSIZE			= 0x1;
              SWP_NOZORDER		= 0x4;
              SWP_NOOWNERZORDER	= 0x200;
              
              removeWindowBorder = function(hWnd)
              	local style;
              	
              	style = user32.GetWindowLongA(hWnd, GWL_STYLE);
              	style = Bitwise.And(style, Bitwise.Not(Bitwise.Or(WS_CAPTION, WS_THICKFRAME, WS_MINIMIZE, WS_MAXIMIZE, WS_SYSMENU)));
              	user32.SetWindowLongA(hWnd, GWL_STYLE, style);
              	
              	style = user32.GetWindowLongA(hWnd, GWL_EXSTYLE);
              	style = Bitwise.And(style, Bitwise.Not(Bitwise.Or(WS_EX_DLGMODALFRAME, WS_EX_CLIENTEDGE, WS_EX_STATICEDGE)));
              	user32.SetWindowLongA(hWnd, GWL_EXSTYLE, style);
              	
              	user32.SetWindowPos(hWnd, 0, 0,0,0,0, Bitwise.Or(SWP_FRAMECHANGED, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, SWP_NOOWNERZORDER));
              end;
              Bas Groothedde
              Imagine Programming :: Blog

              AMS8 Plugins
              IMXLH Compiler

              Comment


              • #8
                thanks IP :yes

                Comment


                • #9
                  When you want to remove a flag from an int, just perform an AND with the NOT version of the flags.
                  I'm ashamed that I did not know this...

                  Comment


                  • #10
                    Originally posted by slota View Post
                    I'm ashamed that I did not know this...
                    Don't be, I had to Google Bitwise :lol

                    Comment


                    • #11
                      Originally posted by sidiamur
                      je ne comprends pas
                      Envoyer un exemple ... merci
                      The example you seek is enclosed in the code blocks above.
                      Bas Groothedde
                      Imagine Programming :: Blog

                      AMS8 Plugins
                      IMXLH Compiler

                      Comment

                      Working...
                      X