📄 foldfun.cpp
字号:
/*****************************************************************
*
* Project.....: Fun with Folders
* Application.: FOLDFUN.exe
* Module......: FOLDFUN.cpp
* Description.: Application main module
* Compiler....: MS Visual C++
* Written by..: D. Esposito
* 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")
#pragma comment(lib, "comctl32.lib")
#endif
/*---------------------------------------------------------------*/
// INCLUDE section
/*---------------------------------------------------------------*/
#include "FoldFun.h"
#include <commctrl.h>
#include <shellapi.h>
#include <shlobj.h>
#include "resource.h"
/*---------------------------------------------------------------*/
// GLOBAL section
/*---------------------------------------------------------------*/
// Data
HICON g_hIconLarge;
HICON g_hIconSmall;
// Functions
void OnInitDialog(HWND);
void OnOK(HWND);
void OnSettings(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<HICON>(
LoadImage(hInstance, "APP_ICON", IMAGE_ICON,
GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CXICON), 0));
g_hIconSmall = static_cast<HICON>(
LoadImage(hInstance, "APP_ICON", IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON), 0));
// Enable common controls
INITCOMMONCONTROLSEX iccex;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccex.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&iccex);
// 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 IDCANCEL:
EndDialog(hDlg, FALSE);
return FALSE;
case IDC_GETSETTINGS:
OnSettings(hDlg);
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<LPARAM>(g_hIconSmall));
SendMessage(hDlg, WM_SETICON, TRUE, reinterpret_cast<LPARAM>(g_hIconLarge));
}
void OnSettings(HWND hDlg)
{
SetDlgItemText(hDlg, IDC_SETTINGS, "");
SHELLFLAGSTATE sfs;
SHGetSettings(&sfs, SSF_DESKTOPHTML | SSF_SHOWALLOBJECTS |
SSF_MAPNETDRVBUTTON | SSF_SHOWATTRIBCOL | SSF_SHOWEXTENSIONS);
TCHAR szBuf[MAX_PATH] = {0};
if(sfs.fDesktopHTML)
lstrcat(szBuf, __TEXT("Active Desktop - View as Web page is active\r\n"));
if(sfs.fMapNetDrvBtn)
lstrcat(szBuf, __TEXT("Network buttons on the toolbar\r\n"));
if(sfs.fShowAllObjects)
lstrcat(szBuf, __TEXT("Shows all files\r\n"));
if(sfs.fShowAttribCol)
lstrcat(szBuf, __TEXT("Shows attributes in Detail view\r\n"));
if(sfs.fShowExtensions)
lstrcat(szBuf, __TEXT("Shows extensions for known file types\r\n"));
SetDlgItemText(hDlg, IDC_SETTINGS, szBuf);
}
/* End of file: FoldFun.cpp */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -