分类: C/C++
2008-08-01 17:00:42
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //加载SkinMagicLib.lib、DETOURS.lib 库 InitSkinMagicLib( hInstance, "LINJIN", NULL,NULL ); //LoadSkinFile("corona.smf"); //加载静态自定义皮肤资源 LoadSkinFromResource( GetModuleHandle(NULL), "XPBLUE" , "SKINMAGIC"); //为程序中对话框换肤 SetDialogSkin( "Dialog" ) ; ...... //在 WinMain 结束时释放 SkinMagic 资源。 ExitSkinMagicLib(); }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { ...... //如果程序用到菜单 //要在 SetWindowSkin 之前用,否则 hMenu 为 NULL hMenu = GetMenu (hWnd) ; // 把皮肤加入程序框架 SetWindowSkin( hWnd , "MainFrame" ); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); //使用菜单变换皮肤, //通过数组的持续把菜单和皮肤资源对应, static char* idColor [7] = { "XPBLUE", "CORONA", "KROMO", "XPGREAN", "XPLUS","XPSTEEL","DEVIOR" } ; ...... switch (wmId) { case IDM_XP: // Note: Logic below case IDM_CORONA: // assumes that IDM_WHITE case IDM_KROMO: // through IDM_BLACK are case IDM_XPGREAN: // consecutive numbers in case IDM_XPLUS : // the order shown here. case IDM_XPSTEEL: case IDM_DEVIOR: //菜单选择 CheckMenuItem (hMenu, iSelection, MF_UNCHECKED) ; iSelection = wmId ; CheckMenuItem (hMenu, iSelection, MF_CHECKED) ; LoadSkinFromResource( GetModuleHandle(NULL), idColor[LOWORD (wParam) - IDM_XP] , "SKINMAGIC" ); InvalidateRect (hWnd, NULL, TRUE) ; return 0 ; 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); } }