?? editwnd.c
字號:
//======================================================================
// EditWnd - Edit 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 EditWndWindowProc
const struct decodeUINT EditWndMessages[] = {
WM_CREATE, DoCreateEditWnd,
WM_COMMAND, DoCommandEditWnd,
};
// Structure defining the controls in the window
CTLWNDSTRUCT Edits[] = {
{TEXT ("edit"), IDC_SINGLELINE, TEXT ("Single line edit control"),
10, 10, 130, 23, ES_AUTOHSCROLL},
{TEXT ("edit"), IDC_MULTILINE, TEXT ("Multi line edit control"),
10, 35, 130, 90, ES_MULTILINE | ES_AUTOVSCROLL},
{TEXT ("edit"), IDC_PASSBOX, TEXT (""),
10, 127, 130, 23, ES_PASSWORD},
};
// Structure labeling the edit control WM_COMMAND notifications
NOTELABELS nlEdit[] = {{TEXT ("EN_SETFOCUS "), 0x0100},
{TEXT ("EN_KILLFOCUS"), 0x0200},
{TEXT ("EN_CHANGE "), 0x0300},
{TEXT ("EN_UPDATE "), 0x0400},
{TEXT ("EN_ERRSPACE "), 0x0500},
{TEXT ("EN_MAXTEXT "), 0x0501},
{TEXT ("EN_HSCROLL "), 0x0601},
{TEXT ("EN_VSCROLL "), 0x0602},
};
//----------------------------------------------------------------------
// InitEditWnd - EditWnd window initialization
//
int InitEditWnd (HINSTANCE hInstance) {
WNDCLASS wc;
// Register application EditWnd window class.
wc.style = 0; // Window style
wc.lpfnWndProc = EditWndProc; // 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 = EDITWND; // Window class name
if (RegisterClass (&wc) == 0) return 1;
return 0;
}
//======================================================================
// Message handling procedures for EditWindow
//----------------------------------------------------------------------
// EditWndWndProc - Callback function for application window
//
LRESULT CALLBACK EditWndProc (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(EditWndMessages); i++) {
if (wMsg == EditWndMessages[i].Code)
return (*EditWndMessages[i].Fxn)(hWnd, wMsg, wParam, lParam);
}
return DefWindowProc (hWnd, wMsg, wParam, lParam);
}
//----------------------------------------------------------------------
// DoCreateEditWnd - Process WM_CREATE message for window.
//
LRESULT DoCreateEditWnd (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
INT i;
for (i = 0; i < dim(Edits); i++) {
CreateWindow (Edits[i].szClass, Edits[i].szTitle,
Edits[i].lStyle | WS_VISIBLE | WS_CHILD | WS_BORDER,
Edits[i].x, Edits[i].y, Edits[i].cx, Edits[i].cy,
hWnd, (HMENU) Edits[i].nID, hInst, NULL);
}
return 0;
}
//----------------------------------------------------------------------
// DoCommandEditWnd - Process WM_COMMAND message for window.
//
LRESULT DoCommandEditWnd (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
TCHAR szOut[128];
INT i;
for (i = 0; i < dim(nlEdit); i++) {
if (HIWORD (wParam) == nlEdit[i].wNotification) {
lstrcpy (szOut, nlEdit[i].pszLabel);
break;
}
}
if (i == dim(nlEdit))
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 + -