You are here:

C++/full-screen Mode

Advertisement


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.

Answer
Hello,

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

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.