Archive for 十二月 16th, 2003


栏目说明

栏目介绍

栏目介绍

栏目介绍

栏目介绍

栏目介绍

栏目介绍

本栏目介绍

.

WINDOWS消息

Programming Windows 笔记及相关的MSDN摘录


LRESULT SendMessage(
  HWND hWnd,      // handle to destination window
  UINT Msg,       // message
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);


窗口创建
WM_CREATE
/*————–注释 end———–*/
TEXTMETRIC tm;
hdc = GetDC(hwnd);
GetTextMetrics(hdc, &tm);
cxChar = tm.tmAveCharWidth;
cxCaps = (tm.tmPitchAndFamily & 1? 3:2)*cxChar/2;
cyChar = tm.tmHeight + tm.tmExternalLeading;
ReleaseDC(hwnd, hdc);


or


cxChar = LOWORD(GetDialogBaseUnits());
cyChar = HIWORD(GetDialogBaseUnits());


hInstance的取得
((LPCREATESTRUCT)lParam)->hInstance


or


(HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);


有用的函数:
LONG SetWindowLong(
  HWND hWnd,       // handle to window
  int nIndex,      // offset of value to set
  LONG dwNewLong   // new value
);
LONG GetWindowLong(
  HWND hWnd,  // handle to window
  int nIndex  // offset of value to retrieve
);
GWL_EXSTYLE Sets a new extended window style. For more information, see CreateWindowEx. 
GWL_STYLE Sets a new window style.
GWL_WNDPROC Sets a new address for the window procedure. Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.
GWL_HINSTANCE Sets a new application instance handle. GWL_ID Sets a new identifier of the window.
GWL_USERDATA Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.


The following values are also available when the hWnd parameter identifies a dialog box.


DWL_DLGPROC Sets the new address of the dialog box procedure.
DWL_MSGRESULT Sets the return value of a message processed in the dialog box procedure.
DWL_USER Sets new extra information that is private to the application, such as handles or pointers.


DWORD SetClassLong(
  HWND hWnd,       // handle to window
  int nIndex,      // index of value to change
  LONG dwNewLong   // new value
);
DWORD GetClassLong(
  HWND hWnd,  // handle to window
  int nIndex  // offset of value to retrieve
);
GCW_ATOM  Retrieves an ATOM value that uniquely identifies the window class. This is the same atom that the RegisterClassEx function returns.
GCL_CBCLSEXTRA  Retrieves the size, in bytes, of the extra memory associated with the class.
GCL_CBWNDEXTRA  Retrieves the size, in bytes, of the extra window memory associated with each window in the class. For information on how to access this memory, see GetWindowLong.
GCL_HBRBACKGROUND Retrieves a handle to the background brush associated with the class.
GCL_HCURSOR  Retrieves a handle to the cursor associated with the class.
GCL_HICON  Retrieves a handle to the icon associated with the class.
GCL_HICONSM  Retrieves a handle to the small icon associated with the class.
GCL_HMODULE  Retrieves a handle to the module that registered the class.
GCL_MENUNAME  Retrieves the address of the menu name string. The string identifies the menu resource associated with the class.
GCL_STYLE  Retrieves the window-class style bits.
GCL_WNDPROC  Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. 


/*————–注释—————*/


窗口绘制
WM_PAINT


窗口销毁
WM_DESTROY



/*————–注释 end———–*/
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
or
hdc = GetDC(hwnd);
ReleaseDC(hwnd, hdc);
写文本
TextOut(hdc, x, y, psText, iLength);
int DrawText(
  HDC hDC,          // handle to DC
  LPCTSTR lpString, // text to draw
  int nCount,       // text length
  LPRECT lpRect,    // formatting dimensions
  UINT uFormat      // text-drawing options
);
更新/失效
BOOL InvalidateRect(
  HWND hWnd,           // handle to window
  CONST RECT* lpRect,  // rectangle coordinates
  BOOL bErase          // erase state
);
BOOL UpdateWindow(
  HWND hWnd   // handle to window
);
/*————–注释—————*/


窗口大小更改
WM_SIZE
/*————–注释 end———–*/
wParam
SIZE_MAXHIDE Message is sent to all pop-up windows when some other window is maximized.
SIZE_MAXIMIZED The window has been maximized.
SIZE_MAXSHOW Message is sent to all pop-up windows when some other window has been restored to its former size.
SIZE_MINIMIZED The window has been minimized.
SIZE_RESTORED The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.


cxClient = LOWORD(lParam);
cyClient = HIWORD(wParam);


BOOL MoveWindow(
  HWND hWnd,      // handle to window
  int X,          // horizontal position
  int Y,          // vertical position
  int nWidth,     // width
  int nHeight,    // height
  BOOL bRepaint   // repaint option
);
/*————–注释—————*/


滚动事件
WM_VSCROLL
WM_HSCROLL
/*————–注释 end———–*/
LOWORD(wParam)
SB_BOTTOM  Scrolls to the lower right.
SB_ENDSCROLL  Ends scroll.
SB_LINEDOWN  Scrolls one line down.
SB_LINEUP  Scrolls one line up.
SB_PAGEDOWN  Scrolls one page down.
SB_PAGEUP  Scrolls one page up.
SB_LEFT   Scrolls to the upper left.
SB_RIGHT  Scrolls to the lower right.
SB_LINELEFT  Scrolls left by one unit.
SB_LINERIGHT  Scrolls right by one unit.
SB_PAGELEFT  Scrolls left by the width of the window.
SB_PAGERIGHT  Scrolls right by the width of the window.
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK  The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to.
SB_TOP   Scrolls to the upper left.


BOOL SetScrollRange(
  HWND hWnd,    // handle to window
  int nBar,     // scroll bar
  int nMinPos,  // minimum scrolling position
  int nMaxPos,  // maximum scrolling position
  BOOL bRedraw  // redraw flag
);


int SetScrollPos(
  HWND hWnd,     // handle to window
  int nBar,      // scroll bar
  int nPos,      // new position of scroll box
  BOOL bRedraw   // redraw flag
);


SB_CTL Sets the position of the scroll box in a scroll bar control. The hWnd parameter must be the handle to the scroll bar control.
SB_HORZ Sets the position of the scroll box in a window’s standard horizontal scroll bar.
SB_VERT Sets the position of the scroll box in a window’s standard vertical scroll bar.


int SetScrollInfo(
  HWND hwnd,           // handle to window
  int fnBar,           // scroll bar type
  LPCSCROLLINFO lpsi,  // scroll parameters
  BOOL fRedraw         // redraw flag
);
SIF_DISABLENOSCROLL Disables the scroll bar instead of removing it, if the scroll bar’s new parameters make the scroll bar unnecessary.
SIF_PAGE  Sets the scroll page to the value specified in the nPage member of the SCROLLINFO structure pointed to by lpsi.
SIF_POS   Sets the scroll position to the value specified in the nPos member of the SCROLLINFO structure pointed to by lpsi.
SIF_RANGE  Sets the scroll range to the value specified in the nMin and nMax members of the SCROLLINFO structure pointed to by lpsi.
/*————–注释—————*/



键盘
WM_ACTIVATE
WM_APPCOMMAND
WM_CHAR
WM_DEADCHAR
WM_GETHOTKEY
WM_HOTKEY
WM_KEYDOWN
WM_KEYUP
WM_KILLFOCUS
WM_SETFOCUS
WM_SETHOTKEY
WM_SYSCHAR
WM_SYSDEADCHAR
WM_SYSKEYDOWN
WM_SYSKEYUP
WM_UNICHAR
/*————–注释—————*/
wParam 虚拟键值
int GetKeyNameText(
  LONG lParam,      // second parameter of keyboard message
  LPTSTR lpString,  // buffer for key name
  int nSize         // maximum length of key name
);
/*————–注释 end———–*/


鼠标
左键
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBCLK
中键
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBCLK
右键
WM_RBUTTONDOWN
WM_RBUTTONUP
WM_RBUTTONDBCLK
移动
WM_MOUSEMOVE
非客户区左键
WM_NCLBUTTONDOWN
WM_NCLBUTTONUP
WM_NCLBUTTONDBCLK
非客户区中键
WM_NCMBUTTONDOWN
WM_NCMBUTTONUP
WM_NCMBUTTONDBCLK
非客户区右键
WM_NCRBUTTONDOWN
WM_NCRBUTTONUP
WM_NCRBUTTONDBCLK
鼠标滚轮
WM_MOUSEWHEEL
/*————–注释—————*/
x坐标 = LOWORD(lParam)
y坐标 = HIWORD(lParam)
wParam说明
MK_LBUTTON
MK_MBUTTON
MK_RBUTTON
MK_SHIFT
MK_CONTROL
判断是否按下shift
wParam & MK_SHIFT
屏幕坐标转换成客户坐标
ScreenToClient(hwnd, &pt)
客户坐标转换成屏幕坐标
ClientToScreen(hwnd, &pt)
/*————–注释 end———–*/
非客户区命中测试
WM_NCHITTEST
/*————–注释—————*/
与wParam组合
HTCLIENT 客户区 
HTNOWHERE 不在窗口
HTTRANSPARENT 窗口由另一窗口覆盖
HTERROR  使DefWindowProc产生蜂鸣


ex:
// 禁止窗口客户区和非客户区的鼠标消息
case WM_NCHITTEST
 return (LRESULT)HTNOWHERE


HWND SetCapture(
  HWND hWnd   // handle to window
);
BOOL ReleaseCapture(VOID);
/*————–注释 end———–*/


计时器事件
WM_TIMER
/*————–注释—————*/
方法一
建立计时器
UINT_PTR SetTimer(
  HWND hWnd,              // handle to window
  UINT_PTR nIDEvent,      // timer identifier ! wParam 计时器系统ID
  UINT uElapse,           // time-out value
  TIMERPROC lpTimerFunc   // timer procedure ! 回调函数指针,NULL值时使用WinProc消息处理
);
销毁计时器
BOOL KillTimer(
  HWND hWnd,          // handle to window
  UINT_PTR uIDEvent   // timer identifier ! wParam 计时器系统ID
);
方法二
VOID CALLBACK TimerProc(
  HWND hwnd,         // handle to window
  UINT uMsg,         // always WM_TIMER message!!!
  UINT_PTR idEvent,  // timer identifier
  DWORD dwTime       // current system time
);
方法三:
SetTimer(NULL, 0, wMsecInterval, TimeProc);
KillTimer(NULL, 0);
有一系列不同计时间隔的计时器,并不期望对每个计时器跟踪可以使用这种方法。
/*————–注释 end———–*/


子窗口事件
WM_COMMAND
/*————–注释—————*/
LOWORD(wParam) 子窗口ID
HIWORD(wParam) 通知码 If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.
lParam  子窗口句柄


BS_PUSHBUTTON
BS_DEFPUSHBUTTON
SendMessage(hwndButton, BM_SETSTATE, 1, 0); // 按下按钮
SendMessage(hwndButton, BM_SETSTATE, 0, 0); // 按钮恢复


BS_CHECKBOX
BS_AUTOCHECKBOX
BS_3STATE
BS_AUTO3STATE
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)!SendMessage((HWND)lParam, BM_GETCHECK, 0, 0)); // check状态转换


BS_RADIOBUTTON
BS_AUTORADIOBUTTON
SendMessage(hwndButton, BM_SETCHECK, 1, 0); // radio选取状
SendMessage(hwndButton, BM_SETCHECK, 0, 0); // radio未选取状


BS_GROUPBOX


SetWindowText(hwnd, pszString);   // 更改按钮文本
GetWindowText(hwnd, pszBuffer, iMaxLength); // 获得按钮文本


ShowWindow(hwnd, SW_SHOWNORMAL);  // 显示控件
ShowWindow(hwnd, SW_HIDE);   // 隐藏控件
EnableWindow(hwnd, FALSE);   // 使控件无效
IsWindowEnabled(hwnd);    // 判断控件是否有效


SetFocus(hwnd);     // 设置焦点


SetBkColor(hdc, GetSysColor(XXX));
SetTextColor(hdc, GetSysColor(XXX));


按钮控件属性(Button Styles)
BS_3STATE  Same as a check box, except that the box can be dimmed as well as checked. The dimmed state typically is used to show that a check box has been disabled.
BS_AUTO3STATE  Same as a three-state check box, except that the box changes its state when the user selects it.
BS_AUTOCHECKBOX  Same as a check box, except that a check mark appears in the check box when the user selects the box; the check mark disappears the next time the user selects the box.
BS_AUTORADIOBUTTON Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group.
BS_BITMAP  Specifies that the button displays a bitmap.
BS_BOTTOM  Places text at the bottom of the button rectangle.
BS_CENTER  Centers text horizontally in the button rectangle.
BS_CHECKBOX  Creates a small square that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style).
BS_DEFPUSHBUTTON Creates a button that has a heavy black border. The user can select this button by pressing the ENTER key. This style enables the user to quickly select the most likely option (the default option).
BS_FLAT   Specifies that the button is two-dimensional; it does not use the default shading to create a 3-D image.
BS_GROUPBOX  Creates a rectangle in which other buttons can be grouped. Any text associated with this style is displayed in the rectangle’s upper-left corner.
BS_ICON   Specifies that the button displays an icon.
BS_LEFT   Left aligns the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is left aligned on the right side of the check box or radio button.
BS_LEFTTEXT  When combined with a radio-button or check-box style, the text appears on the left side of the radio button or check box.
BS_MULTILINE  Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
BS_NOTIFY  Enables a button to send BN_DBLCLK, BN_KILLFOCUS, and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether it has this style.
BS_OWNERDRAW  Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.
BS_PUSHBUTTON  Creates a pushbutton that posts a WM_COMMAND message to the owner window when the user selects the button.
BS_PUSHLIKE  Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn’t pushed or checked, and sunken when it is pushed or checked.
BS_RADIOBUTTON  Creates a small circle that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style). Radio buttons are usually used in groups of related, but mutually exclusive, choices.
BS_RIGHT  Right aligns the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is right aligned on the right side of the check box or radio button.
BS_RIGHTBUTTON  Positions a radio button’s circle or a check box’s square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.
BS_TEXT   Specifies that the button displays text.
BS_TOP   Places text at the top of the button rectangle.
BS_USERBUTTON  Obsolete, but provided for compatibility with 16-bit versions of Windows. Win32-based applications should use BS_OWNERDRAW instead.
BS_VCENTER  Places text in the middle (vertically) of the button rectangle.


静态控件属性(Static Styles)
SS_BITMAP Specifies a bitmap is to be displayed in the static control. The given text is the name of a bitmap (not a filename) defined elsewhere in the resource file. The style ignores the nWidth and nHeight parameters; the control automatically sizes itself to accommodate the bitmap.
SS_BLACKFRAME   Specifies a box with a frame drawn with the same color as window frames. The default is black.
SS_BLACKRECT Specifies a rectangle filled with the color used to draw window frames. The default is black.
SS_CENTER Designates a simple rectangle and displays the given text centered in the rectangle. The text is formatted before it is displayed. Words that would extend past the end of a line are automatically wrapped to the beginning of the next centered line.
SS_CENTERIMAGE  Specifies that, if the bitmap or icon is smaller than the client area of the static control, the rest of the client area is filled with the color of the pixel in the top left corner of the bitmap or icon. If the static control contains a single line of text, the text is centered vertically in the client area of the control.
SS_ENDELLIPSIS or SS_PATHELLIPSIS   Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle. You can specify SS_END_ELLIPSIS to replace characters at the end of the string, or SS_PATHELLIPSIS to replace characters in the middle of the string. If the string contains backslash (\) characters, SS_PATHELLIPSIS preserves as much of the text after the last backslash as possible.
SS_ENHMETAFILE  Specifies an enhanced metafile is to be displayed in the static control. The given text is the name of a metafile. An enhanced metafile static control has a fixed size; the metafile is scaled to fit the static control’s client area.
SS_ETCHEDFRAME  Draws the frame of the static control using the EDGE_ETCHED edge style.
SS_ETCHEDHORZ Draws the top and bottom edges of the static control using the EDGE_ETCHED edge style.
SS_ETCHEDVERT Draws the left and right edges of the static control using the EDGE_ETCHED edge style.
SS_GRAYFRAME Specifies a box with a frame drawn with the same color as the screen background (desktop). The default is gray.
SS_GRAYRECT Specifies a rectangle filled with the color used to fill the screen background. The default is gray.
SS_ICON  Designates an icon displayed in the dialog box. The given text is the name of an icon (not a filename) defined elsewhere in the resource file. The nWidth and nHeight parameters are ignored; the icon automatically sizes itself.
SS_LEFT  Designates a simple rectangle and displays the given text flush-left in the rectangle. The text is formatted before it is displayed. Words that would extend past the end of a line are automatically wrapped to the beginning of the next flush-left line.
SS_LEFTNOWORDWRAP   Designates a simple rectangle and displays the given text flush-left in the rectangle. Tabs are expanded, but words are not wrapped. Text that extends past the end of a line is clipped.
SS_NOPREFIX Unless this style is specified, Windows will interpret any ampersand (&) characters in the control’s text to be accelerator prefix characters. In this case, the ampersand is removed and the next character in the string is underlined. If a static control is to contain text where this feature is not wanted, SS_NOPREFIX may be added. This static-control style may be included with any of the defined static controls. You can combine SS_NOPREFIX with other styles by using the bitwise OR operator. This is most often used when filenames or other strings that may contain an ampersand need to be displayed in a static control in a dialog box.
SS_NOTIFY Sends the parent window STN_CLICKED, STN_DBLCLK, STN_DISABLE, and STN_ENABLE notification messages when the user clicks or double-clicks the control.
SS_OWNERDRAW Specifies that the owner of the static control is responsible for drawing the control. The owner window receives a WM_DRAWITEM message whenever the control needs to be drawn.
SS_REALSIZEIMAGE   Prevents a static icon or bitmap control (that is, static controls that have the SS_ICON or SS_BITMAP style) from being resized as it is loaded or drawn. If the icon or bitmap is larger than the destination area, the image is clipped.
SS_RIGHT Designates a simple rectangle and displays the given text flush-right in the rectangle. The text is formatted before it is displayed. Words that would extend past the end of a line are automatically wrapped to the beginning of the next flush-right line.
SS_RIGHTJUST Specifies that the lower right corner of a static control with the SS_BITMAP or SS_ICON style is to remain fixed when the control is resized. Only the top and left sides are adjusted to accommodate a new bitmap or icon.
SS_SIMPLE Designates a simple rectangle and displays a single line of text flush-left in the rectangle. The line of text cannot be shortened or altered in any way. (The control’s parent window or dialog box must not process the WM_CTLCOLOR message.)
SS_SUNKEN Draws a half-sunken border around a static control.
SS_USERITEM Specifies a user-defined item.
SS_WHITEFRAME   Specifies a box with a frame drawn with the same color as the window background. The default is white.
SS_WHITERECT Specifies a rectangle filled with the color used to fill the window background. The default is white.
SS_WORDELLIPSIS   Truncates text that does not fit and adds ellipses.


滚动条属性(Scroll-bar Styles)
SBS_BOTTOMALIGN   Used with the SBS_HORZ style. The bottom edge of the scroll bar is aligned with the bottom edge of the rectangle specified in the Create member function. The scroll bar has the default height for system scroll bars.
SBS_HORZ   Designates a horizontal scroll bar. If neither the SBS_BOTTOMALIGN nor SBS_TOPALIGN style is specified, the scroll bar has the height, width, and position given in the Create member function.
SBS_LEFTALIGN   Used with the SBS_VERT style. The left edge of the scroll bar is aligned with the left edge of the rectangle specified in the Create member function. The scroll bar has the default width for system scroll bars.
SBS_RIGHTALIGN   Used with the SBS_VERT style. The right edge of the scroll bar is aligned with the right edge of the rectangle specified in the Create member function. The scroll bar has the default width for system scroll bars.
SBS_SIZEBOX   Designates a size box. If neither the SBS_SIZEBOXBOTTOMRIGHTALIGN nor SBS_SIZEBOXTOPLEFTALIGN style is specified, the size box has the height, width, and position given in the Create member function.
SBS_SIZEBOXBOTTOMRIGHTALIGN Used with the SBS_SIZEBOX style. The lower-right corner of the size box is aligned with the lower-right corner of the rectangle specified in the Create member function. The size box has the default size for system size boxes.
SBS_SIZEBOXTOPLEFTALIGN  Used with the SBS_SIZEBOX style. The upper-left corner of the size box is aligned with the upper-left corner of the rectangle specified in the Create member function. The size box has the default size for system size boxes.
SBS_SIZEGRIP   Same as SBS_SIZEBOX, but with a raised edge.
SBS_TOPALIGN   Used with the SBS_HORZ style. The top edge of the scroll bar is aligned with the top edge of the rectangle specified in the Create member function. The scroll bar has the default height for system scroll bars.
SBS_VERT   Designates a vertical scroll bar. If neither the SBS_RIGHTALIGN nor SBS_LEFTALIGN style is specified, the scroll bar has the height, width, and position given in the Create member function.


编辑框属性(Edit Styles)
ES_AUTOHSCROLL  Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to position 0.
ES_AUTOVSCROLL  Automatically scrolls text up one page when the user presses ENTER on the last line.
ES_CENTER  Centers text in a single-line or multiline edit control.
ES_LEFT   Left-aligns text in a single-line or multiline edit control.
ES_LOWERCASE  Converts all characters to lowercase as they are typed into the edit control.
ES_MULTILINE  Designates a multiple-line edit control. (The default is single line.) If the ES_AUTOVSCROLL style is specified, the edit control shows as many lines as possible and scrolls vertically when the user presses the ENTER key. If ES_AUTOVSCROLL is not given, the edit control shows as many lines as possible and beeps if ENTER is pressed when no more lines can be displayed. If the ES_AUTOHSCROLL style is specified, the multiple-line edit control automatically scrolls horizontally when the caret goes past the right edge of the control. To start a new line, the user must press ENTER. If ES_AUTOHSCROLL is not given, the control automatically wraps words to the beginning of the next line when necessary; a new line is also started if ENTER is pressed. The position of the wordwrap is determined by the window size. If the window size changes, the wordwrap position changes and the text is redisplayed. Multiple-line edit controls can have scroll bars. An edit control with scroll bars processes its own scroll-bar messages. Edit controls without scroll bars scroll as described above and process any scroll messages sent by the parent window.
ES_NOHIDESEL  Normally, an edit control hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. Specifying ES_NOHIDESEL deletes this default action.
ES_NUMBER  Allows only digits to be entered into the edit control.
ES_OEMCONVERT  Text entered in the edit control is converted from the ANSI character set to the OEM character set and then back to ANSI. This ensures proper character conversion when the application calls the AnsiToOem Windows function to convert an ANSI string in the edit control to OEM characters. This style is most useful for edit controls that contain filenames.
ES_PASSWORD  Displays all characters as an asterisk (*) as they are typed into the edit control. An application can use the SetPasswordChar member function to change the character that is displayed.
ES_READONLY  Prevents the user from entering or editing text in the edit control.
ES_RIGHT  Right-aligns text in a single-line or multiline edit control.
ES_UPPERCASE  Converts all characters to uppercase as they are typed into the edit control.
ES_WANTRETURN  Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiple-line edit control in a dialog box. Without this style, pressing the ENTER key has the same effect as pressing the dialog box’s default pushbutton. This style has no effect on a single-line edit control.



/*————–注释 end———–*/


系统颜色改变
WM_SYSCOLORCHANGE


WM_DRAWITEM
/*————–注释—————*/
数据结构
typedef struct tagDRAWITEMSTRUCT {
  UINT      CtlType;
  UINT      CtlID;
  UINT      itemID;
  UINT      itemAction;
  UINT      itemState;
  HWND      hwndItem;
  HDC       hDC;
  RECT      rcItem;
  ULONG_PTR itemData;
} DRAWITEMSTRUCT;


LPDRAWITEMSTRUCT pdis;
pdis = (LPDRAWITEMSTRUCT)lParam;


CtlType
ODT_BUTTON Owner-drawn button
ODT_COMBOBOX Owner-drawn combo box
ODT_LISTBOX Owner-drawn list box
ODT_LISTVIEW List view control
ODT_MENU Owner-drawn menu item
ODT_STATIC Owner-drawn static control
ODT_TAB  Tab control


itemAction
ODA_DRAWENTIRE The entire control needs to be drawn.
ODA_FOCUS The control has lost or gained the keyboard focus. The itemState member should be checked to determine whether the control has the focus.
ODA_SELECT The selection status has changed. The itemState member should be checked to determine the new selection state.


itemState
ODS_CHECKED  The menu item is to be checked. This bit is used only in a menu.
ODS_COMBOBOXEDIT The drawing takes place in the selection field (edit control) of an owner-drawn combo box.
ODS_DEFAULT  The item is the default item.
ODS_DISABLED  The item is to be drawn as disabled.
ODS_FOCUS  The item has the keyboard focus.
ODS_GRAYED  The item is to be grayed. This bit is used only in a menu.
ODS_HOTLIGHT  Windows 98/Me, Windows 2000/XP: The item is being hot-tracked, that is, the item will be highlighted when the mouse is on the item.
ODS_INACTIVE  Windows 98/Me, Windows 2000/XP: The item is inactive and the window associated with the menu is inactive.
ODS_NOACCEL  Windows 2000/XP: The control is drawn without the keyboard accelerator cues.
ODS_NOFOCUSRECT  Windows 2000/XP: The control is drawn without focus indicator cues.
ODS_SELECTED  The menu item’s status is selected.
/*————–注释 end———–*/


渲染滚动条
WM_CTLCOLORSCROLLBAR


渲染静态控件
WM_CTLCOLORSTATIC

Powered by WordPress. Theme: Motion by 85ideas.