📄 scrolldlg.cpp
字号:
//======================================================================
// ScrollDlg - Scrollable dialog box window code
//
// Written for the book Programming Windows CE
// Copyright (C) 2007 Douglas Boling
//======================================================================
#include <windows.h> // For all that Windows stuff
#include <commctrl.h> // Common Control includes
#include <prsht.h> // Property sheet includes
#include "DlgDemo.h" // Program-specific stuff
// Structure labeling the button control WM_COMMAND notifications
NOTELABELS nlBtn[] = {{TEXT ("BN_CLICKED "), BN_CLICKED },
{TEXT ("BN_PAINT "), BN_PAINT },
{TEXT ("BN_SETFOCUS "), BN_SETFOCUS},
{TEXT ("BN_KILLFOCUS"), BN_KILLFOCUS}
};
// Scroll position of dialog
int nVPos = 0;
//======================================================================
// ScrollableDlgProc - Scrollable dialog box procedure
//
BOOL CALLBACK ScrollableDlgProc (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
switch (wMsg) {
case WM_INITDIALOG:
return TRUE;
//
// Reflect WM_COMMAND messages to main window.
//
case WM_COMMAND:
PrintCmdMessage (wParam, lParam, nlBtn, sizeof(nlBtn));
// Close dialog for OK or Cancel
switch (LOWORD (wParam)) {
case IDOK:
case IDCANCEL:
EndDialog (hWnd, 0);
return TRUE;
}
return TRUE;
//
// Reflect notify message.
//
case WM_NOTIFY:
PrintNotMessage (lParam, NULL, 0);
return FALSE; // Return false to force default processing.
case WM_VSCROLL:
{
int nNewPos = nVPos;
int nLinesPerPage = 5;
switch (LOWORD (wParam)) {
case SB_LINEUP:
nNewPos -= 1;
break;
case SB_LINEDOWN:
nNewPos += 1;
break;
case SB_PAGEUP:
nNewPos -= nLinesPerPage;
break;
case SB_PAGEDOWN:
nNewPos += nLinesPerPage;
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
nNewPos = HIWORD (wParam);
break;
}
// If scroll position changed, Scroll the window and
// update scrollbar
if (nVPos != nNewPos) {
ScrollWindowEx (hWnd, 0, nVPos - nNewPos, NULL, NULL,
NULL, NULL, SW_INVALIDATE | SW_SCROLLCHILDREN);
SCROLLINFO si;
nVPos = nNewPos;
si.cbSize = sizeof (si);
si.nPos = nVPos;
si.fMask = SIF_POS;
SetScrollInfo (hWnd, SB_VERT, &si, TRUE);
}
}
break;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -