C++/full-screen Mode
Expert: Eddie - 9/24/2004
Question Hello sir,
I want to display a photo in full-screen mode in my program. Currently I maximize my form and in this way I use the maximum area I can; but I want my form not to have any frame(including minimize, maximize and close buttons) and also I want the screen to contain only my form(not the task bar and ...).
This is exactly what MS-IE(internet explorer) or ACDSee does in full-screen mode.
Please let me know how I can have a full-screen mode in my program.
thank you very much.
AnswerHello,
If this is a windows application, theres a couple of techniques to do this. To get rid of the minimize and maximize buttons, put the following line in your CreateWindow function as the 3rd parameter:
WS_POPUP | WS_VISIBLE
That gets rid of the tool bar area of the window. For fullscreening the window, the following code will do the trick:
bool m_bFullScreen = true;
if (m_bFullScreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = 1024;
dmScreenSettings.dmPelsHeight = 768; dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
// setting display mode failed, switch to windowed
MessageBox(NULL, "Display mode failed", NULL, MB_OK);
m_bFullScreen=false;
}
}
if (m_bFullScreen)
{
dwExStyle=WS_EX_APPWINDOW;
dwStyle=WS_POPUP;
ShowCursor(FALSE);
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle=WS_OVERLAPPEDWINDOW;
}
Putting that code before the call to CreateWindow will do it.
I hope this information is helpful.
- Eddie