Hey, I'm trying to make a little window in C++ that goes full screen.
I've been browsing the internet for a solution... And well, somewhere just said to change the bit in CreateWindow to WS_MAXIMIZE... That did nothing.
I have a code at the moment...
Code:
#include "stdafx.h"
#include <windows.h>
int WINAPI WinMain( HINSTANCE hInstance, // HANDLE TO AN INSTANCE. This is the "handle" to YOUR PROGRAM ITSELF. More in the GLOSSARY at the bottom.
HINSTANCE hPrevInstance,// USELESS on modern windows (totally ignore hPrevInstance)
LPSTR szCmdLine, // Command line arguments. Explained near BOTTOM of this file.
int iCmdShow ) // Start window maximized, minimized, etc.
{
#pragma region part 1 - STARTUP STUFF
WNDCLASS wc;
wc.cbClsExtra = 0; // ignore for now
wc.cbWndExtra = 0; // ignore for now
wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH ); // I want the window to have a white background
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // I want it to have an arrow for a cursor
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); // I want it to have that envelope like icon
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc; // Give name of WndProc function here.
wc.lpszClassName = TEXT("Philip");
wc.lpszMenuName = 0; // no menu - ignore
wc.style = CS_HREDRAW | CS_VREDRAW;
DEVMODE screen;
memset(&screen,0,sizeof(screen));
screen.dmSize = sizeof(screen);
screen.dmPelsWidth = 1024;
screen.dmPelsHeight = 768;
screen.dmBitsPerPel = 32;
screen.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
ChangeDisplaySettings(&screen, CDS_FULLSCREEN);
RegisterClass( &wc );
HWND hwnd = CreateWindow(
TEXT("Philip"), // THIS IS THE LINK
// to the WNDCLASS structure that
// we created earlier.
TEXT("Window ittle"),// appears in title of window
WS_POPUP,
50, 50, // x, y start coordinates of window
500, 500, // width, height of window
NULL, NULL, // nothing and nothing (ignore to start out)
hInstance, NULL ); // hInstance -- (see glossary), nothing
ShowWindow(hwnd, iCmdShow );
UpdateWindow(hwnd);
#pragma endregion
#pragma region part 2 - ENTER A LOOP TO CONTINUALLY KEEP CHECKING WITH WIN O/S FOR USER INTERACTION
while( GetMessage( &msg, NULL, 0, 0 ) )
{
DispatchMessage( &msg );
}
#pragma endregion
return msg.wParam; // return from WinMain
}
LRESULT CALLBACK WndProc( HWND hwnd, // "handle" to the window that this message is for
UINT message, // TYPE of message (e.g. WM_PAINT is a message asking to paint the window)
WPARAM wparam, // information about the actual message
LPARAM lparam ) // MORE info about the message
{
switch( message )
{
case WM_PAINT:
{
// we would place our Windows painting code here.
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint( hwnd, &ps );
// draw a circle and a 2 squares
Ellipse( hdc, 20, 20, 160, 160 );
Rectangle( hdc, 50, 50, 90, 90 );
Rectangle( hdc, 200, 50, 140, 90 );
EndPaint( hwnd, &ps );
}
return 0;
break;
case WM_DESTROY:
PostQuitMessage( 0 ) ;
return 0;
break;
}
return DefWindowProc( hwnd, message, wparam, lparam );
}
But umm... Yeah that just makes my PC show a black screen, forcing me to turn it off and on again.
So I'm really stumped :P
I'd really appreciate any comments, thank you
(Sorry if the code is a bit messy... It's a mixture between mine and someone else's from a tutorial with lots of comments in, basically the full screen bit is this bit..)
Code:
DEVMODE screen;
memset(&screen,0,sizeof(screen));
screen.dmSize = sizeof(screen);
screen.dmPelsWidth = 1024;
screen.dmPelsHeight = 768;
screen.dmBitsPerPel = 32;
screen.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
ChangeDisplaySettings(&screen, CDS_FULLSCREEN);
Well... Supposedly.