/** * It loads the logo images into memory. * * Read the logo-file input switch, obtaining a list of images and * associated durations and transparencies. Store the image(s), and * times. An image without a stated time or opacity will use the * logo-delay and logo-opacity values. */ static void LogoListLoad( vlc_object_t *p_this, logo_list_t *p_logo_list, const char *psz_filename ) { char *psz_list; /* the list: <logo>[,[<delay>[,[<alpha>]]]][;...] */ char *psz_original; unsigned int i; logo_t *p_logo; /* the parsing's result */ p_logo_list->i_counter = 0; p_logo_list->i_next_pic = 0; psz_original = psz_list = strdup( psz_filename ); if( !psz_list ) abort(); /* Count the number logos == number of ';' + 1 */ p_logo_list->i_count = 1; for( i = 0; i < strlen( psz_list ); i++ ) { if( psz_list[i] == ';' ) p_logo_list->i_count++; } p_logo_list->p_logo = p_logo = calloc( p_logo_list->i_count, sizeof(*p_logo) ); if( !p_logo ) abort(); /* Fill the data */ for( i = 0; i < p_logo_list->i_count; i++ ) { char *p_c = strchr( psz_list, ';' ); char *p_c2 = strchr( psz_list, ',' ); p_logo[i].i_alpha = -1; /* use default settings */ p_logo[i].i_delay = -1; /* use default settings */ if( p_c2 && ( p_c2 < p_c || !p_c ) ) { /* <logo>,<delay>[,<alpha>] type */ if( p_c2[1] != ',' && p_c2[1] != ';' && p_c2[1] != '\0' ) p_logo[i].i_delay = atoi( p_c2+1 ); *p_c2 = '\0'; if( ( p_c2 = strchr( p_c2+1, ',' ) ) && ( p_c2 < p_c || !p_c ) && p_c2[1] != ';' && p_c2[1] != '\0' ) p_logo[i].i_alpha = atoi( p_c2 + 1 ); } else { /* <logo> type */ if( p_c ) *p_c = '\0'; } msg_Dbg( p_this, "logo file name %s, delay %d, alpha %d", psz_list, p_logo[i].i_delay, p_logo[i].i_alpha ); p_logo[i].p_pic = LoadImage( p_this, psz_list ); if( !p_logo[i].p_pic ) { msg_Warn( p_this, "error while loading logo %s, will be skipped", psz_list ); } if( p_c ) psz_list = &p_c[1]; } /* initialize so that on the first update it will wrap back to 0 */ p_logo_list->i_counter = p_logo_list->i_count - 1; free( psz_original ); }
StairSpiked::StairSpiked(int pos_y, QWidget *parent) : Stair(pos_y, 100, parent) { LoadImage(); nLifeChangeValue = -50; }
FORCE_INLINE int NSISCALL ui_doinstall(void) { header *header = g_header; static WNDCLASS wc; // richedit subclassing and bgbg creation // detect default language // more information at: // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_0xrn.asp LANGID (WINAPI *GUDUIL)(); GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage); if (GUDUIL) { // Windows ME/2000+ myitoa(state_language, GUDUIL()); } else { static const char reg_9x_locale[] = "Control Panel\\Desktop\\ResourceLocale"; static const char reg_nt_locale_key[] = ".DEFAULT\\Control Panel\\International"; const char *reg_nt_locale_val = ®_9x_locale[30]; // = "Locale" with opt *(DWORD*)state_language = CHAR4_TO_DWORD('0', 'x', 0, 0); { // Windows 9x myRegGetStr(HKEY_CURRENT_USER, reg_9x_locale, NULL, g_tmp, 0); } if (!g_tmp[0]) { // Windows NT // This key exists on 9x as well, so it's only read if ResourceLocale wasn't found myRegGetStr(HKEY_USERS, reg_nt_locale_key, reg_nt_locale_val, g_tmp, 0); } mystrcat(state_language, g_tmp); } // set default language set_language(); // initialize auto close flag g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE; #ifdef NSIS_CONFIG_PLUGIN_SUPPORT // initialize plugin api g_exec_flags.plugin_api_version=NSISPIAPIVER_CURR; #endif // read install directory from registry if (!is_valid_instpath(state_install_directory)) { if (header->install_reg_key_ptr) { myRegGetStr( (HKEY)header->install_reg_rootkey, GetNSISStringNP(header->install_reg_key_ptr), GetNSISStringNP(header->install_reg_value_ptr), ps_tmpbuf, 0 ); if (ps_tmpbuf[0]) { char *p=ps_tmpbuf; char *e; if (p[0]=='\"') { char *p2; p++; p2 = findchar(p, '"'); *p2 = 0; } // p is the path now, check for .exe extension e=p+mystrlen(p)-4; if (e > p) { // if filename ends in .exe, and is not a directory, remove the filename if (!lstrcmpi(e, ".exe")) // check extension { DWORD d; d=GetFileAttributes(p); if (d == INVALID_FILE_ATTRIBUTES || !(d&FILE_ATTRIBUTE_DIRECTORY)) { // if there is no back-slash, the string will become empty, but that's ok because // it would make an invalid instdir anyway trimslashtoend(p); } } } mystrcpy(state_install_directory,addtrailingslash(p)); } } } if (!is_valid_instpath(state_install_directory)) { GetNSISString(state_install_directory,header->install_directory_ptr); } #ifdef NSIS_CONFIG_LOG if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller) { #if !defined(NSIS_CONFIG_LOG_ODS) && !defined(NSIS_CONFIG_LOG_STDOUT) build_g_logfile(); #endif log_dolog=1; } #endif #ifdef NSIS_CONFIG_VISIBLE_SUPPORT g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED); #ifdef NSIS_SUPPORT_BGBG if (header->bg_color1 != -1) { DWORD cn = CHAR4_TO_DWORD('_', 'N', 'b', 0); RECT vp; extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM); wc.lpfnWndProc = BG_WndProc; wc.hInstance = g_hInstance; wc.hIcon = g_hIcon; //wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.lpszClassName = (LPCSTR)&cn; if (!RegisterClass(&wc)) return 0; SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,(LPCSTR)&cn,0,WS_POPUP, vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL); } #endif//NSIS_SUPPORT_BGBG #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_SUPPORT_CODECALLBACKS // Select language if (ExecuteCallbackFunction(CB_ONINIT)) return 2; set_language(); #endif #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT if (!g_exec_flags.silent) #endif//NSIS_CONFIG_SILENT_SUPPORT { #ifdef NSIS_SUPPORT_BGBG ShowWindow(m_bgwnd, SW_SHOW); #endif//NSIS_SUPPORT_BGBG #ifdef NSIS_CONFIG_LICENSEPAGE { // load richedit DLL static const char riched20[]="RichEd20"; static const char riched32[]="RichEd32"; static const char richedit20a[]="RichEdit20A"; static const char richedit[]="RichEdit"; if (!LoadLibrary(riched20)) { LoadLibrary(riched32); } // make richedit20a point to RICHEDIT if (!GetClassInfo(NULL,richedit20a,&wc)) { GetClassInfo(NULL,richedit,&wc); wc.lpszClassName = richedit20a; RegisterClass(&wc); } } #endif { int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc); #if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) ExecuteCallbackFunction(CB_ONGUIEND); #endif #ifdef NSIS_CONFIG_PLUGIN_SUPPORT Plugins_SendMsgToAllPlugins(NSPIM_GUIUNLOAD); #endif return ret; } } #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT else #endif//NSIS_CONFIG_VISIBLE_SUPPORT { if (install_thread(NULL)) { #ifdef NSIS_SUPPORT_CODECALLBACKS if (!g_quit_flag) ExecuteCallbackFunction(CB_ONINSTFAILED); #endif//NSIS_SUPPORT_CODECALLBACKS return 2; } #ifdef NSIS_SUPPORT_CODECALLBACKS ExecuteCallbackFunction(CB_ONINSTSUCCESS); #endif//NSIS_SUPPORT_CODECALLBACKS return 0; } #endif//NSIS_CONFIG_SILENT_SUPPORT }
// ウィンドウプロシージャ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { int id, rcw = 80, rch = 40, mousex, mousey; static int catw, cath; static HDC hdc_mem, hdc_cat; HBITMAP hBmp; static HBITMAP hCat; HDC hdc; static RECT rc1, rc2; PAINTSTRUCT ps; static BOOL bDrag, bDragCat; static POINT ptStart; BITMAP bmp_info; switch (msg) { case WM_CREATE: MyAdjustWindow(hWnd, 600, 400); hdc_mem = CreateCompatibleDC(NULL); hdc = GetDC(hWnd); hBmp = CreateCompatibleBitmap(hdc, 600, 400); SelectObject(hdc_mem, hBmp); PatBlt(hdc_mem, 0, 0, 600, 400, WHITENESS); rc1.left = 10; rc1.top = 10; rc1.right = rc1.left + rcw; rc1.bottom = rc1.top + rch; Rectangle(hdc_mem, rc1.left, rc1.top, rc1.right, rc1.bottom); // ビットマップを読み込み、メモリデバイスコンテキストに転送する hCat = (HBITMAP)LoadImage(hInst, TEXT("MYBMP"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); GetObject(hCat, (int)sizeof(bmp_info), &bmp_info); catw = bmp_info.bmWidth; cath = bmp_info.bmHeight; hdc_cat = CreateCompatibleDC(NULL); SelectObject(hdc_cat, hCat); rc2.left = 100; rc2.top = 100; rc2.right = rc2.left + catw; rc2.bottom = rc2.top + cath; BitBlt(hdc_mem, rc2.left, rc2.top, catw, cath, hdc_cat, 0, 0, SRCCOPY); DeleteObject(hBmp); ReleaseDC(hWnd, hdc); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); BitBlt(hdc, 0, 0, 600, 400, hdc_mem, 0, 0, SRCCOPY); EndPaint(hWnd, &ps); break; case WM_LBUTTONDOWN: mousex = LOWORD(lp); // マウス位置のx座標 mousey = HIWORD(lp); // マウス位置のy座標 // マウスの位置が、長方形の内部にある場合 if (mousex > rc1.left && mousex < rc1.right && mousey > rc1.top && mousey < rc1.bottom) { bDrag = TRUE; } // マウスの位置が、ビットマップの内部にある場合 if (mousex > rc2.left && mousex < rc2.right && mousey > rc2.top && mousey < rc2.bottom) { bDragCat = TRUE; } // 長方形とビットマップのどちらもドラッグされていない場合 if (!bDrag && !bDragCat) return DefWindowProc(hWnd, msg, wp, lp); ptStart.x = mousex; ptStart.y = mousey; SetCapture(hWnd); // キャプチャ開始 break; case WM_MOUSEMOVE: if (!bDrag && !bDragCat) return DefWindowProc(hWnd, msg, wp, lp); mousex = LOWORD(lp); // マウス位置のx座標 mousey = HIWORD(lp); // マウス位置のy座標 if (bDrag) { // 長方形がドラッグ中の場合 rc1.left += mousex - ptStart.x; rc1.top += mousey - ptStart.y; rc1.right = rc1.left + rcw; rc1.bottom = rc1.top + rch; } if (bDragCat) { // ビットマップがドラッグ中の場合 rc2.left += mousex - ptStart.x; rc2.top += mousey - ptStart.y; rc2.right = rc2.left + catw; rc2.bottom = rc2.top + cath; } PatBlt(hdc_mem, 0, 0, 600, 400, WHITENESS); Rectangle(hdc_mem, rc1.left, rc1.top, rc1.right, rc1.bottom); BitBlt(hdc_mem, rc2.left, rc2.top, catw, cath, hdc_cat, 0, 0, SRCCOPY); InvalidateRect(hWnd, NULL, FALSE); ptStart.x = mousex; ptStart.y = mousey; break; case WM_LBUTTONUP: if (!bDrag && !bDragCat) return DefWindowProc(hWnd, msg, wp, lp); ReleaseCapture(); // キャプチャ終了 if (bDrag) bDrag = FALSE; if (bDragCat) bDragCat = FALSE; break; case WM_CLOSE: id = MessageBox(hWnd, TEXT("終了してもよろしいですか"), TEXT("確認"), MB_YESNO | MB_ICONQUESTION); if (id == IDYES) DestroyWindow(hWnd); break; case WM_DESTROY: if (bDrag || bDragCat) // ドラッグ中なら ReleaseCapture(); // キャプチャ終了 DeleteObject(hCat); DeleteDC(hdc_mem); DeleteDC(hdc_cat); PostQuitMessage(0); break; default: return (DefWindowProc(hWnd, msg, wp, lp)); } return 0; }
Bool winCreateBoundingWindowFullScreen (ScreenPtr pScreen) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; int iWidth = pScreenInfo->dwWidth; int iHeight = pScreenInfo->dwHeight; HWND *phwnd = &pScreenPriv->hwndScreen; WNDCLASS wc; int xOrg = pScreenInfo->dwInitialX; int yOrg = pScreenInfo->dwInitialY; #ifdef NXWIN_LOGO HANDLE nxIcon; nxIcon = LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 16, 16, /* GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), */ 0 ); if(nxIcon == NULL) { ErrorF ("cannot load icon\n"); } #endif #if CYGDEBUG ErrorF ("winCreateBoundingWindowFullScreen\n"); #endif ErrorF ("winCreateBoundingWindowFullscreen - User w: %d h: %d\n", pScreenInfo->dwUserWidth, pScreenInfo->dwUserHeight); ErrorF ("winCreateBoundingWindowFullscreen - Current w: %d h: %d\n", pScreenInfo->dwWidth, pScreenInfo->dwHeight); /* Setup our window class */ wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = winWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInstance; #ifdef NXWIN_LOGO wc.hIcon = nxIcon; #else wc.hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)); #endif wc.hCursor = 0; wc.hbrBackground = 0; wc.lpszMenuName = NULL; wc.lpszClassName = WINDOW_CLASS; RegisterClass (&wc); /* Create the window */ /* Store current Focus */ *phwnd = CreateWindowExA (0, /* Extended styles */ WINDOW_CLASS, /* Class name */ WINDOW_TITLE, /* Window name */ (WS_POPUPWINDOW & ~WS_BORDER) #ifdef NXWIN_ICONIC | (nxwinIconicMode?WS_ICONIC:0) #endif , xOrg, /* Horizontal position */ yOrg, /* Vertical position */ iWidth, /* Right edge */ iHeight, /* Bottom edge */ (HWND) NULL, /* No parent or owner window */ (HMENU) NULL, /* No menu */ GetModuleHandle (NULL),/* Instance handle */ pScreenPriv); /* ScreenPrivates */ /* Branch on the server engine */ switch (pScreenInfo->dwEngine) { case WIN_SERVER_SHADOW_GDI: /* Show the window */ ShowWindow (*phwnd, nxwinHideStart?SW_HIDE:SW_SHOWMAXIMIZED); break; default: /* Hide the window */ ShowWindow (*phwnd, nxwinHideStart?SW_HIDE:SW_SHOWNORMAL); break; } /* Send first paint message */ UpdateWindow (*phwnd); SetWindowText(*phwnd, nxwinWinName); /* Attempt to bring our window to the top of the display */ if( !nxwinHideStart ) BringWindowToTop (*phwnd); return TRUE; }
// Main window program int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow) { HWND hwnd = NULL; MSG msg = {0}; WNDCLASSEX wndclassex = {0}; // Init fields we care about wndclassex.cbSize = sizeof(WNDCLASSEX); // Always set to size of WNDCLASSEX wndclassex.style = CS_HREDRAW | CS_VREDRAW; wndclassex.lpfnWndProc = WinProc; wndclassex.hInstance = hinstance; wndclassex.lpszClassName = kClassName; wndclassex.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_SHARED); RegisterClassEx(&wndclassex); // Register the WNDCLASSEX RECT rect = { 0, 0, kWinWid, kWinHgt }; // Desired window client rect DWORD winStyleEx = WS_EX_CLIENTEDGE; DWORD winStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; // Adjust window rect so it gives us our desired client rect when we // create the window AdjustWindowRectEx(&rect, winStyle, false, winStyleEx); // Create the window hwnd = CreateWindowEx(winStyleEx, // Window extended style kClassName, "www.GameTutorials.com -- D3D Fog", winStyle, // Window style CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, hinstance, NULL); // Init our global 3D object if(g3D->init(hwnd) == false) return EXIT_FAILURE; // There's been an error, lets get out of this joint // Get the client rect and make sure our client is the size we want GetClientRect(hwnd, &rect); assert(rect.right == kWinWid && rect.bottom == kWinHgt); // We set up our projection matrix once because it will never change g3D->setProjMatrix(DEG2RAD(60), (float)rect.right / (float)rect.bottom, 1.0f, 8192.0f); // If we can initialize the fog, exit the application if(!InitFog()) return EXIT_FAILURE; ShowCursor(FALSE); // Hide cursor ShowWindow(hwnd, ishow); UpdateWindow(hwnd); // Slam the cursor to the middle of the screen SetCursorPos(GetSystemMetrics(SM_CXSCREEN) >> 1, GetSystemMetrics(SM_CYSCREEN) >> 1); // While the app is running... while(1) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Handle messages from the OS { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else if(LockFrameRate()) // Otherwise if it's time to draw { static float angle = 0; // Angle of rotation D3DXMATRIX wMat; // World matrix CameraMouseInput(); // Move camera via the mouse // Set the world view to the current camera view g3D->setViewMatrix(gCamera); g3D->begin(); // Begin drawing g3D->clear(kFogColor); // Clear the screen to the fog color // Rotate around the Y-axis g3D->setWorldMatrix(D3DXMatrixRotationY(&wMat, DEG2RAD(++angle))); // Draw 4 cubes DrawCube(CPos(2,0,0), 0.5f, D3DCOLOR_ARGB(255, 255, 0, 0)); DrawCube(CPos(-2,0,0), 0.5f, D3DCOLOR_ARGB(255, 255, 0, 0)); DrawCube(CPos(0,0,2), 0.5f, D3DCOLOR_ARGB(255, 255, 0, 0)); DrawCube(CPos(0,0,-2), 0.5f, D3DCOLOR_ARGB(255, 255, 0, 0)); // Draw the grid g3D->setWorldMatrix(D3DXMatrixIdentity(&wMat)); DrawGrid(CPos(0,-2,0), 32, D3DCOLOR_ARGB(255, 0, 200, 0)); g3D->end(); // Finish drawing } else Sleep(1); // Give the OS a tiny bit of time to process other things } // end of while(1) ShowCursor(TRUE); // Reshow cursor g3D->deinit(); // Free up CD3DObj UnregisterClass(kClassName,hinstance); // Free up WNDCLASSEX return EXIT_SUCCESS; // Application was a success }
int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR cmdLine, int nCmdShow) { CArch arch(instance); CLOG; CArgs args; s_instance = instance; // if "/uninstall" is on the command line then just stop and // uninstall the service and quit. this is the only option // but we ignore any others. if (CString(cmdLine).find("/uninstall") != CString::npos) { CAutoStart::uninstallDaemons(false); CAutoStart::uninstallDaemons(true); return 0; } // register main window (dialog) class WNDCLASSEX classInfo; classInfo.cbSize = sizeof(classInfo); classInfo.style = CS_HREDRAW | CS_VREDRAW; classInfo.lpfnWndProc = &mainWndProc; classInfo.cbClsExtra = 0; classInfo.cbWndExtra = DLGWINDOWEXTRA; classInfo.hInstance = instance; classInfo.hIcon = (HICON)LoadImage(instance, MAKEINTRESOURCE(IDI_SYNERGY), IMAGE_ICON, 32, 32, LR_SHARED); classInfo.hCursor = LoadCursor(NULL, IDC_ARROW); classInfo.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1); classInfo.lpszMenuName = NULL; classInfo.lpszClassName = s_mainClass; classInfo.hIconSm = (HICON)LoadImage(instance, MAKEINTRESOURCE(IDI_SYNERGY), IMAGE_ICON, 16, 16, LR_SHARED); RegisterClassEx(&classInfo); // create main window HWND mainWindow = CreateDialog(s_instance, MAKEINTRESOURCE(IDD_MAIN), 0, NULL); // prep windows initMainWindow(mainWindow); s_globalOptions = new CGlobalOptions(mainWindow, &ARG->m_config); s_advancedOptions = new CAdvancedOptions(mainWindow, &ARG->m_config); s_hotkeyOptions = new CHotkeyOptions(mainWindow, &ARG->m_config); s_screensLinks = new CScreensLinks(mainWindow, &ARG->m_config); s_info = new CInfo(mainWindow); // show window ShowWindow(mainWindow, nCmdShow); // main loop MSG msg; bool done = false; do { switch (GetMessage(&msg, NULL, 0, 0)) { case -1: // error break; case 0: // quit done = true; break; default: if (!IsDialogMessage(mainWindow, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } break; } } while (!done); return (int)msg.wParam; }
int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze"); // Define the camera to look into our 3d world Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM) Mesh mesh = GenMeshCubicmap(imMap, (Vector3){ 1.0f, 1.0f, 1.0f }); Model model = LoadModelFromMesh(mesh); // NOTE: By default each cube is mapped to one part of texture atlas Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture // Get map image data to be used for collision detection Color *mapPixels = GetImageData(imMap); UnloadImage(imMap); // Unload image from RAM Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position Vector3 playerPosition = camera.position; // Set player position SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set camera mode SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- Vector3 oldCamPos = camera.position; // Store old camera position UpdateCamera(&camera); // Update camera // Check player collision (we simplify to 2D collision detection) Vector2 playerPos = { camera.position.x, camera.position.z }; float playerRadius = 0.1f; // Collision radius (player is modelled as a cilinder for collision) int playerCellX = (int)(playerPos.x - mapPosition.x + 0.5f); int playerCellY = (int)(playerPos.y - mapPosition.z + 0.5f); // Out-of-limits security check if (playerCellX < 0) playerCellX = 0; else if (playerCellX >= cubicmap.width) playerCellX = cubicmap.width - 1; if (playerCellY < 0) playerCellY = 0; else if (playerCellY >= cubicmap.height) playerCellY = cubicmap.height - 1; // Check map collisions using image data and player position // TODO: Improvement: Just check player surrounding cells for collision for (int y = 0; y < cubicmap.height; y++) { for (int x = 0; x < cubicmap.width; x++) { if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel (CheckCollisionCircleRec(playerPos, playerRadius, (Rectangle){ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f }))) { // Collision detected, reset camera position camera.position = oldCamPos; } } } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); BeginMode3D(camera); DrawModel(model, mapPosition, 1.0f, WHITE); // Draw maze map //DrawCubeV(playerPosition, (Vector3){ 0.2f, 0.4f, 0.2f }, RED); // Draw player EndMode3D(); DrawTextureEx(cubicmap, (Vector2){ GetScreenWidth() - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); DrawRectangleLines(GetScreenWidth() - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); // Draw player position radar DrawRectangle(GetScreenWidth() - cubicmap.width*4 - 20 + playerCellX*4, 20 + playerCellY*4, 4, 4, RED); DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- free(mapPixels); // Unload color array UnloadTexture(cubicmap); // Unload cubicmap texture UnloadTexture(texture); // Unload map texture UnloadModel(model); // Unload map model CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
BOOL CFileDiffDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); CString temp; CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); this->m_ctrRev1Edit.Init(); this->m_ctrRev2Edit.Init(); m_tooltips.Create(this); m_tooltips.AddTool(IDC_SWITCHLEFTRIGHT, IDS_FILEDIFF_SWITCHLEFTRIGHT_TT); m_cFileList.SetRedraw(false); m_cFileList.DeleteAllItems(); DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP; m_cFileList.SetExtendedStyle(exStyle); m_nIconFolder = SYS_IMAGE_LIST().GetDirIconIndex(); m_cFileList.SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL); m_SwitchButton.SetImage((HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SWITCHLEFTRIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR)); m_SwitchButton.Invalidate(); m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED); m_cFilter.SetInfoIcon(IDI_FILTEREDIT); temp.LoadString(IDS_FILEDIFF_FILTERCUE); temp = _T(" ")+temp; m_cFilter.SetCueBanner(temp); if (!m_sFilter.IsEmpty()) m_cFilter.SetWindowText(m_sFilter); int c = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1; while (c>=0) m_cFileList.DeleteColumn(c--); temp.LoadString(IDS_FILEDIFF_FILE); m_cFileList.InsertColumn(0, temp); temp.LoadString(IDS_FILEDIFF_EXT); m_cFileList.InsertColumn(1, temp); temp.LoadString(IDS_FILEDIFF_ACTION); m_cFileList.InsertColumn(2, temp); temp.LoadString(IDS_FILEDIFF_STATADD); m_cFileList.InsertColumn(3, temp); temp.LoadString(IDS_FILEDIFF_STATDEL); m_cFileList.InsertColumn(4, temp); int mincol = 0; int maxcol = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1; int col; for (col = mincol; col <= maxcol; col++) { m_cFileList.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER); } m_cFileList.SetRedraw(true); AddAnchor(IDC_DIFFSTATIC1, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_SWITCHLEFTRIGHT, TOP_RIGHT); AddAnchor(IDC_FIRSTURL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_REV1BTN, TOP_RIGHT); //AddAnchor(IDC_DIFFSTATIC2, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_SECONDURL, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_REV2BTN, TOP_RIGHT); AddAnchor(IDC_FILTER, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_FILELIST, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_REV1GROUP,TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_REV2GROUP,TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_REV1EDIT,TOP_LEFT); AddAnchor(IDC_REV2EDIT,TOP_LEFT); EnableSaveRestore(_T("FileDiffDlg")); if(this->m_strRev1.IsEmpty()) this->m_ctrRev1Edit.SetWindowText(this->m_rev1.m_CommitHash.ToString()); else { if(m_rev1.GetCommit(this->m_strRev1)) { CString msg; msg.Format(IDS_PROC_REFINVALID, this->m_strRev1); this->m_FileListText += msg; } this->m_ctrRev1Edit.SetWindowText(m_strRev1); } if(this->m_strRev2.IsEmpty()) this->m_ctrRev2Edit.SetWindowText(this->m_rev2.m_CommitHash.ToString()); else { if(m_rev2.GetCommit(this->m_strRev2)) { CString msg; msg.Format(IDS_PROC_REFINVALID, this->m_strRev2); this->m_FileListText += msg; } this->m_ctrRev2Edit.SetWindowText(m_strRev2); } SetURLLabels(); InterlockedExchange(&m_bThreadRunning, TRUE); if (AfxBeginThread(DiffThreadEntry, this)==NULL) { InterlockedExchange(&m_bThreadRunning, FALSE); CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); } InterlockedExchange(&m_bLoadingRef, TRUE); if (AfxBeginThread(LoadRefThreadEntry, this)==NULL) { InterlockedExchange(&m_bLoadingRef, FALSE); CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); } this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE))); this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG))); this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG))); this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE))); this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG))); this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG))); // Start with focus on file list GetDlgItem(IDC_FILELIST)->SetFocus(); if(m_rev2.m_CommitHash.IsEmpty()) m_SwitchButton.EnableWindow(FALSE); KillTimer(IDT_INPUT); return FALSE; }
/* dll exported functions */ LIBNOTIFY_API BOOL notify_init(const char *app_name) { DWORD thread_ret_code = 0; HANDLE wait_handles[2] = {NULL}; UNREFERENCED_PARAMETER(app_name); // forbid multiple calls, by checking if the event is already created HANDLE evtHandle = OpenEvent(EVENT_MODIFY_STATE, FALSE, wstrLibInitEvent); if(evtHandle) { CloseHandle(evtHandle); evtHandle = NULL; return FALSE; // currently only one app. can use the library } else // library already initialized { event_lib_inited = CreateEvent(NULL, TRUE, FALSE, wstrLibInitEvent); if(!event_lib_inited) goto cleanup_and_exit; InitializeCriticalSection(&thread_guard); } font_summary = CreateFont(0, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_ROMAN, NULL); if(!font_summary) goto cleanup_and_exit; font_body = CreateFont(0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_ROMAN, NULL); if(!font_body) goto cleanup_and_exit; // these needn't be released, since they're OS level shared resources notification_icons[0] = LoadImage(NULL, MAKEINTRESOURCE(OIC_NOTE), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); notification_icons[1] = LoadImage(NULL, MAKEINTRESOURCE(OIC_BANG), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); if(!notification_icons[0] || !notification_icons[1]) goto cleanup_and_exit; // set globals which are set only once and read then on multiple times /* screen width / 3.5 is the maximum allowed notification width */ notification_window_width_max = (GetSystemMetrics(SM_CXSCREEN) * 2) / 7; icon_size = (uint16_t) GetSystemMetrics(SM_CXICON); icon_padding = icon_size / 3; /* icon spacing is a third of the icon width */ notification_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) ¬ification_daemon_main, event_lib_inited, 0, ¬ification_thread_id); if(!notification_thread) goto cleanup_and_exit; // block and confirm all things are right and then return success wait_handles[0] = event_lib_inited, wait_handles[1] = notification_thread; if((WAIT_OBJECT_0 + G_N_ELEMENTS(wait_handles)) > WaitForMultipleObjects(G_N_ELEMENTS(wait_handles), wait_handles, FALSE, thread_wait_timeout)) { if(GetExitCodeThread(notification_thread, &thread_ret_code)) { if(STILL_ACTIVE == thread_ret_code) { return TRUE; } } } /* order is similar to stack unwind in C++ */ cleanup_and_exit: if(notification_thread) { /* terminate and free the thread */ TerminateThread(notification_thread, (DWORD) -1); CloseHandle(notification_thread); notification_thread = NULL; } if(font_body) { DeleteObject(font_body); font_body = NULL; } if(font_summary) { DeleteObject(font_summary); font_summary = NULL; } if(event_lib_inited) { DeleteCriticalSection(&thread_guard); CloseHandle(event_lib_inited); event_lib_inited = NULL; } return FALSE; }
//---------------------------------------------------------------------------------- // Main entry point //---------------------------------------------------------------------------------- int main(void) { // Initialization //--------------------------------------------------------- InitWindow(screenWidth, screenHeight, "GGJ16 - LIGHT MY RITUAL!"); // Global data loading (assets that must be available in all screens, i.e. fonts) InitAudioDevice(); Image image = LoadImage("resources/lights_map.png"); // Load image in CPU memory (RAM) lightsMap = GetImageData(image); // Get image pixels data as an array of Color lightsMapWidth = image.width; lightsMapHeight = image.height; UnloadImage(image); // Unload image from CPU memory (RAM) font = LoadSpriteFont("resources/font_arcadian.png"); //doors = LoadTexture("resources/textures/doors.png"); //sndDoor = LoadSound("resources/audio/door.ogg"); music = LoadMusicStream("resources/audio/ambient.ogg"); PlayMusicStream(music); SetMusicVolume(music, 1.0f); // Setup and Init first screen currentScreen = LOGO_RL; //InitTitleScreen(); //InitGameplayScreen(); rlInitLogoScreen(); #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { UpdateDrawFrame(); } #endif // De-Initialization //-------------------------------------------------------------------------------------- switch (currentScreen) { case LOGO_RL: rlUnloadLogoScreen(); break; case TITLE: UnloadTitleScreen(); break; case GAMEPLAY: UnloadGameplayScreen(); break; default: break; } // Unload all global loaded data (i.e. fonts) here! UnloadSpriteFont(font); //UnloadSound(sndDoor); UnloadMusicStream(music); free(lightsMap); CloseAudioDevice(); CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (message) { case WM_CBLBUTTONCLICKED: switch(wParam) {// begin wParam case 1: DisplayStatus("AM Productions Caption pressed - Going to http://am-productions.yi.org/"); ShellExecute(NULL,"open","http://am-productions.yi.org/",NULL,NULL,SW_SHOWNORMAL); break; case 2: cbExtra.New(8, (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_BITMAP5),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS|LR_DEFAULTCOLOR), (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_BITMAP6),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS|LR_DEFAULTCOLOR), "Caption 8",1); DisplayStatus("Caption 2 pressed - Created Caption 8 and inserted it at index 1"); break; case 3: cbExtra.Delete(3); DisplayStatus("Caption 3 pressed - Deleted Caption 3"); break; case 4: DisplayStatus("Caption 4 pressed"); break; case 7: DisplayStatus("Caption 7 pressed"); break; case 8: cbExtra.Replace(8,7, (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_BITMAP5),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS|LR_DEFAULTCOLOR), (HBITMAP)LoadImage(hInst,MAKEINTRESOURCE(IDB_BITMAP6),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS|LR_DEFAULTCOLOR), "Caption 7"); DisplayStatus("Caption 8 pressed - Replaced Caption 8 with Caption 7"); break; }// end wParam break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// Load a BMFont file (AngelCode font file) static SpriteFont LoadBMFont(const char *fileName) { #define MAX_BUFFER_SIZE 256 SpriteFont font = { 0 }; font.texture.id = 0; char buffer[MAX_BUFFER_SIZE]; char *searchPoint = NULL; int fontSize = 0; int texWidth, texHeight; char texFileName[128]; int numChars = 0; int base; // Useless data FILE *fntFile; fntFile = fopen(fileName, "rt"); if (fntFile == NULL) { TraceLog(WARNING, "[%s] FNT file could not be opened", fileName); return font; } // NOTE: We skip first line, it contains no useful information fgets(buffer, MAX_BUFFER_SIZE, fntFile); //searchPoint = strstr(buffer, "size"); //sscanf(searchPoint, "size=%i", &fontSize); fgets(buffer, MAX_BUFFER_SIZE, fntFile); searchPoint = strstr(buffer, "lineHeight"); sscanf(searchPoint, "lineHeight=%i base=%i scaleW=%i scaleH=%i", &fontSize, &base, &texWidth, &texHeight); TraceLog(DEBUG, "[%s] Font size: %i", fileName, fontSize); TraceLog(DEBUG, "[%s] Font texture scale: %ix%i", fileName, texWidth, texHeight); fgets(buffer, MAX_BUFFER_SIZE, fntFile); searchPoint = strstr(buffer, "file"); sscanf(searchPoint, "file=\"%128[^\"]\"", texFileName); TraceLog(DEBUG, "[%s] Font texture filename: %s", fileName, texFileName); fgets(buffer, MAX_BUFFER_SIZE, fntFile); searchPoint = strstr(buffer, "count"); sscanf(searchPoint, "count=%i", &numChars); TraceLog(DEBUG, "[%s] Font num chars: %i", fileName, numChars); // Compose correct path using route of .fnt file (fileName) and texFileName char *texPath = NULL; char *lastSlash = NULL; lastSlash = strrchr(fileName, '/'); // NOTE: We need some extra space to avoid memory corruption on next allocations! texPath = malloc(strlen(fileName) - strlen(lastSlash) + strlen(texFileName) + 4); // NOTE: strcat() and strncat() required a '\0' terminated string to work! *texPath = '\0'; strncat(texPath, fileName, strlen(fileName) - strlen(lastSlash) + 1); strncat(texPath, texFileName, strlen(texFileName)); TraceLog(DEBUG, "[%s] Font texture loading path: %s", fileName, texPath); Image imFont = LoadImage(texPath); if (imFont.format == UNCOMPRESSED_GRAYSCALE) { Image imCopy = ImageCopy(imFont); for (int i = 0; i < imCopy.width*imCopy.height; i++) ((unsigned char *)imCopy.data)[i] = 0xff; // WHITE pixel ImageAlphaMask(&imCopy, imFont); font.texture = LoadTextureFromImage(imCopy); UnloadImage(imCopy); } else font.texture = LoadTextureFromImage(imFont); font.size = fontSize; font.numChars = numChars; font.charValues = (int *)malloc(numChars*sizeof(int)); font.charRecs = (Rectangle *)malloc(numChars*sizeof(Rectangle)); font.charOffsets = (Vector2 *)malloc(numChars*sizeof(Vector2)); font.charAdvanceX = (int *)malloc(numChars*sizeof(int)); UnloadImage(imFont); free(texPath); int charId, charX, charY, charWidth, charHeight, charOffsetX, charOffsetY, charAdvanceX; for (int i = 0; i < numChars; i++) { fgets(buffer, MAX_BUFFER_SIZE, fntFile); sscanf(buffer, "char id=%i x=%i y=%i width=%i height=%i xoffset=%i yoffset=%i xadvance=%i", &charId, &charX, &charY, &charWidth, &charHeight, &charOffsetX, &charOffsetY, &charAdvanceX); // Save data properly in sprite font font.charValues[i] = charId; font.charRecs[i] = (Rectangle){ charX, charY, charWidth, charHeight }; font.charOffsets[i] = (Vector2){ (float)charOffsetX, (float)charOffsetY }; font.charAdvanceX[i] = charAdvanceX; } fclose(fntFile); if (font.texture.id == 0) { UnloadSpriteFont(font); font = GetDefaultFont(); } else TraceLog(INFO, "[%s] SpriteFont loaded successfully", fileName); return font; }
// front end static HICON LoadIconEx( int id ) { return LoadImage( hInst, MAKEINTRESOURCE(id), IMAGE_ICON, ICON_SIZE, ICON_SIZE, 0 ); }
//options page on miranda called INT_PTR CALLBACK DlgProcConnectionNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndList; switch (msg) { case WM_INITDIALOG://initialize dialog, so set properties from db. { LVCOLUMN lvc = { 0 }; LVITEM lvI = { 0 }; TCHAR buff[256]; bOptionsOpen = TRUE; TranslateDialogDefault(hwndDlg);//translate miranda function #ifdef _WIN64 mir_sntprintf(buff,_countof(buff),_T("%d.%d.%d.%d/64"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version))); #else mir_sntprintf(buff, _T("%d.%d.%d.%d/32"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version))); #endif SetDlgItemText(hwndDlg, IDC_VERSION, buff); LoadSettings(); //connExceptionsTmp=LoadSettingsConnections(); SetDlgItemInt(hwndDlg, IDC_INTERVAL, settingInterval, FALSE); SetDlgItemInt(hwndDlg, IDC_INTERVAL1, settingInterval1, TRUE); CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_RESOLVEIP, settingResolveIp ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, ID_CHK_DEFAULTACTION, settingDefaultAction ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor); SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor); if (!settingSetColours) { HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR); CheckDlgButton(hwndDlg, IDC_SETCOLOURS, BST_UNCHECKED); EnableWindow(hwnd, FALSE); hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR); EnableWindow(hwnd, FALSE); } SendDlgItemMessage(hwndDlg, ID_ADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON6), IMAGE_ICON, 16, 16, 0)); SendDlgItemMessage(hwndDlg, ID_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, 0)); SendDlgItemMessage(hwndDlg, ID_DOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON4), IMAGE_ICON, 16, 16, 0)); SendDlgItemMessage(hwndDlg, ID_UP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON5), IMAGE_ICON, 16, 16, 0)); // initialise and fill listbox hwndList = GetDlgItem(hwndDlg, IDC_STATUS); ListView_DeleteAllItems(hwndList); SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); // Initialize the LVCOLUMN structure. // The mask specifies that the format, width, text, and // subitem members of the structure are valid. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.iSubItem = 0; lvc.pszText = TranslateT("Status"); lvc.cx = 120; // width of column in pixels ListView_InsertColumn(hwndList, 0, &lvc); // Some code to create the list-view control. // Initialize LVITEM members that are common to all // items. lvI.mask = LVIF_TEXT; for (int i = 0; i < STATUS_COUNT; i++) { lvI.pszText = pcli->pfnGetStatusModeDescription(ID_STATUS_ONLINE + i, 0); lvI.iItem = i; ListView_InsertItem(hwndList, &lvI); ListView_SetCheckState(hwndList, i, settingStatus[i]); } connExceptionsTmp = LoadSettingsConnections(); hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS); SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; lvc.iSubItem = 0; lvc.cx = 120; // width of column in pixels lvc.pszText = TranslateT("Application"); ListView_InsertColumn(hwndList, 1, &lvc); lvc.pszText = TranslateT("Internal socket"); ListView_InsertColumn(hwndList, 2, &lvc); lvc.pszText = TranslateT("External socket"); ListView_InsertColumn(hwndList, 3, &lvc); lvc.pszText = TranslateT("Action"); lvc.cx = 50; ListView_InsertColumn(hwndList, 4, &lvc); //fill exceptions list fillExceptionsListView(hwndDlg); } break; case WM_COMMAND://user changed something, so get changes to variables PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); switch (LOWORD(wParam)) { case IDC_INTERVAL: settingInterval = GetDlgItemInt(hwndDlg, IDC_INTERVAL, NULL, FALSE); break; case IDC_INTERVAL1: settingInterval1 = GetDlgItemInt(hwndDlg, IDC_INTERVAL1, NULL, TRUE); break; case IDC_RESOLVEIP: settingResolveIp = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RESOLVEIP); break; case ID_CHK_DEFAULTACTION: settingDefaultAction = (BYTE)IsDlgButtonChecked(hwndDlg, ID_CHK_DEFAULTACTION); break; case ID_ADD: { struct CONNECTION *cur = (struct CONNECTION *)mir_alloc(sizeof(struct CONNECTION)); memset(cur, 0, sizeof(struct CONNECTION)); cur->intExtPort = -1; cur->intIntPort = -1; cur->Pid = 0; cur->PName[0] = '*'; cur->strExtIp[0] = '*'; cur->strIntIp[0] = '*'; if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur) == IDCANCEL) { mir_free(cur); cur = NULL; } else { cur->next = connExceptionsTmp; connExceptionsTmp = cur; } fillExceptionsListView(hwndDlg); ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), 0, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED); SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)); } break; case ID_DELETE: { int pos, pos1; struct CONNECTION *cur = connExceptionsTmp, *pre = NULL; pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED); if (pos == -1)break; pos1 = pos; while (pos--) { pre = cur; cur = cur->next; } if (pre == NULL) connExceptionsTmp = connExceptionsTmp->next; else (pre)->next = cur->next; mir_free(cur); fillExceptionsListView(hwndDlg); ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED); SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)); break; } case ID_UP: { int pos, pos1; struct CONNECTION *cur = NULL, *pre = NULL, *prepre = NULL; cur = connExceptionsTmp; pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED); if (pos == -1)break; pos1 = pos; while (pos--) { prepre = pre; pre = cur; cur = cur->next; } if (prepre != NULL) { pre->next = cur->next; cur->next = pre; prepre->next = cur; } else if (pre != NULL) { pre->next = cur->next; cur->next = pre; connExceptionsTmp = cur; } fillExceptionsListView(hwndDlg); ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 - 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED); SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)); break; } case ID_DOWN: { int pos, pos1; struct CONNECTION *cur = NULL, *pre = NULL; cur = connExceptionsTmp; pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED); if (pos == -1)break; pos1 = pos; while (pos--) { pre = cur; cur = cur->next; } if (cur == connExceptionsTmp&&cur->next != NULL) { connExceptionsTmp = cur->next; cur->next = cur->next->next; connExceptionsTmp->next = cur; } else if (cur->next != NULL) { struct CONNECTION *tmp = cur->next->next; pre->next = cur->next; cur->next->next = cur; cur->next = tmp; } fillExceptionsListView(hwndDlg); ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 + 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED); SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)); break; } case IDC_SETCOLOURS: { HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR); settingSetColours = IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS); EnableWindow(hwnd, settingSetColours); hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR); EnableWindow(hwnd, settingSetColours); break; } case IDC_BGCOLOR: settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); break; case IDC_FGCOLOR: settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0); break; } break; case WM_NOTIFY://apply changes so write it to db switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_RESET: LoadSettings(); deleteConnectionsTable(connExceptionsTmp); connExceptionsTmp = LoadSettingsConnections(); return TRUE; case PSN_APPLY: db_set_dw(NULL, PLUGINNAME, "Interval", settingInterval); db_set_dw(NULL, PLUGINNAME, "PopupInterval", settingInterval1); db_set_b(NULL, PLUGINNAME, "PopupSetColours", settingSetColours); db_set_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)settingBgColor); db_set_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)settingFgColor); db_set_b(NULL, PLUGINNAME, "ResolveIp", settingResolveIp); db_set_b(NULL, PLUGINNAME, "FilterDefaultAction", settingDefaultAction); for (int i = 0; i < STATUS_COUNT; i++) { char buff[128]; mir_snprintf(buff, "Status%d", i); settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE); db_set_b(0, PLUGINNAME, buff, settingStatus[i] ? 1 : 0); } if (WAIT_OBJECT_0 == WaitForSingleObject(hExceptionsMutex, 100)) { deleteConnectionsTable(connExceptions); saveSettingsConnections(connExceptionsTmp); connExceptions = connExceptionsTmp; connExceptionsTmp = LoadSettingsConnections(); ReleaseMutex(hExceptionsMutex); } return TRUE; } break; } if (GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS) == ((LPNMHDR)lParam)->hwndFrom) { switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: { int pos, pos1; struct CONNECTION *cur = NULL; cur = connExceptionsTmp; pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED); if (pos == -1)break; pos1 = pos; while (pos--) { cur = cur->next; } DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur); fillExceptionsListView(hwndDlg); ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED); SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)); break; } } } if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR)lParam)->hwndFrom) { switch (((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } } break; case WM_DESTROY: bOptionsOpen = FALSE; deleteConnectionsTable(connExceptionsTmp); connExceptionsTmp = NULL; return TRUE; } return 0; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int result = prepare(lpCmdLine); if (result == ERROR_ALREADY_EXISTS) { HWND handle = getInstanceWindow(); ShowWindow(handle, SW_SHOW); SetForegroundWindow(handle); closeLogFile(); return 2; } if (result != TRUE) { signalError(); return 1; } splash = loadBool(SHOW_SPLASH) && strstr(lpCmdLine, "--l4j-no-splash") == NULL; restartOnCrash = loadBool(RESTART_ON_CRASH); // if we should restart on crash, we must also stay alive to check for crashes stayAlive = restartOnCrash || (loadBool(GUI_HEADER_STAYS_ALIVE) && strstr(lpCmdLine, "--l4j-dont-wait") == NULL); if (splash || stayAlive) { hWnd = CreateWindowEx(WS_EX_TOOLWINDOW, "STATIC", "", WS_POPUP | SS_BITMAP, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (splash) { char timeout[10] = {0}; if (loadString(SPLASH_TIMEOUT, timeout)) { splashTimeout = atoi(timeout); if (splashTimeout <= 0 || splashTimeout > MAX_SPLASH_TIMEOUT) { splashTimeout = DEFAULT_SPLASH_TIMEOUT; } } splashTimeoutErr = loadBool(SPLASH_TIMEOUT_ERR) && strstr(lpCmdLine, "--l4j-no-splash-err") == NULL; waitForWindow = loadBool(SPLASH_WAITS_FOR_WINDOW); HANDLE hImage = LoadImage(hInstance, // handle of the instance containing the image MAKEINTRESOURCE(SPLASH_BITMAP), // name or identifier of image IMAGE_BITMAP, // type of image 0, // desired width 0, // desired height LR_DEFAULTSIZE); if (hImage == NULL) { signalError(); return 1; } SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImage); RECT rect; GetWindowRect(hWnd, &rect); int x = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2; int y = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2; SetWindowPos(hWnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE); ShowWindow(hWnd, nCmdShow); UpdateWindow (hWnd); } } do { if (splash || stayAlive) { if (!SetTimer (hWnd, ID_TIMER, 1000 /* 1s */, TimerProc)) { signalError(); return 1; } } if (!execute(FALSE, &dwExitCode)) { signalError(); return 1; } if (!(splash || stayAlive)) { debug("Exit code:\t0\n"); closeProcessHandles(); closeLogFile(); return 0; } MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (restartOnCrash && dwExitCode != 0) { debug("Exit code:\t%d, restarting the application!\n", dwExitCode); } closeProcessHandles(); } while (restartOnCrash && dwExitCode != 0); debug("Exit code:\t%d\n", dwExitCode); closeLogFile(); return dwExitCode; }
/* * extrasCreatePipeDialog * * Purpose: * * Create and initialize Pipe Dialog. * */ VOID extrasCreatePipeDialog( _In_ HWND hwndParent ) { LVCOLUMN col; HICON hIcon; //allow only one dialog if (g_wobjDialogs[WOBJ_PIPEDLG_IDX]) { SetActiveWindow(g_wobjDialogs[WOBJ_PIPEDLG_IDX]); return; } RtlSecureZeroMemory(&PipeDlgContext, sizeof(PipeDlgContext)); PipeDlgContext.hwndDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_PIPES), hwndParent, &PipeDlgProc, 0); if (PipeDlgContext.hwndDlg == NULL) { return; } g_wobjDialogs[WOBJ_PIPEDLG_IDX] = PipeDlgContext.hwndDlg; //setup dlg listview PipeDlgContext.ListView = GetDlgItem(PipeDlgContext.hwndDlg, ID_PIPESLIST); if (PipeDlgContext.ListView) { PipeDlgContext.ImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 42, 8); if (PipeDlgContext.ImageList) { //set default app icon hIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_PIPE), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); if (hIcon) { ImageList_ReplaceIcon(PipeDlgContext.ImageList, -1, hIcon); DestroyIcon(hIcon); } //sort images hIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTUP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); if (hIcon) { ImageList_ReplaceIcon(PipeDlgContext.ImageList, -1, hIcon); DestroyIcon(hIcon); } hIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTDOWN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); if (hIcon) { ImageList_ReplaceIcon(PipeDlgContext.ImageList, -1, hIcon); DestroyIcon(hIcon); } ListView_SetImageList(PipeDlgContext.ListView, PipeDlgContext.ImageList, LVSIL_SMALL); } ListView_SetExtendedListViewStyle(PipeDlgContext.ListView, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_LABELTIP); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE; col.iSubItem = 1; col.pszText = TEXT("Name"); col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT; col.iOrder = 0; col.iImage = 2; col.cx = 500; ListView_InsertColumn(PipeDlgContext.ListView, 1, &col); PipeDlgQueryInfo(); ListView_SortItemsEx(PipeDlgContext.ListView, &PipeDlgCompareFunc, 0); } }
main(int argc,char *argv[]) { CoolImage *image; int x,y; int i,j; PtWidget_t *win; PtArg_t args[3]; PhDim_t dim={m_W,m_H}; PhPoint_t pos={50,250}; int fd; //Bt878 driver file descriptor int fd_temp; int size_read; struct timeval tv; fd_set rfd; int n; int error; int counter = 0; int counter_mean = 0; int file = 0; //Timing calculation uint64_t cps, cycle1, cycle2, ncycles; float sec; float msec; // if a paramater was passed, grab it as the blit type if (argc>1) blittype=atoi(argv[1]); // initialize our connection to Photon, and create/realize a window //PtInit("/net/irene2/dev/photon"); PtInit("/dev/photon"); PtSetArg(&args[0],Pt_ARG_POS,&pos,0); PtSetArg(&args[1],Pt_ARG_DIM,&dim,0); win=PtCreateWidget(PtWindow,Pt_NO_PARENT,2,args); PtRealizeWidget(win); // Allocate and fill a series of NUMIMAGES images with a little // fading type animation. Put your own animation in here if you like. /* * Set a 5 second timeout. */ tv.tv_sec = 5; tv.tv_usec = 0; image = AllocBuffer(m_W,m_H,fd); assert(image!=0); if (file != 2) { init_bttvx(2,0, m_W,m_H,0,0); open_bttvx(); BttvxSetImageBuffer(0, image->buffer); } fd_temp = fd; FD_ZERO( &rfd ); FD_SET( fd, &rfd ); while(1) { //fd = open("/net/europa/dev/bttvx0",O_RDWR); //if ( fd > 0 ) //{ ///switch ( n = select( 1 + max( fd,0 ), /// &rfd, 0, 0, &tv ) ) ///{ /// case -1: /// perror( "select" ); /// return EXIT_FAILURE; /// case 0: /// puts( "select timed out" ); /// break; /// default: //printf( "descriptor ready ...\n"); //if( FD_ISSET( console, &rfd ) ) // puts( " -- console descriptor has data pending" ); //if( FD_ISSET( serial, &rfd ) ) // puts( " -- serial descriptor has data pending" ); /* Read the text */ cycle1=ClockCycles( ); //lseek(fd,0L,SEEK_SET); /// size_read = read( fd, image->buffer, W*H*deep ); if (file != 2) { BttvxWaitEvent(); BttvxAcquireBuffer(image->buffer); } switch(file) { case 0: BlitBuffer(win,image); break; case 1: SaveImage(counter,image); break; case 2: LoadImage(counter,image); BlitBuffer(win,image); getchar(); break; }; if (file!=2) BttvxReleaseBuffer(); cycle2=ClockCycles( ); counter++; counter_mean++; ncycles=cycle2-cycle1; //printf("%lld cycles elapsed \n", ncycles); /* find out how many cycles per second */ cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec; //printf( "This system has %lld cycles/sec.\n",cps ); sec=(float)ncycles/cps; msec +=sec; if (counter_mean == 250 ) { msec = msec/counter_mean; printf("The cycles in seconds is %f \n",msec); counter_mean = 0; msec = 0; } //}else //sleep(2); } //printf("Blitted %d frames using method %d\n",REPS*NUMIMAGES,blittype); // now free the images FreeBuffer(image); close( fd ); /// hide the window and destroy it. PtUnrealizeWidget(win); PtDestroyWidget(win); }
Bool winCreateBoundingWindowWindowed (ScreenPtr pScreen) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; int iWidth = pScreenInfo->dwUserWidth; int iHeight = pScreenInfo->dwUserHeight; int iPosX; int iPosY; HWND *phwnd = &pScreenPriv->hwndScreen; WNDCLASSEX wc; RECT rcClient, rcWorkArea; DWORD dwWindowStyle; BOOL fForceShowWindow = FALSE; char szTitle[256]; winDebug ("winCreateBoundingWindowWindowed - User w: %d h: %d\n", (int) pScreenInfo->dwUserWidth, (int) pScreenInfo->dwUserHeight); winDebug ("winCreateBoundingWindowWindowed - Current w: %d h: %d\n", (int) pScreenInfo->dwWidth, (int) pScreenInfo->dwHeight); /* Set the common window style flags */ dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX; /* Decorated or undecorated window */ if (pScreenInfo->fDecoration #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif && !pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { /* Try to handle startup via run.exe. run.exe instructs Windows to * hide all created windows. Detect this case and make sure the * window is shown nevertheless */ STARTUPINFO startupInfo; GetStartupInfo(&startupInfo); if (startupInfo.dwFlags & STARTF_USESHOWWINDOW && startupInfo.wShowWindow == SW_HIDE) { fForceShowWindow = TRUE; } dwWindowStyle |= WS_CAPTION; if (pScreenInfo->iResizeMode != notAllowed) dwWindowStyle |= WS_THICKFRAME | WS_MAXIMIZEBOX; } else dwWindowStyle |= WS_POPUP; /* Setup our window class */ wc.cbSize=sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = winWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInstance; wc.hIcon = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = WINDOW_CLASS; wc.hIconSm = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE); RegisterClassEx (&wc); /* Get size of work area */ winGetWorkArea (&rcWorkArea, pScreenInfo); /* Adjust for auto-hide taskbars */ winAdjustForAutoHide (&rcWorkArea); /* Did the user specify a position? */ if (pScreenInfo->fUserGavePosition) { iPosX = pScreenInfo->dwInitialX; iPosY = pScreenInfo->dwInitialY; } else { iPosX = rcWorkArea.left; iPosY = rcWorkArea.top; } /* Clean up the scrollbars flag, if necessary */ if ((!pScreenInfo->fDecoration #ifdef XWIN_MULTIWINDOWEXTWM || pScreenInfo->fMWExtWM #endif || pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW || pScreenInfo->fMultiWindow #endif ) && (pScreenInfo->iResizeMode == resizeWithScrollbars)) { /* We cannot have scrollbars if we do not have a window border */ pScreenInfo->iResizeMode = notAllowed; } /* Did the user specify a height and width? */ if (pScreenInfo->fUserGaveHeightAndWidth) { /* User gave a desired height and width, try to accomodate */ #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - User gave height " "and width\n"); #endif /* Adjust the window width and height for borders and title bar */ if (pScreenInfo->fDecoration #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif && !pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Window has decoration\n"); #endif /* Are we resizable */ if (pScreenInfo->iResizeMode != notAllowed) { #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Window is resizable\n"); #endif iWidth += 2 * GetSystemMetrics (SM_CXSIZEFRAME); iHeight += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION); } else { #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Window is not resizable\n"); #endif iWidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME); iHeight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION); } } } else { /* By default, we are creating a window that is as large as possible */ #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - User did not give " "height and width\n"); #endif /* Defaults are wrong if we have multiple monitors */ if (pScreenInfo->fMultipleMonitors) { iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); } } /* Make sure window is no bigger than work area */ if (TRUE #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { /* Trim window width to fit work area */ if (iWidth > (rcWorkArea.right - rcWorkArea.left)) iWidth = rcWorkArea.right - rcWorkArea.left; /* Trim window height to fit work area */ if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top)) iHeight = rcWorkArea.bottom - rcWorkArea.top; #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Adjusted width: %d "\ "height: %d\n", iWidth, iHeight); #endif } /* Set display and screen-specific tooltip text */ if (g_pszQueryHost != NULL) snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE_XDMCP, g_pszQueryHost, display, (int) pScreenInfo->dwScreen); else snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE, display, (int) pScreenInfo->dwScreen); /* Create the window */ *phwnd = CreateWindowExA (0, /* Extended styles */ WINDOW_CLASS, /* Class name */ szTitle, /* Window name */ dwWindowStyle, iPosX, /* Horizontal position */ iPosY, /* Vertical position */ iWidth, /* Right edge */ iHeight, /* Bottom edge */ (HWND) NULL, /* No parent or owner window */ (HMENU) NULL, /* No menu */ GetModuleHandle (NULL),/* Instance handle */ pScreenPriv); /* ScreenPrivates */ if (*phwnd == NULL) { ErrorF ("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n"); return FALSE; } #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n"); #endif if (fForceShowWindow) { ErrorF("winCreateBoundingWindowWindowed - Setting normal windowstyle\n"); ShowWindow(*phwnd, SW_SHOW); } /* Get the client area coordinates */ if (!GetClientRect (*phwnd, &rcClient)) { ErrorF ("winCreateBoundingWindowWindowed - GetClientRect () " "failed\n"); return FALSE; } winDebug ("winCreateBoundingWindowWindowed - WindowClient " "w %ld h %ld r %ld l %ld b %ld t %ld\n", rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, rcClient.right, rcClient.left, rcClient.bottom, rcClient.top); /* We adjust the visual size if the user did not specify it */ if (!((pScreenInfo->iResizeMode == resizeWithScrollbars) && pScreenInfo->fUserGaveHeightAndWidth)) { /* * User did not give a height and width with scrollbars enabled, * so we will resize the underlying visual to be as large as * the initial view port (page size). This way scrollbars will * not appear until the user shrinks the window, if they ever do. * * NOTE: We have to store the viewport size here because * the user may have an autohide taskbar, which would * cause the viewport size to be one less in one dimension * than the viewport size that we calculated by subtracting * the size of the borders and caption. */ pScreenInfo->dwWidth = rcClient.right - rcClient.left; pScreenInfo->dwHeight = rcClient.bottom - rcClient.top; } #if 0 /* * NOTE: For the uninitiated, the page size is the number of pixels * that we can display in the x or y direction at a time and the * range is the total number of pixels in the x or y direction that we * have available to display. In other words, the page size is the * size of the window area minus the space the caption, borders, and * scrollbars (if any) occupy, and the range is the size of the * underlying X visual. Notice that, contrary to what some of the * MSDN Library arcticles lead you to believe, the windows * ``client area'' size does not include the scrollbars. In other words, * the whole client area size that is reported to you is drawable by * you; you do not have to subtract the size of the scrollbars from * the client area size, and if you did it would result in the size * of the scrollbars being double counted. */ /* Setup scrollbar page and range, if scrollbars are enabled */ if (pScreenInfo->fScrollbars) { SCROLLINFO si; /* Initialize the scrollbar info structure */ si.cbSize = sizeof (si); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; /* Setup the width range and page size */ si.nMax = pScreenInfo->dwWidth - 1; si.nPage = rcClient.right - rcClient.left; winDebug ("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n", si.nMax, si.nPage); SetScrollInfo (*phwnd, SB_HORZ, &si, TRUE); /* Setup the height range and page size */ si.nMax = pScreenInfo->dwHeight - 1; si.nPage = rcClient.bottom - rcClient.top; winDebug ("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n", si.nMax, si.nPage); SetScrollInfo (*phwnd, SB_VERT, &si, TRUE); } #endif /* Show the window */ if (FALSE #ifdef XWIN_MULTIWINDOWEXTWM || pScreenInfo->fMWExtWM #endif #ifdef XWIN_MULTIWINDOW || pScreenInfo->fMultiWindow #endif ) { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) pScreenPriv->fRootWindowShown = FALSE; #endif ShowWindow (*phwnd, SW_HIDE); } else ShowWindow (*phwnd, SW_SHOWNORMAL); if (!UpdateWindow (*phwnd)) { ErrorF ("winCreateBoundingWindowWindowed - UpdateWindow () failed\n"); return FALSE; } /* Attempt to bring our window to the top of the display */ if (TRUE #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif && !pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { if (!BringWindowToTop (*phwnd)) { ErrorF ("winCreateBoundingWindowWindowed - BringWindowToTop () " "failed\n"); return FALSE; } } #ifdef XWIN_NATIVEGDI /* Paint window background blue */ if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI) winPaintBackground (*phwnd, RGB (0x00, 0x00, 0xFF)); #endif winDebug ("winCreateBoundingWindowWindowed - Returning\n"); return TRUE; }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { WNDCLASSEX wcFrame = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW/*style*/, FrameWndProc, 0/*cbClsExtra*/, 0/*cbWndExtra*/, hInstance, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)), LoadCursor(0, IDC_ARROW), 0/*hbrBackground*/, 0/*lpszMenuName*/, szFrameClass, (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_MDI_APP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) }; ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class #if 0 WNDCLASS wcChild = { CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW, ChildWndProc, 0/*cbClsExtra*/, 0/*cbWndExtra*/, hInstance, 0/*hIcon*/, LoadCursor(0, IDC_ARROW), 0/*hbrBackground*/, 0/*lpszMenuName*/, szChildClass }; ATOM hChildWndClass = RegisterClass(&wcChild); // register child windows class #else // WNDCLASSEX wcChild = { // sizeof(WNDCLASSEX), // CS_HREDRAW | CS_VREDRAW/*style*/, // ChildWndProc, // 0/*cbClsExtra*/, // sizeof(HANDLE)/*cbWndExtra*/, // hInstance, // LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)), // LoadCursor(0, IDC_ARROW), // 0/*hbrBackground*/, // 0/*lpszMenuName*/, // szChildClass, // (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDC_MDI_APP), IMAGE_ICON, // GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) // }; // ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class #endif HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP)); HMENU hMenuOptions = GetSubMenu(hMenu, ID_OPTIONS_MENU); // HMENU hChildMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP_CHILD)); INITCOMMONCONTROLSEX icc = { sizeof(INITCOMMONCONTROLSEX), ICC_BAR_CLASSES }; HDC hdc = GetDC(0); hMenuFrame = hMenu; // hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MDI_APP)); hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif")); ReleaseDC(0, hdc); hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, // hFrameWnd = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL/*hWndParent*/, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } if (InitCommonControlsEx(&icc)) { int nParts[3]; TBBUTTON toolbarBtns[] = { {0, 0, 0, TBSTYLE_SEP}, {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON}, }; hToolBar = CreateToolbarEx(hFrameWnd, WS_CHILD|WS_VISIBLE, IDC_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns, sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON)); CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED); // Create the status bar hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, "", hFrameWnd, IDC_STATUSBAR); if (!hStatusBar) return FALSE; CheckMenuItem(hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); // Create the status bar panes nParts[0] = 100; nParts[1] = 210; nParts[2] = 400; SendMessage(hStatusBar, SB_SETPARTS, 3, (long)nParts); } else { CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_GRAYED); CheckMenuItem(hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_GRAYED); } ShowWindow(hFrameWnd, nCmdShow); UpdateWindow(hFrameWnd); UpdateStatusBar(); return TRUE; }
Bool winCreateBoundingWindowFullScreen (ScreenPtr pScreen) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; int iX = pScreenInfo->dwInitialX; int iY = pScreenInfo->dwInitialY; int iWidth = pScreenInfo->dwWidth; int iHeight = pScreenInfo->dwHeight; HWND *phwnd = &pScreenPriv->hwndScreen; WNDCLASSEX wc; char szTitle[256]; #if CYGDEBUG winDebug ("winCreateBoundingWindowFullScreen\n"); #endif /* Setup our window class */ wc.cbSize=sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = winWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInstance; wc.hIcon = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); wc.hCursor = 0; wc.hbrBackground = 0; wc.lpszMenuName = NULL; wc.lpszClassName = WINDOW_CLASS; wc.hIconSm = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE); RegisterClassEx (&wc); /* Set display and screen-specific tooltip text */ if (g_pszQueryHost != NULL) snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE_XDMCP, g_pszQueryHost, display, (int) pScreenInfo->dwScreen); else snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE, display, (int) pScreenInfo->dwScreen); /* Create the window */ *phwnd = CreateWindowExA (0, /* Extended styles */ WINDOW_CLASS, /* Class name */ szTitle, /* Window name */ WS_POPUP, iX, /* Horizontal position */ iY, /* Vertical position */ iWidth, /* Right edge */ iHeight, /* Bottom edge */ (HWND) NULL, /* No parent or owner window */ (HMENU) NULL, /* No menu */ GetModuleHandle (NULL),/* Instance handle */ pScreenPriv); /* ScreenPrivates */ /* Branch on the server engine */ switch (pScreenInfo->dwEngine) { #ifdef XWIN_NATIVEGDI case WIN_SERVER_SHADOW_GDI: /* Show the window */ ShowWindow (*phwnd, SW_SHOWMAXIMIZED); break; #endif default: /* Hide the window */ ShowWindow (*phwnd, SW_SHOWNORMAL); break; } /* Send first paint message */ UpdateWindow (*phwnd); /* Attempt to bring our window to the top of the display */ BringWindowToTop (*phwnd); return TRUE; }
Bool winCreateBoundingWindowWindowed (ScreenPtr pScreen) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; int iWidth = pScreenInfo->dwUserWidth; int iHeight = pScreenInfo->dwUserHeight; HWND *phwnd = &pScreenPriv->hwndScreen; WNDCLASS wc; RECT rcClient, rcWorkArea; DWORD dwWindowStyle; #ifdef NXWIN_LOGO HANDLE nxIcon; nxIcon = LoadImage( GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 16, 16, /* GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), */ 0 ); if(nxIcon == NULL) { ErrorF ("cannot load icon\n"); } #endif ErrorF ("winCreateBoundingWindowWindowed - User w: %d h: %d\n", pScreenInfo->dwUserWidth, pScreenInfo->dwUserHeight); ErrorF ("winCreateBoundingWindowWindowed - Current w: %d h: %d\n", pScreenInfo->dwWidth, pScreenInfo->dwHeight); /* Set the common window style flags */ dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX; /* Decorated or undecorated window */ if (pScreenInfo->fDecoration && !pScreenInfo->fRootless && !pScreenInfo->fMultiWindow) { dwWindowStyle |= WS_CAPTION; if (pScreenInfo->fScrollbars) dwWindowStyle |= WS_THICKFRAME | WS_MAXIMIZEBOX; } else dwWindowStyle |= WS_POPUP; /* Setup our window class */ wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = winWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInstance; #ifdef NXWIN_LOGO wc.hIcon = nxIcon; #else wc.hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)); #endif wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = WINDOW_CLASS; RegisterClass (&wc); /* Get size of work area */ winGetWorkArea (&rcWorkArea, pScreenInfo); /* Adjust for auto-hide taskbars */ winAdjustForAutoHide (&rcWorkArea); /* Did the user specify a height and width? */ if (pScreenInfo->fUserGaveHeightAndWidth) { /* User gave a desired height and width, try to accomodate */ #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - User gave height " "and width\n"); #endif /* Adjust the window width and height for borders and title bar */ if (pScreenInfo->fDecoration && !pScreenInfo->fRootless && !pScreenInfo->fMultiWindow) { #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - Window has decoration\n"); #endif /* Are we using scrollbars? */ if (pScreenInfo->fScrollbars) { #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - Window has " "scrollbars\n"); #endif iWidth += 2 * GetSystemMetrics (SM_CXSIZEFRAME); iHeight += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION); } else { #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - Window does not have " "scrollbars\n"); #endif iWidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME); iHeight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION); } } else { /* * User gave a width and height but also said no decoration. * In this case we have to ignore the requested width and height * and instead use the largest possible window that we can. */ if (pScreenInfo->fMultipleMonitors) { iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); } else { iWidth = GetSystemMetrics (SM_CXSCREEN); iHeight = GetSystemMetrics (SM_CYSCREEN); } } } else { /* By default, we are creating a window that is as large as possible */ #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - User did not give " "height and width\n"); #endif /* Defaults are wrong if we have multiple monitors */ if (pScreenInfo->fMultipleMonitors) { iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); } } /* Clean up the scrollbars flag, if necessary */ if ((!pScreenInfo->fDecoration || pScreenInfo->fRootless || pScreenInfo->fMultiWindow) && pScreenInfo->fScrollbars) { /* We cannot have scrollbars if we do not have a window border */ pScreenInfo->fScrollbars = FALSE; } /* Trim window width to fit work area */ if (iWidth > (rcWorkArea.right - rcWorkArea.left)) iWidth = rcWorkArea.right - rcWorkArea.left; /* Trim window height to fit work area */ if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top)) iHeight = rcWorkArea.bottom - rcWorkArea.top; #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - Adjusted width: %d "\ "height: %d\n", iWidth, iHeight); #endif /* Create the window */ *phwnd = CreateWindowExA (0, /* Extended styles */ WINDOW_CLASS, /* Class name */ WINDOW_TITLE, /* Window name */ dwWindowStyle #ifdef NXWIN_ICONIC | (nxwinIconicMode?WS_ICONIC:0) #endif , rcWorkArea.left, /* Horizontal position */ rcWorkArea.top, /* Vertical position */ iWidth, /* Right edge */ iHeight, /* Bottom edge */ (HWND) NULL, /* No parent or owner window */ (HMENU) NULL, /* No menu */ GetModuleHandle (NULL),/* Instance handle */ pScreenPriv); /* ScreenPrivates */ if (*phwnd == NULL) { ErrorF ("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n"); return FALSE; } #if CYGDEBUG ErrorF ("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n"); #endif /* Get the client area coordinates */ if (!GetClientRect (*phwnd, &rcClient)) { ErrorF ("winCreateBoundingWindowWindowed - GetClientRect () " "failed\n"); return FALSE; } ErrorF ("winCreateBoundingWindowWindowed - WindowClient " "w %ld h %ld r %ld l %ld b %ld t %ld\n", rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, rcClient.right, rcClient.left, rcClient.bottom, rcClient.top); /* We adjust the visual size if the user did not specify it */ if (!(pScreenInfo->fScrollbars && pScreenInfo->fUserGaveHeightAndWidth)) { /* * User did not give a height and width with scrollbars enabled, * so we will resize the underlying visual to be as large as * the initial view port (page size). This way scrollbars will * not appear until the user shrinks the window, if they ever do. * * NOTE: We have to store the viewport size here because * the user may have an autohide taskbar, which would * cause the viewport size to be one less in one dimension * than the viewport size that we calculated by subtracting * the size of the borders and caption. */ pScreenInfo->dwWidth = rcClient.right - rcClient.left; pScreenInfo->dwHeight = rcClient.bottom - rcClient.top; } #if 0 /* * NOTE: For the uninitiated, the page size is the number of pixels * that we can display in the x or y direction at a time and the * range is the total number of pixels in the x or y direction that we * have available to display. In other words, the page size is the * size of the window area minus the space the caption, borders, and * scrollbars (if any) occupy, and the range is the size of the * underlying X visual. Notice that, contrary to what some of the * MSDN Library arcticles lead you to believe, the windows * ``client area'' size does not include the scrollbars. In other words, * the whole client area size that is reported to you is drawable by * you; you do not have to subtract the size of the scrollbars from * the client area size, and if you did it would result in the size * of the scrollbars being double counted. */ /* Setup scrollbar page and range, if scrollbars are enabled */ if (pScreenInfo->fScrollbars) { SCROLLINFO si; /* Initialize the scrollbar info structure */ si.cbSize = sizeof (si); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; /* Setup the width range and page size */ si.nMax = pScreenInfo->dwWidth - 1; si.nPage = rcClient.right - rcClient.left; ErrorF ("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n", si.nMax, si.nPage); SetScrollInfo (*phwnd, SB_HORZ, &si, TRUE); /* Setup the height range and page size */ si.nMax = pScreenInfo->dwHeight - 1; si.nPage = rcClient.bottom - rcClient.top; ErrorF ("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n", si.nMax, si.nPage); SetScrollInfo (*phwnd, SB_VERT, &si, TRUE); } #endif /* Show the window */ if (pScreenInfo->fMultiWindow) ShowWindow (*phwnd, nxwinHideStart?SW_HIDE:SW_SHOWMINNOACTIVE); else ShowWindow (*phwnd, nxwinHideStart?SW_HIDE:SW_SHOWNORMAL); SetWindowText(*phwnd, nxwinWinName); /* if (!UpdateWindow (*phwnd)) { ErrorF ("winCreateBoundingWindowWindowed - UpdateWindow () failed\n"); return FALSE; } Attempt to bring our window to the top of the display if (!BringWindowToTop (*phwnd)) { ErrorF ("winCreateBoundingWindowWindowed - BringWindowToTop () " "failed\n"); return FALSE; } */ /* Paint window background blue */ if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI) winPaintBackground (*phwnd, RGB (0x00, 0x00, 0xFF)); ErrorF ("winCreateBoundingWindowWindowed - Returning\n"); return TRUE; }
// load small icon (shared) it's not need to be destroyed static HICON LoadSmallIconShared(HINSTANCE hInstance, LPCTSTR lpIconName) { int cx = g_iIconSX; return (HICON)LoadImage(hInstance, lpIconName, IMAGE_ICON, cx, cx, LR_DEFAULTCOLOR | LR_SHARED); }
// Start point of the program // Start keyboard hook, init config dialog and notification icon int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); if (!RegisterClassEx(&wcex)) return 1; hInst = hInstance; // Store instance handle in our global variable // a dummy hidden dialog to receive the message hHiddenDialog = CreateWindow(szWindowClass, szTitle, WS_TILED|WS_CAPTION|WS_THICKFRAME| WS_MINIMIZEBOX , CW_USEDEFAULT, CW_USEDEFAULT,390, 310, NULL,NULL,hInstance,NULL); if (!hHiddenDialog) return 1; // add button OK HMENU OKButtonID = reinterpret_cast<HMENU>(static_cast<DWORD_PTR>(SM_CLOSE)); HWND hButton = CreateWindowExW(0, L"Button", L"OK", WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_DEFPUSHBUTTON, 140, 228, 100, 25, hHiddenDialog, OKButtonID, hInst, nullptr); SetWindowLongPtr(hButton, GWLP_ID, static_cast<LONG_PTR>(static_cast<DWORD_PTR>(SM_CLOSE))); // setup the icon ZeroMemory(&niData,sizeof(NOTIFYICONDATA)); niData.cbSize = sizeof(NOTIFYICONDATA); niData.uID = TRAY_ICON_ID; niData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; // load the icon niData.hIcon = (HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); niData.hWnd = hHiddenDialog; niData.uCallbackMessage = SWM_TRAYMSG; // tooltip message copyString(niData.szTip, szTip); Shell_NotifyIcon(NIM_ADD,&niData); // free icon handle if (niData.hIcon && DestroyIcon(niData.hIcon)) niData.hIcon = NULL; // setup keyboard hook kbhHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC) KBHookProc, hInst, NULL); // setup mouse hook if (ThreeFingerTap) {mousehHook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)MouseHookProc, hInst, NULL); } // Reposition the window int ScreenX=0; int ScreenY=0; int WinX=0; int WinY=0; RECT wnd; GetWindowRect(hHiddenDialog, &wnd); WinX = wnd.right - wnd.left; WinY = wnd.bottom - wnd.top; ScreenX = GetSystemMetrics(SM_CXSCREEN); ScreenY = GetSystemMetrics(SM_CYSCREEN); ScreenX = (ScreenX / 2) - ((int)WinX / 2); ScreenY = (ScreenY / 2) - ((int)WinY / 2); SetWindowPos(hHiddenDialog,HWND_TOP, ScreenX, ScreenY, (int)WinX,(int)WinY,NULL); // Main message loop: MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; // program end here }
CInvestigatorPopupWnd::CInvestigatorPopupWnd() { m_pInvestigator = NULL; m_hIcon = (HICON)LoadImage( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_SHEETTYPE), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS ); }
/* Show the Splash Window * * Open the bitmap, insert into the splash window and display it. * */ int showSplash( const _TCHAR* featureImage ) { static int splashing = 0; HBITMAP hBitmap = 0; BITMAP bmp; HDC hDC; int depth; int x, y; int width, height; int dpiX, scaledWidth, scaledHeight; if(splashing) { /*splash screen is already showing, do nothing */ return 0; } if (featureImage == NULL) return -1; /* if Java was started first and is calling back to show the splash, we might not * have initialized the window system yet */ initWindowSystem(0, NULL, 1); /* Load the bitmap for the feature. */ hDC = GetDC( NULL); depth = GetDeviceCaps( hDC, BITSPIXEL ) * GetDeviceCaps( hDC, PLANES); /* fetch screen DPI and round it to 100% multiples, this implementation needs to be kept in sync with org.eclipse.swt.internal.DPIUtil#setDeviceZoom(int) */ dpiX = GetDeviceCaps ( hDC, LOGPIXELSX ); dpiX = ((int)((dpiX + 24) / 96 )) * 96; ReleaseDC(NULL, hDC); if (featureImage != NULL) hBitmap = LoadImage(NULL, featureImage, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); /* If the bitmap could not be found, return an error. */ if (hBitmap == 0) return ERROR_FILE_NOT_FOUND; GetObject(hBitmap, sizeof(BITMAP), &bmp); /* reload scaled up image when zoom > 100% */ if (dpiX > 96) { /* calculate scaled-up bounds */ scaledWidth = dpiX * bmp.bmWidth / 96; scaledHeight = dpiX * bmp.bmHeight / 96; hBitmap = LoadImage(NULL, featureImage, IMAGE_BITMAP, scaledWidth, scaledHeight, LR_LOADFROMFILE); /* If the bitmap could not be found, return an error. */ if (hBitmap == 0) return ERROR_FILE_NOT_FOUND; GetObject(hBitmap, sizeof(BITMAP), &bmp); } /* figure out position */ width = GetSystemMetrics (SM_CXSCREEN); height = GetSystemMetrics (SM_CYSCREEN); x = (width - bmp.bmWidth) / 2; y = (height - bmp.bmHeight) / 2; /* Centre the splash window and display it. */ SetWindowPos (topWindow, 0, x, y, bmp.bmWidth, bmp.bmHeight, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); SendMessage( topWindow, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBitmap ); ShowWindow( topWindow, SW_SHOW ); BringWindowToTop( topWindow ); splashing = 1; /* Process messages */ dispatchMessages(); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = (HICON)LoadImage( // returns a HANDLE so we have to cast to HICON NULL, // hInstance must be NULL when loading from a file "tr.ico", // the icon file name IMAGE_ICON, // specifies that the file is an icon 0, // width of the image (we'll specify default later on) 0, // height of the image LR_LOADFROMFILE | // we want to load a file (as opposed to a resource) LR_DEFAULTSIZE | // default metrics based on the type (IMAGE_ICON, 32x32) LR_SHARED // let the system release the handle when it's no longer used ); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = (HICON)LoadImage( NULL, "tr.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED ); if (!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } // Step 2: Creating the Window hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "R-tree Application", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1366, 768, NULL, NULL, hInstance, NULL); if (hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); // Step 3: The Message Loop while (GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
bool Situation_6::Initialize() { hbit[0] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/BackGround.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[1] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/Narr1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[2] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/Narr2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[3] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/ButtonA.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[4] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/ButtonB.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[5] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/ButtonC.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[6] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/BackGround_A.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[7] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/BackGround_B.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[8] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/BackGround_C.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[9] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/NarrA_1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[10] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/NarrA_2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[11] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/NarrB_1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[12] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/NarrB_2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[13] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/NarrC_1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); hbit[14] = (HBITMAP)LoadImage(NULL, L"./Bitmap/sit_6/NarrC_2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); for (size_t i = 0; i < 15; i++) IMAGE_CHECK(hbit[i]); CurrentNarr = &hbit[1]; CommonPtr()->ResetCommon(); return true; }
HRESULT image::init(const char* fileName, int width, int height, int frameX, int frameY, BOOL trans, COLORREF transColor) { //파일 경로가 잘못 되었으면... if (fileName == NULL) return E_FAIL; //재초기화에 대비 if (_imageInfo != NULL) release(); //DC 얻는다 HDC hdc = GetDC(_hWnd); //이미지 정보 생성 _imageInfo = new IMAGE_INFO; _imageInfo->loadType = LOAD_FILE; _imageInfo->resID = 0; _imageInfo->hMemDC = CreateCompatibleDC(hdc); _imageInfo->hBit = (HBITMAP)LoadImage(_hInstance, fileName, IMAGE_BITMAP, width, height, LR_LOADFROMFILE); _imageInfo->hOBit = (HBITMAP)SelectObject(_imageInfo->hMemDC, _imageInfo->hBit); _imageInfo->x = 0; _imageInfo->y = 0; _imageInfo->width = width; _imageInfo->height = height; _imageInfo->currentFrameX = 0; _imageInfo->currentFrameY = 0; _imageInfo->maxFrameX = frameX - 1; _imageInfo->maxFrameY = frameY - 1; _imageInfo->frameWidth = width / frameX; _imageInfo->frameHeight = height / frameY; //파일 경로 이름 복사 int len = strlen(fileName); _fileName = new CHAR[len + 1]; strcpy_s(_fileName, len + 1, fileName); //투명 컬러 셋팅 _trans = trans; _transColor = transColor; //알파 블렌드 욥션 설정하자 _blendFunc.BlendFlags = 0; _blendFunc.AlphaFormat = 0; _blendFunc.BlendOp = AC_SRC_OVER; ////알파 블렌드 사용을 위한 이미지 설정 //_blendImage = new IMAGE_INFO; //_blendImage->loadType = LOAD_EMPTY; //_blendImage->resID = 0; //_blendImage->hMemDC = CreateCompatibleDC(hdc); //_blendImage->hBit = (HBITMAP)CreateCompatibleBitmap(hdc, width, height); //_blendImage->hOBit = (HBITMAP)SelectObject(_blendImage->hMemDC, _blendImage->hBit); //_blendImage->width = WINSIZEX; //_blendImage->height = WINSIZEY; //얻은 DC해제 ReleaseDC(_hWnd, hdc); //리소스 얻기에 실패하면 if (_imageInfo->hBit == 0) { release(); return E_FAIL; } return S_OK; }
//--------------------------------------------------------------------------------------- LRESULT OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) { LRESULT lr = 0; PNOTIFYICONDATA pTrayIcon = (PNOTIFYICONDATA)malloc(sizeof(NOTIFYICONDATA)); if(pTrayIcon) { ZeroMemory(pTrayIcon, sizeof(NOTIFYICONDATA)); HMODULE hMod = LoadLibrary(_T("shell32.dll")); if(hMod) { FNDllGetVersion pfnDllGetVersion = (FNDllGetVersion)GetProcAddress(hMod, "DllGetVersion"); if(pfnDllGetVersion) { DLLVERSIONINFO VerInfo = {0}; VerInfo.cbSize = sizeof(VerInfo); pfnDllGetVersion(&VerInfo); if(VerInfo.dwMajorVersion == 6) { if(VerInfo.dwBuildNumber > 6) pTrayIcon->cbSize = sizeof(NOTIFYICONDATA); else pTrayIcon->cbSize = NOTIFYICONDATA_V3_SIZE; pTrayIcon->uVersion = NOTIFYICON_VERSION_4; } else if(VerInfo.dwMajorVersion == 5) { pTrayIcon->cbSize = NOTIFYICONDATA_V2_SIZE; pTrayIcon->uVersion = NOTIFYICON_VERSION; } else { pTrayIcon->cbSize = NOTIFYICONDATA_V1_SIZE; } } FreeLibrary(hMod); hMod = NULL; } pTrayIcon->hWnd = hWnd; pTrayIcon->uFlags = NIF_INFO | NIF_TIP | NIF_ICON | NIF_MESSAGE; pTrayIcon->dwInfoFlags = NIIF_USER; pTrayIcon->uCallbackMessage = WM_TRAY; pTrayIcon->uTimeout = 10000; pTrayIcon->hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_OPENNMS_TRAY), IMAGE_ICON, 0, 0, 0); hMod = GetResourceHandle(); if(hMod) { TCHAR szBuf[MAX_PATH] = _T(""); LoadString(hMod, IDS_TRAY_TIP, szBuf, MAX_PATH); _tcsncpy_s(pTrayIcon->szTip, ARRAYSIZE(pTrayIcon->szTip), szBuf, _TRUNCATE); LoadString(hMod, IDS_TRAY_INFOTITLE, szBuf, MAX_PATH); _tcsncpy_s(pTrayIcon->szInfoTitle, ARRAYSIZE(pTrayIcon->szInfoTitle), szBuf, _TRUNCATE); LoadString(hMod, IDS_TRAY_INFOTEXT, szBuf, MAX_PATH); _tcsncpy_s(pTrayIcon->szInfo, ARRAYSIZE(pTrayIcon->szInfo), szBuf, _TRUNCATE); FreeResourceHandle(hMod); } Sleep(5000); Shell_NotifyIcon(NIM_ADD, pTrayIcon); SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pTrayIcon); } return lr; }