Window without border problems (Moved from General C++)

Hi forum,
I need a window without a border to make a custom border.
But when I maximizes a window without a border, it will fill the whole screen.
I want it to only fill the whole screen beneath the taskbar.
How should I setup the window correctly?

Regards,
Simon H.A.
I understand what you mean.

here is a possible way to do what you want:

Windows have a message called WM_GETMINMAXINFO which it sends when the size of a window is changing.

There is a windows function called SystemParametersInfo - this can get you many windows operation information and one peice of information you
can get is the SPI_GETWORKAREA which is the area ( of the primary screen) which is not obscured
by the task bar.

You should be able to adjust the values in the WM_GETMINMAXINFO info to match the values
retrieved from SPI_GETWORKAREA.


I said that like I know it would work - but I haven't tried it (yet.)


**EDIT - tried it - yes it worked **.

I used this to create a window which would have the problem you described and show it maximized.:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	// Step 2: Creating the Window
	hwnd = CreateWindowA(
		g_szClassName,
		"Serpentine's Auto Farmer V 1.0",
	    WS_POPUP|WS_BORDER,
		CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
		NULL, NULL, hInstance, NULL);

	if(hwnd == NULL)
	{
		MessageBox(NULL, "Failed To Create Window!", "Error!",
			MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	ShowWindow(hwnd, SW_MAXIMIZE);
	UpdateWindow(hwnd);



In my windows procedure I trapped the WM_GETMINMAXINFO message
(note we must return 0 to windows)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    

    switch(msg)
   {
	
           case WM_GETMINMAXINFO:
          {
            RECT maxRect;
            MINMAXINFO * pInfo = (MINMAXINFO*)lParam;
            SystemParametersInfo(SPI_GETWORKAREA,0,&maxRect,0);
            
            pInfo->ptMaxSize.x = maxRect.right - maxRect.left;
            pInfo->ptMaxSize.y = maxRect.bottom - maxRect.top;

            pInfo->ptMaxPosition.x = maxRect.left;
            pInfo->ptMaxPosition.y = maxRect.top;
        
            break;  
         }
	
        default:
	return DefWindowProc(hwnd, msg, wParam, lParam);

   }//end switch

	return 0;
}// end windows procedure 
Last edited on
You are the best!
Thank you very much. It solved my problem.

Regards,

Simon H.A.
Topic archived. No new replies allowed.