Re: removing windows style
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Nov 07, 2000
- 463 views
----- Original Message ----- >From: =A9koda >how do i remove windows style from already created window? Hi =A9koda , there is a routine in win32lib called "removeStyle" that was meant to do this. However, it doesn't work for Windows. I've fixed this and the code below is what you need. You can replace the existing removeStyle with thi= s new code. This fix will be posted to the patch area later today. I've also include a new procedure called "addStyle" which does the opposite, namely adding styles to the existing ones. ------------------------------------------------------------ --/topic Utilities --/proc removeStyle( id, style ) --/desc Remove a style from a control. --If /i style is an atom then only the normal Windows style is modified, -- but if style is a sequence, it must be a tw-atom sequence. The first i= s -- the normal styles, and the second is the extended styles. -- --Example --/code -- removeStyle(w1, { -- -- normal styles -- (WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_THICKFRAME), -- -- extended styles -- (WS_EX_CLIENTEDGE) -- }) --/endcode global procedure removeStyle( integer id, object styles ) atom curStyle, styleMask, hWnd, style hWnd =3D getHandle( id ) if sequence(styles) then style =3D styles[1] else style =3D styles end if if style !=3D 0 then curStyle =3D c_func( xGetWindowLong, { hWnd, GWL_STYLE }) styleMask =3D xor_bits( #FFFFFFFF, style ) style =3D and_bits( styleMask ,curStyle ) VOID =3D c_func( xSetWindowLong,{ hWnd, GWL_STYLE, style }) end if if sequence(styles) and styles[2] !=3D 0 then style =3D styles[2] curStyle =3D c_func( xGetWindowLong, { hWnd, GWL_EXSTYLE }) styleMask =3D xor_bits( #FFFFFFFF, style ) style =3D and_bits( styleMask ,curStyle ) VOID =3D c_func( xSetWindowLong,{ hWnd, GWL_EXSTYLE, style }) end if if window_type[id] =3D Window then VOID =3D c_func(xSetForegroundWindow, {hWnd}) VOID =3D c_func(xSetWindowPos, {hWnd, 0, 0, 0, 0, 0, 39}) end if end procedure --/topic Utilities --/proc addStyle( id, style ) --/desc Add a style to a control. --If /i style is an atom then only the normal Windows style is modified, -- but if style is a sequence, it must be a tw-atom sequence. The first i= s -- the normal styles, and the second is the extended styles. -- --Example --/code -- addStyle(w1, { -- -- normal styles -- (WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_THICKFRAME), -- -- extended styles -- (WS_EX_CLIENTEDGE) -- }) --/endcode global procedure addStyle( integer id, object styles ) atom curStyle, hWnd, style hWnd =3D getHandle( id ) if sequence(styles) then style =3D styles[1] else style =3D styles end if if style !=3D 0 then curStyle =3D c_func( xGetWindowLong, { hWnd, GWL_STYLE }) style =3D or_bits( style ,curStyle ) VOID =3D c_func( xSetWindowLong,{ hWnd, GWL_STYLE, style }) end if if sequence(styles) and styles[2] !=3D 0 then style =3D styles[2] curStyle =3D c_func( xGetWindowLong, { hWnd, GWL_EXSTYLE }) style =3D or_bits( style ,curStyle ) VOID =3D c_func( xSetWindowLong,{ hWnd, GWL_EXSTYLE, style }) end if if window_type[id] =3D Window then VOID =3D c_func(xSetForegroundWindow, {hWnd}) VOID =3D c_func(xSetWindowPos, {hWnd, 0, 0, 0, 0, 0, 39}) end if end procedure ---------------------------- cheers, ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot)