Adding a status bar to a Win32 application

I want to add a status bar to my Win32 application. I found out that I can use the CreateStatusWindow function. I work fine until I change my window. See Part of my code:

 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } CreateStatusWindow(WS_CHILD | WS_VISIBLE, _T("Welcome to SpyWindows"), hWnd, 9000); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } 

Here are two printed screens of the main application window:

enter image description here

What can I do to have a good status bar? (I also want to divide it into more areas)

+4
source share
1 answer

The documentation says that the status bar will recount the corresponding position and size when it receives the WM_SIZE Message :

The window procedure automatically adjusts the size of the status bar when it receives a WM_SIZE message. Usually, when the size of the parent window changes, the parent sends a WM_SIZE message to the status bar.

So, the easiest way to achieve this is to send WM_SIZE messages received by the parent (with SendMessage () from its window procedure) to the status bar. Message parameters do not matter, since the status bar does not use them in their calculations.

+7
source

All Articles