Question

I'm developing a c++ application for windows. I'm using win32 API. I have a very simple question, which i couldn't find an answer to. How can i open a window without a title bar (without controls, icon and title) and that can not be resized.

Piece of code that i am using for the application to create a window:

      hWnd = CreateWindow(szWindowClass, 0, (WS_BORDER ),
             0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL);

UPDATE:

To do this in c#, you just define this code:

 FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
 ControlBox = false;
Was it helpful?

Solution

hWnd = CreateWindow(szWindowClass, 0, (WS_BORDER ), 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL); 

SetWindowLong(hWnd, GWL_STYLE, 0); //remove all window styles, check MSDN for details

ShowWindow(hWnd, SW_SHOW); //display window

OTHER TIPS

HWND hWnd ;
hWnd = CreateWindow(szWindowClass, 0, (WS_BORDER ), 0, 0, 100, 100, NULL, NULL, Instance, NULL); 
SetWindowLong(hwnd, GWL_STYLE, WS_BORDER );  // With 1 point border
//OR
SetWindowLong(hwnd, GWL_STYLE, 0 );  // Without 1 point border = white rectangle 
SetWindowPos(hwnd, 0, 150, 100, 250, 250, SWP_FRAMECHANGED); 

if (!hWnd)
 return FALSE ;
else
ShowWindow(hwnd, SW_SHOW);
CreateWindowEx(0, szWindowClass, 0, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL);

using SetWindowLong will change the size and post. use the WS_POPUP style

SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top