Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Win32 Window Style

Tags:

winapi

Is there a win32 function to change the style of a window after it has been created? I would like to change the style flags that are specified in CreateWindowEx. Specifically, I would like to convert a standard window to a window with no border and no resize.

like image 219
vanja. Avatar asked Feb 18 '10 02:02

vanja.


People also ask

What is Gwl_wndproc?

GWL_WNDPROC -4. Sets a new address for the window procedure. You cannot change this attribute if the window does not belong to the same process as the calling thread. The following values are also available when the hWnd parameter identifies a dialog box.

What is Ws_tabstop?

WS_TABSTOP. 0x00010000L. The window is a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. You can turn this style on and off to change dialog box navigation.

What is Ws_overlappedwindow?

Creating a Main Window Most applications typically use the WS_OVERLAPPEDWINDOW style to create the main window. This style gives the window a title bar, a window menu, a sizing border, and minimize and maximize buttons. The CreateWindowEx function returns a handle that uniquely identifies the window.


2 Answers

I think SetWindowLongPtr should do that. Note that you need to call SetWindowPos afterwards if you changed the border style, as pointed out in the remarks.

Some styles only take effect during window creation and so can not be set by this call. MSDN normally calls out styles that CAN be set afterwards.

like image 82
Joey Avatar answered Sep 30 '22 05:09

Joey


HWND windowHandle = FindWindow(NULL, L"Various tests");
    SetWindowLongPtr(windowHandle, GWL_STYLE, WS_SYSMENU); //3d argument=style
    SetWindowPos(windowHandle, HWND_TOPMOST, 100, 100, Width, Height, SWP_SHOWWINDOW);

did it for me :D

like image 38
Charlie Avatar answered Sep 30 '22 05:09

Charlie