📄 pgpoptionsdialog.cpp
字号:
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
cyChar = tm.tmHeight + tm.tmExternalLeading ;
MaxWidth = GetClientWidth(hwnd)-2*cyChar;
HeaderWidths=MeasureOptionsControls(hdc,options);
if(HeaderWidths>MaxWidth)MaxWidth=HeaderWidths;
ypos=cyChar;
CreateOptionsControls(hwnd,hdc,hFont,&ypos,MaxWidth,options);
ypos+=cyChar; // margin at bottom?
ReleaseDC(hwnd,hdc);
NUMLINES=ypos/cyChar;
return 0 ;
}
case WM_COMMAND:
{
HWND hwndItem;
hwndItem=(HWND)lParam;
if(hwndItem!=NULL)
{
DWORD *Data;
char WinClass[255];
Data=(DWORD *)GetWindowLong(hwndItem,GWL_USERDATA);
GetClassName(hwndItem,WinClass,255);
if(!strcmp(WinClass,"Button"))
{
*Data=!*Data;
Button_SetCheck(hwndItem,*Data);
}
if(!strcmp(WinClass,"ComboBox"))
{
if(HIWORD(wParam)==CBN_SELCHANGE)
{
*Data=SendMessage(hwndItem,CB_GETCURSEL,0,0)+1;
}
}
}
return 0;
}
case WM_SIZE :
{
int x,y;
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
iVscrollPos=iHscrollPos=0;
iVscrollMax = max (0, NUMLINES - cyClient/ cyChar) ;
x = min (iVscrollPos, iVscrollMax) ;
y = x - iVscrollPos;
ScrollWindow (hwnd, 0, -cyChar * y, NULL, NULL) ;
iVscrollPos=x;
SetScrollRange (hwnd, SB_VERT, 0, iVscrollMax, FALSE) ;
SetScrollPos (hwnd, SB_VERT, iVscrollPos, TRUE) ;
iHscrollMax = max (0, 2 + (MaxWidth + 2*cyChar - cxClient) /
cxChar) ;
x = min (iHscrollPos, iHscrollMax) ;
y = x - iHscrollPos;
ScrollWindow (hwnd, -cxChar * y, 0, NULL, NULL) ;
iHscrollPos=x;
SetScrollRange (hwnd, SB_HORZ, 0, iHscrollMax, FALSE) ;
SetScrollPos (hwnd, SB_HORZ, iHscrollPos, TRUE) ;
return 0 ;
}
case WM_VSCROLL :
{
switch (LOWORD (wParam))
{
case SB_TOP :
iVscrollInc = -iVscrollPos ;
break ;
case SB_BOTTOM :
iVscrollInc = iVscrollMax - iVscrollPos ;
break ;
case SB_LINEUP :
iVscrollInc = -1 ;
break ;
case SB_LINEDOWN :
iVscrollInc = 1 ;
break ;
case SB_PAGEUP :
iVscrollInc = min (-1, -cyClient / cyChar) ;
break ;
case SB_PAGEDOWN :
iVscrollInc = max (1, cyClient / cyChar) ;
break ;
case SB_THUMBTRACK :
iVscrollInc = HIWORD (wParam) - iVscrollPos ;
break ;
default :
iVscrollInc = 0 ;
}
iVscrollInc = max (-iVscrollPos,
min (iVscrollInc, iVscrollMax - iVscrollPos)) ;
if (iVscrollInc != 0)
{
iVscrollPos += iVscrollInc ;
ScrollWindow (hwnd, 0, -cyChar * iVscrollInc, NULL, NULL) ;
SetScrollPos (hwnd, SB_VERT, iVscrollPos, TRUE) ;
UpdateWindow (hwnd) ;
}
return 0 ;
}
case WM_HSCROLL :
{
switch (LOWORD (wParam))
{
case SB_LINEUP :
iHscrollInc = -1 ;
break ;
case SB_LINEDOWN :
iHscrollInc = 1 ;
break ;
case SB_PAGEUP :
iHscrollInc = -8 ;
break ;
case SB_PAGEDOWN :
iHscrollInc = 8 ;
break ;
case SB_THUMBPOSITION :
iHscrollInc = HIWORD (wParam) - iHscrollPos ;
break ;
default :
iHscrollInc = 0 ;
}
iHscrollInc = max (-iHscrollPos,
min (iHscrollInc, iHscrollMax - iHscrollPos)) ;
if (iHscrollInc != 0)
{
iHscrollPos += iHscrollInc ;
ScrollWindow (hwnd, -cxChar * iHscrollInc, 0, NULL, NULL) ;
SetScrollPos (hwnd, SB_HORZ, iHscrollPos, TRUE) ;
}
return 0 ;
}
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
HWND CreateOptionsControl(HWND hwndParent,
PGPOptionListRef options,
int x,int y,int dx,int dy)
{
static char szClassName[] = "CustomOptionsControl" ;
WNDCLASSEX wndclass ;
HWND hwndOptionsWindow;
wndclass.cbSize = sizeof (wndclass) ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = CustomOptionsWndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = g_hInst ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH)COLOR_WINDOW;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szClassName ;
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ;
RegisterClassEx (&wndclass) ;
hwndOptionsWindow = CreateWindowEx (WS_EX_CONTROLPARENT,szClassName,
"CustomOptionsWindow",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
WS_DLGFRAME | WS_TABSTOP,
x,y,
dx,dy,
hwndParent,NULL,g_hInst,(LPVOID)options) ;
return hwndOptionsWindow;
}
void MoveOptionsControl(HWND hDlg,HWND *hwndChild,
PGPOptionListRef options,
int x,int y,
int dx,int dy)
{
InvalidateRect(hwndChild,NULL,TRUE);
if(*hwndChild!=NULL)
DestroyWindow(*hwndChild);
*hwndChild=CreateOptionsControl(hDlg,
options,
x,y,
dx,dy);
}
void MoveOptionsDialog(HWND hDlg,HWND *hwndChild,
CPGPOptionsDialogOptions *options,
int cxClient,int cyClient)
{
MoveOptionsControl(hDlg,hwndChild,options->mClientOptions,
10,10,cxClient-20,cyClient-55);
InvalidateRect(GetDlgItem(hDlg, IDOK),NULL,TRUE);
MoveWindow(GetDlgItem(hDlg, IDOK),
cxClient-175,cyClient-35,
75,25,TRUE);
InvalidateRect(GetDlgItem(hDlg, IDCANCEL),NULL,TRUE);
MoveWindow(GetDlgItem(hDlg, IDCANCEL),
cxClient-85,cyClient-35,
75,25,TRUE);
}
BOOL CALLBACK
OptionsDialogProc (HWND hDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
static HWND hwndChild;
switch (uMsg)
{
case WM_INITDIALOG:
{
RECT rc;
CPGPOptionsDialogOptions *options;
options=(CPGPOptionsDialogOptions *)lParam;
SetWindowLong(hDlg,GWL_USERDATA,(long)options);
if(options->mPrompt!=NULL)
SetWindowText(hDlg,options->mPrompt);
GetClientRect(hDlg,&rc);
hwndChild=NULL;
MoveOptionsDialog(hDlg,&hwndChild,options,
rc.right-rc.left,
rc.bottom-rc.top);
return TRUE;
}
case WM_SIZE :
{
int cxClient, cyClient;
CPGPOptionsDialogOptions *options;
options=(CPGPOptionsDialogOptions *)
GetWindowLong(hDlg,GWL_USERDATA);
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
MoveOptionsDialog(hDlg,&hwndChild,options,
cxClient,
cyClient);
break ;
}
case WM_COMMAND:
{
switch(wParam)
{
case IDOK:
{
EndDialog(hDlg, TRUE);
break;
}
case IDCANCEL:
{
EndDialog(hDlg, FALSE);
break;
}
}
break;
}
case WM_QUIT:
case WM_CLOSE:
case WM_DESTROY :
{
EndDialog(hDlg, FALSE);
break ;
}
}
return FALSE;
}
#endif
PGPError
pgpOptionsDialogPlatform(
PGPContextRef context,
CPGPOptionsDialogOptions *options)
{
PGPError err = kPGPError_NoErr;
(void) context;
(void) options;
// InitRandomKeyHook(&hhookMouse,&hhookKeyboard);
//DialogBoxParam(g_hInst,
// MAKEINTRESOURCE(IDD_OPTIONSDIALOG),
// options->mHwndParent,
// (DLGPROC)OptionsDialogProc,
// (LPARAM)options);
//
// UninitRandomKeyHook(hhookMouse,hhookKeyboard);
return( err );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -