Help for Tune Smithy Koch snowflake icon.gif

How to show a dialog full screen

From Tune Smithy

(Difference between revisions)
Jump to: navigation, search
WikiSysop (Talk | contribs)
(New page: First, the problem. It is easy to show a normal window full screen, in various ways. But for a dialog created using e.g. CreateDialog, then the problem is that it normally gets created wit...)
Newer edit →

Revision as of 08:27, 23 February 2010

First, the problem. It is easy to show a normal window full screen, in various ways. But for a dialog created using e.g. CreateDialog, then the problem is that it normally gets created with a border and title bar. So how to show it full screen without them?

The idea is to resize the dialog so that its edges and title bar go outside the monitor. Then - so that you can't see the extra bits of it on a multiple monitor setup - clip the window to the client area.

This technique can also be used to make a dialog that is draggable without a title bar - clip in the same way, and make it draggable using the HTCAPTION trick - see How to make any part of a window or dialog draggable

First of all, we need to tell Windows that our dialog can be resized larger than the screen, otherwise it will helpfully resize it to fit the screen whenever we try.

So - in the dialog proc for the window use:

#include<stdio.h>
 switch(message)
 {
 case WM_GETMINMAXINFO:
  {
   // This is where I got the idea:
   // http://msdn.microsoft.com/en-us/magazine/cc188910.aspx
   MINMAXINFO *pmmi=(MINMAXINFO *)lParam;
   int xborder=GetSystemMetrics(SM_CXEDGE)+GetSystemMetrics(SM_CXSIZEFRAME);
   int yborder=GetSystemMetrics(SM_CYEDGE)+GetSystemMetrics(SM_CYSIZEFRAME);
   int ytitle_bar=GetSystemMetrics(SM_CYCAPTION)+(GetMenu(hDlg)?GetSystemMetrics(SM_CYMENU):0);
   pmmi->ptMaxSize.x=GetSystemMetrics(SM_CXSCREEN)+xborder*2;
   pmmi->ptMaxSize.y=GetSystemMetrics(SM_CYSCREEN)+yborder*2+ytitle_bar;
   pmmi->ptMaxTrackSize.x=GetSystemMetrics(SM_CXVIRTUALSCREEN)+xborder*2;
   pmmi->ptMaxTrackSize.y=GetSystemMetrics(SM_CYVIRTUALSCREEN)+yborder*2+ytitle_bar;
   pmmi->ptMaxPosition.x=-xborder;
   pmmi->ptMaxPosition.y=-yborder;
  }
  break;
}
Personal tools
Namespaces
Variants
Actions
Navigation
How to use the wiki
More
Toolbox