Change window style while app is running

I want to create a function (if there isn't one already) that'll resize a window when given its handle, new width and new height...
Simple enough surely?

Also I'd like to create a function which can easily change the styles of window from fullscreen (WS_EX_TOPMOST | WS_POPUP), to standard (WS_OVERLAPPED or WS_OVERLAPPEDWINDOW)...
Todo so would also need style value in the window handle and summat in DirectX but I'll deal with that one later.

So the question simplified is how to I alter members of the window using the handle when the window is assigned to the handle using CreateWindowEx(...)
Last edited on
Okay never mind, I've found out how to change the size by using SetWinowPoshWnd, x, y, w, h, flags);
Is there any way to change the style?
Last edited on
You can change some of the style using GetWindowLongPtr/SetWindowLongPtr with GWL_STYLE (and the extended style using GWL_EXSTYLE)

- Some of the bits should be modified using the appropriate API call, e.g. the WS_VISIBLE should normally be handled using ShowWindow()

- But some of the bits only mean something when the window is created. For example, I'm not sure what happens if you change the WS_CHILD bit after creating a child window. This might well be ignored, but if it is allowed it could cause confusion!

- In some cases you might have to call SetWindowPos before the window responds to the change (ATL's CWindow::ModifyStyle() method calls GetWindowPos, SetWindowPos and then SetWindowPos)

Note that GetWindowLongPtr should be used rather than the older GetWindowLong which is still referred to some older documentation. Similarly with the corresponding set function.


Window Styles

GetWindowLongPtr function
Last edited on
Topic archived. No new replies allowed.