Prev: Using Environmental Variables in VS 2008 Pro's Tools - Options -Include files?
Next: Shell extension and "drag-and-drop" handler on directory background?
From: winapi on 2 Jun 2010 18:30 Hello, Is it possible to change a windows style at "run time". I found this code which seems to make sense, but does not seem to be working? long style = GetWindowLong(hwnd, GWL_EXSTYLE); style &= ~WS_EX_STATICEDGE; SetWindowLong(hwnd, GWL_EXSTYLE, style); Maybe the window has to be destroyed created again? Thanks.
From: winapi on 2 Jun 2010 18:58 Ok, I manage to get this working using the code below. . . . void SetFrameStyle(HWND hwnd) { static RECT rect; GetClientRect(hwnd, &rect); SetWindowLongPtr(hwnd, GWL_EXSTYLE, (LONG)WS_EX_CLIENTEDGE); SetWindowPos ( hwnd, NULL, rect.left, rect.top, rect.right, rect.bottom, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOMOVE ); }
From: Dee Earley on 3 Jun 2010 04:07 On 02/06/2010 23:30, winapi wrote: > Hello, > > Is it possible to change a windows style at "run time". > I found this code which seems to make sense, but does not seem to be > working? > > long style = GetWindowLong(hwnd, GWL_EXSTYLE); > style&= ~WS_EX_STATICEDGE; > SetWindowLong(hwnd, GWL_EXSTYLE, style); > > Maybe the window has to be destroyed created again? It depends on the style. Some are only used on creation or need some other change for them to be applied. I don't know of any solid documentation beyond MSDN though. -- Dee Earley (dee.earley(a)icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.)
From: Jackie on 3 Jun 2010 04:37
Dee Earley wrote: > On 02/06/2010 23:30, winapi wrote: >> Hello, >> >> Is it possible to change a windows style at "run time". >> I found this code which seems to make sense, but does not seem to be >> working? >> >> long style = GetWindowLong(hwnd, GWL_EXSTYLE); >> style&= ~WS_EX_STATICEDGE; >> SetWindowLong(hwnd, GWL_EXSTYLE, style); >> >> Maybe the window has to be destroyed created again? > > It depends on the style. > > Some are only used on creation or need some other change for them to be > applied. > I don't know of any solid documentation beyond MSDN though. > At least in some cases, you have to call SetWindowPos after setting the new style, like s/he did (you can check an earlier post). :) -- Regards, Jackie |