// // FUNCTION: InitInstance() // // PURPOSE: creates main window // // COMMENTS: // // In this function, we create and display the main program window. // BOOL InitInstance() { extern bool CommandResolution; if(!IsEmbedded() && !CommandResolution) { ScreenSizeX = 800; ScreenSizeY = 480; } #if defined(ENABLE_SDL) && defined(USE_FULLSCREEN) #if (SDL_MAJOR_VERSION >= 2) SDL_DisplayMode mode = {}; if(SDL_GetCurrentDisplayMode(0, &mode) == 0) { ScreenSizeX = mode.w; ScreenSizeY = mode.h; } else { fprintf(stderr, "SDL_GetCurrentDisplayMode() has failed: %s\n", ::SDL_GetError()); } #else ScreenSizeX = 0; ScreenSizeY = 0; #endif #endif PreloadInitialisation(true); RECT WindowSize; #ifdef __linux__ WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #ifdef WIN32 #ifdef UNDER_CE WindowSize=WindowResize( GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); #else WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #endif if (!goInstallSystem) Poco::Thread::sleep(50); // 091119 #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif if(!MainWindow.Create(WindowSize)) { StartupStore(TEXT(". FAILURE: Create main window%s"),NEWLINE); return FALSE; } const PixelRect rc(MainWindow.GetClientRect()); ScreenSizeX = rc.GetSize().cx; ScreenSizeY = rc.GetSize().cy; InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetLabelText(0,TEXT("MODE")); extern void InitLKFonts(); // reload updating LK fonts after loading profile for fontquality InitLKFonts(); ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts MainWindow.SetVisible(true); return TRUE; }
// // FUNCTION: InitInstance() // // PURPOSE: creates main window // // COMMENTS: // // In this function, we create and display the main program window. // BOOL InitInstance() { extern bool CommandResolution; if(!IsEmbedded() && !CommandResolution) { ScreenSizeX = 800; ScreenSizeY = 480; } #if defined(ENABLE_SDL) && defined(USE_FULLSCREEN) #if (SDL_MAJOR_VERSION >= 2) SDL_DisplayMode mode = {}; if(SDL_GetCurrentDisplayMode(0, &mode) == 0) { ScreenSizeX = mode.w; ScreenSizeY = mode.h; } else { fprintf(stderr, "SDL_GetCurrentDisplayMode() has failed: %s\n", ::SDL_GetError()); } #else ScreenSizeX = 0; ScreenSizeY = 0; #endif #endif PreloadInitialisation(true); RECT WindowSize; #ifdef __linux__ #ifdef USE_VIDEOCORE uint32_t iWidth, iHeight; if(graphics_get_display_size(0, &iWidth, &iHeight) >= 0) { ScreenSizeX=iWidth; ScreenSizeY=iHeight; } #endif #ifdef ANDROID const PixelSize Size = native_view->GetSize(); ScreenSizeX=Size.cx; ScreenSizeY=Size.cy; #endif WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #ifdef WIN32 #if defined(UNDER_CE) || defined(USE_FULLSCREEN) WindowSize=WindowResize( GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); #else WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #endif #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif if(!MainWindow.Create(WindowSize)) { StartupStore(TEXT(". FAILURE: Create main window%s"),NEWLINE); return FALSE; } const PixelRect rc(MainWindow.GetClientRect()); ScreenSizeX = rc.GetSize().cx; ScreenSizeY = rc.GetSize().cy; ScreenHasChanged(); InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts MainWindow.SetVisible(true); return TRUE; }
// // Reinit screen upon resolution/orientation change detected // // Test is possible from VirtualKeys.cpp, activating the customkey at line 229 // In this case, enable a testbench development option. // void ReinitScreen(void) { static int oldSCREENWIDTH=0; static int oldSCREENHEIGHT=0; RECT WindowSize, rc; // This is needed to hide any menu currently on, as first thing. InputEvents::setMode(TEXT("default")); #if TESTBENCH StartupStore(_T("... ChangeScreen suspending Draw Thread\n")); #endif MapWindow::SuspendDrawingThread(); // MapWndProc will get a WM_SIZE // // Detect the current screen geometry // #if (WINDOWSPC>0) // For PC we assume that the desired resolution is in SCREENxx WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = SCREENWIDTH; WindowSize.bottom = SCREENHEIGHT; #else WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = GetSystemMetrics(SM_CXSCREEN); WindowSize.bottom = GetSystemMetrics(SM_CYSCREEN); #endif // // ----------- DEVELOPMENT TESTBENCH OPTIONS ------------- // #if 0 // Force a test resolution, for testing only! // Using always the same resolution will not work when asking for the same resolution again. // dont know why (yet)... WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = 480; WindowSize.bottom = 272; #endif #if 0 // Simulate changin one resolution to another static bool vhflip=true; if (vhflip) { WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = 480; WindowSize.bottom = 272; vhflip=false; } else { WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = 800; WindowSize.bottom = 480; vhflip=true;; } #endif #if 0 // Simulate Portrait<>Landscape flip/flop WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = SCREENHEIGHT; WindowSize.bottom = SCREENWIDTH; #endif // // --------------------------------------------------------- // if (oldSCREENWIDTH!=WindowSize.right || oldSCREENHEIGHT!=WindowSize.bottom) { #if TESTBENCH StartupStore(_T(".... CHANGING RESOLUTION\n")); #endif #if (WINDOWSPC>0) SCREENWIDTH = WindowSize.right; SCREENHEIGHT= WindowSize.bottom; #endif oldSCREENWIDTH = WindowSize.right; oldSCREENHEIGHT= WindowSize.bottom; } else { // THIS DOES NOT STILL WORK! NO EFFECT. #if TESTBENCH StartupStore(_T(".... CHANGE RESOLUTION, SAME SIZE, WM_SIZE FORCED\n")); #endif #if (WINDOWSPC>0) SCREENWIDTH = WindowSize.right; SCREENHEIGHT= WindowSize.bottom; #endif SendMessage(hWndMapWindow, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELPARAM(0,0)); } #if (WINDOWSPC>0) WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.left = (GetSystemMetrics(SM_CXSCREEN) - WindowSize.right) / 2; WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); WindowSize.top = (GetSystemMetrics(SM_CYSCREEN) - WindowSize.bottom) / 2; // We must consider the command bar size on PC window MoveWindow(hWndMainWindow, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, TRUE); MoveWindow(hWndMapWindow, 0, 0, SCREENWIDTH, SCREENHEIGHT, FALSE); // also TRUE? #else // Still to be tested! MoveWindow(hWndMainWindow, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, TRUE); MoveWindow(hWndMapWindow, 0, 0, WindowSize.right, WindowSize.bottom, FALSE); #endif GetClientRect(hWndMainWindow, &rc); #if (WINDOWSPC>0) rc.left = 0; rc.right = SCREENWIDTH; rc.top = 0; rc.bottom = SCREENHEIGHT; #endif InitLKScreen(); LKSW_ReloadProfileBitmaps=true; LKObjects_Delete(); LKObjects_Create(); ButtonLabel::Destroy(); ButtonLabel::CreateButtonLabels(rc); extern void InitialiseFonts(RECT rc); InitialiseFonts(rc); InitLKFonts(); ButtonLabel::SetFont(MapWindowBoldFont); Message::Destroy(); Message::Initialize(rc); // creates window, sets fonts LockTerrainDataGraphics(); CloseTerrainRenderer(); UnlockTerrainDataGraphics(); Reset_Single_DoInits(MDI_DRAWLOOK8000); Reset_Single_DoInits(MDI_DRAWTRI); Reset_Single_DoInits(MDI_DRAWHSI); Reset_Single_DoInits(MDI_DRAWASPNEAREST); Reset_Single_DoInits(MDI_DRAWCOMMON); Reset_Single_DoInits(MDI_DRAWFLARMTRAFFIC); Reset_Single_DoInits(MDI_DRAWINFOPAGE); Reset_Single_DoInits(MDI_WRITEINFO); Reset_Single_DoInits(MDI_DRAWLOOK8000); Reset_Single_DoInits(MDI_DRAWMAPSPACE); Reset_Single_DoInits(MDI_DRAWNEAREST); Reset_Single_DoInits(MDI_DRAWTARGET); Reset_Single_DoInits(MDI_DRAWTHERMALHISTORY); Reset_Single_DoInits(MDI_DRAWTRAFFIC); Reset_Single_DoInits(MDI_DRAWVARIO); Reset_Single_DoInits(MDI_PROCESSVIRTUALKEY); Reset_Single_DoInits(MDI_ONPAINTLISTITEM); Reset_Single_DoInits(MDI_DRAWMAPSCALE); Reset_Single_DoInits(MDI_MAPWPLABELADD); Reset_Single_DoInits(MDI_CHECKLABELBLOCK); Reset_Single_DoInits(MDI_LKPROCESS); Reset_Single_DoInits(MDI_COMPASS); Reset_Single_DoInits(MDI_LOOKABLEND); Reset_Single_DoInits(MDI_MAPWPVECTORS); Reset_Single_DoInits(MDI_MAPASP); Reset_Single_DoInits(MDI_MAPRADAR); // doing nothing reallt Reset_Single_DoInits(MDI_FLARMRADAR); Reset_Single_DoInits(MDI_MAPWNDPROC); Reset_Single_DoInits(MDI_DRAWBOTTOMBAR); Reset_Single_DoInits(MDI_DRAWTASK); #if TESTBENCH StartupStore(_T("... ChangeScreen resuming Draw Thread\n")); #endif MapWindow::ResumeDrawingThread(); ShowWindow(hWndMainWindow, SW_SHOWNORMAL); BringWindowToTop(hWndMainWindow); return; }
// // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name RECT rc; hInst = hInstance; // Store instance handle in our global variable LoadString(hInstance, IDC_LK8000, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); // If it is already running, then focus on the window // problem was that if two instances are started within a few seconds, both will survive! // We enforceed this with mutex at the beginning of WinMain hWndMainWindow = FindWindow(szWindowClass, szTitle); if (hWndMainWindow) { SetForegroundWindow((HWND)((ULONG) hWndMainWindow | 0x00000001)); return 0; } InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? PreloadInitialisation(true); MyRegisterClass(hInst, szWindowClass); RECT WindowSize; WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = GetSystemMetrics(SM_CXSCREEN); WindowSize.bottom = GetSystemMetrics(SM_CYSCREEN); #if (WINDOWSPC>0) WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.left = (GetSystemMetrics(SM_CXSCREEN) - WindowSize.right) / 2; WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); WindowSize.top = (GetSystemMetrics(SM_CYSCREEN) - WindowSize.bottom) / 2; /* // // Custom setup for positioning the window , ready to be used // WindowSize.top=768; // top and left corner coords WindowSize.left=1024; WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); */ #endif if (!goInstallSystem) Sleep(50); // 091119 #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif hWndMainWindow = CreateWindow(szWindowClass, szTitle, WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, NULL, NULL, hInstance, NULL); if (!hWndMainWindow) { return FALSE; } hBrushSelected = (HBRUSH)CreateSolidBrush(ColorSelected); hBrushUnselected = (HBRUSH)CreateSolidBrush(ColorUnselected); hBrushButton = (HBRUSH)CreateSolidBrush(ColorButton); #ifdef LXMINIMAP hBrushButtonHasFocus = (HBRUSH)CreateSolidBrush(ColorButtonHasFocus); #endif GetClientRect(hWndMainWindow, &rc); #if (WINDOWSPC>0) rc.left = 0; rc.right = SCREENWIDTH; rc.top = 0; rc.bottom = SCREENHEIGHT; #endif LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetLabelText(0,TEXT("MODE")); extern void InitialiseFonts(RECT rc); InitialiseFonts(rc); InitLKFonts(); // reload updating LK fonts after loading profile for fontquality ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts ShowWindow(hWndMainWindow, SW_SHOW); #if TESTBENCH StartupStore(TEXT(". Create map window%s"),NEWLINE); #endif hWndMapWindow = CreateWindow(TEXT("MapWindowClass"),NULL, WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, (rc.right - rc.left), (rc.bottom-rc.top) , hWndMainWindow, NULL ,hInstance,NULL); ShowWindow(hWndMainWindow, nCmdShow); UpdateWindow(hWndMainWindow); // Since MapWndProc is doing static inits, we want them to be recalculated at the end of // initializations, since some values in use might have been not available yet, for example BottomSize. Reset_Single_DoInits(MDI_MAPWNDPROC); return TRUE; }