24
votes

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;
6

6 Answers

27
votes
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
3
votes
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);
1
votes
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

1
votes

We use the following instruction:

hWnd = CreateWindow(
    "Example", "Example No Title Bar", 
     WS_POPUPWINDOW | WS_VISIBLE,
     0, 0, myWindowWidth, myWindowHeight, 
     NULL, NULL, hInstance, NULL); 

Output: Window without Title Bar AND not resizable

Thank you.

-2
votes
SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);