Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FWcore::window::window(int _width, int _height, int _bpp, bool _fullscr){ // window creator class constructor
- // todo: make allow to create more window, with custom callback proc (for develop)
- width = _width;
- height = _height;
- fullscreen =_fullscr;
- bpp =_bpp;
- for (int i=0; i<256; i++) keys[i]=false; // reset keys
- WNDCLASS wc = {
- CS_VREDRAW |CS_HREDRAW | CS_OWNDC,
- mainloopCallbackProc, // <- custoimize
- 0, 0,
- GetModuleHandle(0),
- static_cast<HICON>( LoadImage(GetModuleHandle( 0 ),
- MAKEINTRESOURCE(IDI_ICON1),
- IMAGE_ICON, 32, 32,
- LR_DEFAULTSIZE)),
- 0, 0, 0,
- "WINCLASS" }; // <- customize
- if( !RegisterClass(&wc) ){
- MessageBox (HWND_DESKTOP, "Cannot register window class.", "Error", MB_OK | MB_ICONEXCLAMATION);
- exit(1);
- }
- DWORD windowframe = NULL;
- if( fullscreen ) {
- DEVMODE screenSettings;
- ZeroMemory( &screenSettings, sizeof( screenSettings ) );
- screenSettings.dmSize = sizeof( screenSettings );
- screenSettings.dmPelsWidth = width;
- screenSettings.dmPelsHeight = height;
- screenSettings.dmBitsPerPel = bpp;
- screenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- long reso = ChangeDisplaySettings( &screenSettings, CDS_FULLSCREEN );
- if( reso != DISP_CHANGE_SUCCESSFUL ) {
- MessageBox( 0, "Could not initialize fullscreen window.", "Fatal error", MB_OK );
- exit(1); // elvileg jónak kell elennie mindig.
- }
- windowframe = NULL;
- ShowCursor( false );
- } else {
- windowframe = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU ;
- }
- hWnd = CreateWindowEx( NULL, "WINCLASS", MAIN_WINDOW_TITLE,
- WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | windowframe,
- 0, 0, width, height, NULL, NULL, GetModuleHandle( 0 ), NULL );
- if( hWnd == NULL ){
- MessageBox (HWND_DESKTOP, "cannot create window", "Error", MB_OK | MB_ICONEXCLAMATION);
- exit(1);
- }
- hDc = GetDC(hWnd);
- ShowWindow( hWnd, SW_SHOWDEFAULT );
- UpdateWindow( hWnd );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement