?? scrolldlg.c
字號:
//======================================================================
// ScrollDlg - Scroll bar dialog box window code
//
// Written for the book Programming Windows CE
// Copyright (C) 1998 Douglas Boling
//======================================================================
#include <windows.h> // For all that Windows stuff
#include <prsht.h> // Property sheet includes
#include "DlgDemo.h" // Program-specific stuff
extern HINSTANCE hInst;
//----------------------------------------------------------------------
// Global data
//
// Identification strings for various WM_xSCROLL notifications
NOTELABELS nlVScroll[] = {{TEXT ("SB_LINEUP "), 0},
{TEXT ("SB_LINEDOWN "), 1},
{TEXT ("SB_PAGEUP "), 2},
{TEXT ("SB_PAGEDOWN "), 3},
{TEXT ("SB_THUMBPOSITION"), 4},
{TEXT ("SB_THUMBTRACK "), 5},
{TEXT ("SB_TOP "), 6},
{TEXT ("SB_BOTTOM "), 7},
{TEXT ("SB_ENDSCROLL "), 8},
};
NOTELABELS nlHScroll[] = {{TEXT ("SB_LINELEFT "), 0},
{TEXT ("SB_LINERIGHT "), 1},
{TEXT ("SB_PAGELEFT "), 2},
{TEXT ("SB_PAGERIGHT "), 3},
{TEXT ("SB_THUMBPOSITION"), 4},
{TEXT ("SB_THUMBTRACK "), 5},
{TEXT ("SB_LEFT "), 6},
{TEXT ("SB_RIGHT "), 7},
{TEXT ("SB_ENDSCROLL "), 8},
};
extern NOTELABELS nlPropPage[];
extern int nPropPageSize;
//======================================================================
// EditDlgProc - Button page dialog box procedure
//
BOOL CALLBACK ScrollDlgProc (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
TCHAR szOut[128];
SCROLLINFO si;
HWND hwndMain;
INT i, sPos;
switch (wMsg) {
case WM_INITDIALOG:
// The generic parameter contains
// the top-level window handle.
hwndMain = (HWND)((LPPROPSHEETPAGE)lParam)->lParam;
// Save the window handle in the window structure.
SetWindowLong (hWnd, DWL_USER, (LONG)hwndMain);
return TRUE;
//
// Reflect WM_COMMAND messages to main window.
//
case WM_VSCROLL:
case WM_HSCROLL:
// Get the handle of the main window from the user word.
hwndMain = (HWND) GetWindowLong (hWnd, DWL_USER);
// Update the report window.
// Determine whether from horizontal or vertical scroll bar.
if (GetDlgItem (hWnd, 101) == (HWND)lParam) {
for (i = 0; i < dim(nlVScroll); i++) {
if (LOWORD (wParam) == nlVScroll[i].wNotification) {
lstrcpy (szOut, nlVScroll[i].pszLabel);
break;
}
}
if (i == dim(nlVScroll))
wsprintf (szOut, TEXT ("notification: %x"),
HIWORD (wParam));
} else {
for (i = 0; i < dim(nlHScroll); i++) {
if (LOWORD (wParam) == nlHScroll[i].wNotification) {
lstrcpy (szOut, nlHScroll[i].pszLabel);
break;
}
}
if (i == dim(nlHScroll))
wsprintf (szOut, TEXT ("notification: %x"),
HIWORD (wParam));
}
SendMessage (hwndMain, MYMSG_ADDLINE,
MAKEWPARAM (-1, ID_SCROLLPAGE), (LPARAM)szOut);
// Get scroll bar position.
si.cbSize = sizeof (si);
si.fMask = SIF_POS;
GetScrollInfo ((HWND)lParam, SB_CTL, &si);
sPos = si.nPos;
// Act on the scroll code.
switch (LOWORD (wParam)) {
case SB_LINEUP: // Also SB_LINELEFT
sPos -= 2;
break;
case SB_LINEDOWN: // Also SB_LINERIGHT
sPos += 2;
break;
case SB_PAGEUP: // Also SB_PAGELEFT
sPos -= 10;
break;
case SB_PAGEDOWN: // Also SB_PAGERIGHT
sPos += 10;
break;
case SB_THUMBPOSITION:
sPos = HIWORD (wParam);
break;
}
// Check range.
if (sPos < 0)
sPos = 0;
if (sPos > 100)
sPos = 100;
// Update scrollbar position.
si.cbSize = sizeof (si);
si.nPos = sPos;
si.fMask = SIF_POS;
SetScrollInfo ((HWND)lParam, SB_CTL, &si, TRUE);
return TRUE;
//
// Reflect notify message.
//
case WM_NOTIFY:
// Get the handle of the main window from the user word.
hwndMain = (HWND) GetWindowLong (hWnd, DWL_USER);
// Look up notify message.
for (i = 0; i < nPropPageSize; i++) {
if (((NMHDR *)lParam)->code ==
nlPropPage[i].wNotification) {
lstrcpy (szOut, nlPropPage[i].pszLabel);
break;
}
}
if (i == nPropPageSize)
wsprintf (szOut, TEXT ("Notify code:%d"),
((NMHDR *)lParam)->code);
SendMessage (hwndMain, MYMSG_ADDLINE,
MAKEWPARAM (-1, ID_SCROLLPAGE), (LPARAM)szOut);
return FALSE; // Return false to force default processing.
}
return FALSE;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -