?? statwnd.c
字號:
//======================================================================
// StatWnd - Static control window code
//
// Written for the book Programming Windows CE
// Copyright (C) 1998 Douglas Boling
//======================================================================
#include <windows.h> // For all that Windows stuff
#include "Ctlview.h" // Program-specific stuff
extern HINSTANCE hInst;
//----------------------------------------------------------------------
// Global data
//
// Message dispatch table for StatWndWindowProc
const struct decodeUINT StatWndMessages[] = {
WM_CREATE, DoCreateStatWnd,
WM_COMMAND, DoCommandStatWnd,
};
// Structure defining the controls in the window
CTLWNDSTRUCT Stats [] = {
{TEXT ("static"), IDC_LEFTTEXT, TEXT ("Left text"),
10, 10, 120, 23, SS_LEFT | SS_NOTIFY},
{TEXT ("static"), IDC_RIGHTTEXT, TEXT ("Right text"),
10, 35, 120, 23, SS_RIGHT},
{TEXT ("static"), IDC_CENTERTEXT, TEXT ("Center text"),
10, 60, 120, 23, SS_CENTER | WS_BORDER},
{TEXT ("static"), IDC_ICONCTL, TEXT ("TEXTICON"),
10, 85, 120, 23, SS_ICON},
{TEXT ("static"), IDC_BITMAPCTL, TEXT ("STATICBMP"),
170, 10, 44, 44, SS_BITMAP | SS_NOTIFY},
};
// Structure labeling the static control WM_COMMAND notifications
NOTELABELS nlStatic[] = {{TEXT ("STN_CLICKED"), 0},
{TEXT ("STN_ENABLE "), 2},
{TEXT ("STN_DISABLE"), 3},
};
//----------------------------------------------------------------------
// InitStatWnd - StatWnd window initialization
//
int InitStatWnd (HINSTANCE hInstance) {
WNDCLASS wc;
// Register application StatWnd window class.
wc.style = 0; // Window style
wc.lpfnWndProc = StatWndProc; // Callback function
wc.cbClsExtra = 0; // Extra class data
wc.cbWndExtra = 0; // Extra window data
wc.hInstance = hInstance; // Owner handle
wc.hIcon = NULL, // Application icon
wc.hCursor = NULL; // Default cursor
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wc.lpszMenuName = NULL; // Menu name
wc.lpszClassName = STATWND; // Window class name
if (RegisterClass (&wc) == 0) return 1;
return 0;
}
//======================================================================
// Message handling procedures for StatWindow
//----------------------------------------------------------------------
// StatWndProc - Callback function for application window
//
LRESULT CALLBACK StatWndProc (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
INT i;
//
// Search message list to see if we need to handle this
// message. If in list, call procedure.
//
for (i = 0; i < dim(StatWndMessages); i++) {
if (wMsg == StatWndMessages[i].Code)
return (*StatWndMessages[i].Fxn)(hWnd, wMsg, wParam, lParam);
}
return DefWindowProc (hWnd, wMsg, wParam, lParam);
}
//----------------------------------------------------------------------
// DoCreateStatWnd - Process WM_CREATE message for window.
//
LRESULT DoCreateStatWnd (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
INT i;
for (i = 0; i < dim(Stats); i++) {
CreateWindow (Stats[i].szClass, Stats[i].szTitle,
Stats[i].lStyle | WS_VISIBLE | WS_CHILD,
Stats[i].x, Stats[i].y, Stats[i].cx, Stats[i].cy,
hWnd, (HMENU) Stats[i].nID, hInst, NULL);
}
return 0;
}
//----------------------------------------------------------------------
// DoCommandStatWnd - Process WM_COMMAND message for window.
//
LRESULT DoCommandStatWnd (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
TCHAR szOut[128];
INT i;
for (i = 0; i < dim(nlStatic); i++) {
if (HIWORD (wParam) == nlStatic[i].wNotification) {
lstrcpy (szOut, nlStatic[i].pszLabel);
break;
}
}
if (i == dim(nlStatic))
wsprintf (szOut, TEXT ("notification: %x"), HIWORD (wParam));
SendMessage (GetParent (hWnd), MYMSG_ADDLINE, wParam,
(LPARAM)szOut);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -