www.pudn.com > 大量windows shell编程例子.zip > A_main.cpp
/***************************************************************** * * Project.....: $$APPNAME$$ * Application.: $$ROOT$$.exe * Module......: $$ROOT$$.cpp * Description.: Application main module * Compiler....: MS Visual C++ * Written by..: $$AUTHOR$$ * Environment.: Windows 9x/NT * ******************************************************************/ /*---------------------------------------------------------------*/ // PRAGMA section /*---------------------------------------------------------------*/ // Force the linker to add the following libraries. #ifdef _MSC_VER #pragma comment(lib, "kernel32.lib") #pragma comment(lib, "user32.lib") #pragma comment(lib, "gdi32.lib") #pragma comment(lib, "shell32.lib") $$IF(USECC) #pragma comment(lib, "comctl32.lib") $$ENDIF #endif /*---------------------------------------------------------------*/ // INCLUDE section /*---------------------------------------------------------------*/ #include "$$root$$.h" $$IF(USECC) #include$$ENDIF $$IF(ADDSHELLAPI) #include $$ENDIF /*---------------------------------------------------------------*/ // GLOBAL section /*---------------------------------------------------------------*/ // Data HICON g_hIconLarge; HICON g_hIconSmall; // Functions void OnInitDialog(HWND); void OnOK(HWND); // Callbacks BOOL CALLBACK APP_DlgProc(HWND, UINT, WPARAM, LPARAM); /*---------------------------------------------------------------*/ // Procedure....: WinMain() // Description..: Entry point in any Windows program // Input........: HINSTANCE, HINSTANCE, LPSTR, int // Output.......: int /*---------------------------------------------------------------*/ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevious, LPTSTR lpsz, int iCmd) { // Save global data g_hIconLarge = static_cast ( LoadImage(hInstance, "APP_ICON", IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CXICON), 0)); g_hIconSmall = static_cast ( LoadImage(hInstance, "APP_ICON", IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON), 0)); $$IF(USECC) $$IF(USECC98) // Enable common controls INITCOMMONCONTROLSEX iccex; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); iccex.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&iccex); $$ELIF(USECC95) // Enable common controls InitCommonControls(); $$ENDIF $$ENDIF // Run main dialog BOOL b = DialogBox(hInstance, "DLG_MAIN", NULL, APP_DlgProc); // Exit DestroyIcon(g_hIconLarge); DestroyIcon(g_hIconSmall); return b; } /*---------------------------------------------------------------*/ // Procedure....: APP_DlgProc() // Description..: Responds to all messages sent to the dialog // Input........: HWND, UINT, WPARAM, LPARAM // Output.......: BOOL /*---------------------------------------------------------------*/ BOOL CALLBACK APP_DlgProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch(uiMsg) { case WM_INITDIALOG: OnInitDialog(hDlg); break; case WM_COMMAND: switch(wParam) { case IDOK: OnOK(hDlg); return FALSE; case IDCANCEL: EndDialog(hDlg, FALSE); return FALSE; } break; } return FALSE; } /***************************************************************** * * Internals: * - OnOK() * - OnInitDialog() * ******************************************************************/ /*---------------------------------------------------------------*/ // Procedure...: OnOK() // Description.: Do something // INPUT.......: HWND // OUTPUT......: void /*---------------------------------------------------------------*/ void OnOK(HWND hDlg) { return; } /*---------------------------------------------------------------*/ // Procedure...: OnInitDialog() // Description.: Initialize the dialog // INPUT.......: HWND // OUTPUT......: void /*---------------------------------------------------------------*/ void OnInitDialog(HWND hDlg) { // Set the icons (T/F as to Large/Small icon) SendMessage(hDlg, WM_SETICON, FALSE, reinterpret_cast (g_hIconSmall)); SendMessage(hDlg, WM_SETICON, TRUE, reinterpret_cast (g_hIconLarge)); } /* End of file: $$root$$.cpp */