赞
踩
afx_msg UINT CWnd::OnGetDlgCode( );
void CWnd::Invalidate(BOOL bErase = TRUE);
DWORD GetSysColor(int nIndex //display element);
TCHAR.H routine
|
_UNICODE & _MBCS not defined
|
_MBCS defined
|
_UNICODE defined
|
_tcsncpy
|
strncpy
|
_mbsnbcpy
|
wcsncpy
|
BOOL DestroyCursor(HCURSOR hCursor // handle to cursor to destroy);
BOOL DestroyMenu(HMENU hMenu // handle to menu);
UINT CButton::GetButtonStyle( ) const;
virtual void CButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
typedef struct tagDRAWITEMSTRUCT {
UINT CtlType;
UINT CtlID;
UINT itemID;
UINT itemAction;
UINT itemState;
HWND hwndItem;
HDC hDC;
RECT rcItem;
DWORD itemData;
} DRAWITEMSTRUCT;
class CClientDC : public CDC
void CDC::FrameRect(LPCRECT lpRect,CBrush* pBrush);
void CRect::OffsetRect(int x,int y) throw( );
void CRect::OffsetRect(POINT point) throw( );
void CRect::OffsetRect(SIZE size) throw( );
void CRect::CopyRect(LPCRECT lpSrcRect) throw( );
关于CDC::DrawState
BOOL CDC::DrawState(CPoint pt,CSize size,HBITMAP hBitmap,
UINT nFlags,HBRUSH hBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,CBitmap* pBitmap,
UINT nFlags,CBrush* pBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,HICON hIcon,
UINT nFlags,HBRUSH hBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,HICON hIcon,
UINT nFlags,CBrush* pBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,LPCTSTR lpszText,
UINT nFlags,BOOL bPrefixText = TRUE, int nTextLen = 0,
HBRUSH hBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,LPCTSTR lpszText,
UINT nFlags,BOOL bPrefixText = TRUE, int nTextLen = 0,
CBrush* pBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,DRAWSTATEPROC lpDrawProc,
LPARAM lData,UINT nFlags,HBRUSH hBrush = NULL);
BOOL CDC::DrawState(CPoint pt,CSize size,DRAWSTATEPROC lpDrawProc,
LPARAM lData,UINT nFlags,CBrush* pBrush = NULL);
Call this member function to display an image and apply a visual effect to indicate a state, such as a disabled or default state. For all nFlag states except DSS_NORMAL, the image is converted to monochrome before the visual effect is applied.
HDC CreateCompatibleDC(HDC hdc // handle to DC);
int FillRect(HDC hDC,//handle to DC CONST RECT *lprc,// rectangle
HBRUSH hbr // handle to brush);
FillRect(hdc, &rect, (HBRUSH) (COLOR_WINDOW+1));For a list of all the standard system colors, see GetSysColor.
COLORREF SetBkColor(HDC hdc, // handle to DC
COLORREF crColor // background color value);
BOOL DeleteDC(HDC hdc // handle to DC);
virtual int DrawText(LPCTSTR lpszString,int nCount,LPRECT lpRect,
UINT nFormat);
int DrawText(const CString& str,LPRECT lpRect,UINT nFormat);
virtual BOOL CToolTipCtrl::Create(CWnd* pParentWnd,DWORD dwStyle = 0);
Creates a tool tip control and attaches it to a CToolTipCtrl object.You construct a CToolTipCtrl in two steps. First, call the constructor to construct the CToolTipCtrl object, and then call Create to create the tool tip control and attach it to the CToolTipCtrl object.
Style
|
Meaning
|
TTS_ALWAYSTIP
|
Specifies that the tool tip will appear when the cursor is on a tool, regardless of whether the tool tip control's owner window is active or inactive. Without this style, the tool tip control appears when the tool's owner window is active, but not when it is inactive.
|
TTS_NOPREFIX
|
This style prevents the system from stripping the ampersand (&) character from a string. If a tool tip control does not have the TTS_NOPREFIX style, the system automatically strips ampersand characters, allowing an application to use the same string as both a menu item and as text in a tool tip control.
|
void CToolTipCtrl::Activate(BOOL bActivate);
TTM_SETMAXTIPWIDTH
wParam = 0;
lParam = (LPARAM)(INT) iWidth;
0
|
No icon.
|
1
|
Info icon.
|
2
|
Warning icon
|
3
|
Error Icon
|
void CToolTipCtrl::RelayEvent(LPMSG lpMsg );
WM_LBUTTONDOWN
|
WM_MOUSEMOVE
|
WM_LBUTTONUP
|
WM_RBUTTONDOWN
|
WM_MBUTTONDOWN
|
WM_RBUTTONUP
|
WM_MBUTTONUP
|
|
virtual BOOL CWnd::PreTranslateMessage(MSG* pMsg);
HINSTANCE AFXAPI AfxFindResourceHandle(LPCTSTR lpszName,
LPCTSTR lpszType);
Value
|
Meaning
|
RT_ACCELERATOR
|
Accelerator table
|
RT_ANICURSOR
|
Animated cursor
|
RT_ANIICON
|
Animated icon
|
RT_BITMAP
|
Bitmap resource
|
RT_CURSOR
|
Hardware-dependent cursor resource
|
RT_DIALOG
|
Dialog box
|
RT_DLGINCLUDE
|
|
RT_FONT
|
Font resource
|
RT_FONTDIR
|
Font directory resource
|
RT_GROUP_CURSOR
|
Hardware-independent cursor resource
|
RT_GROUP_ICON
|
Hardware-independent icon resource
|
RT_HTML
|
HTML
|
RT_ICON
|
Hardware-dependent icon resource
|
RT_MANIFEST
|
Windows XP: Fusion XML Manifest
|
RT_MENU
|
Menu resource
|
RT_MESSAGETABLE
|
Message-table entry
|
RT_PLUGPLAY
|
Plug and Play resource
|
RT_RCDATA
|
Application-defined resource (raw data)
|
RT_STRING
|
String-table entry
|
RT_VERSION
|
Version resource
|
RT_VXD
|
VXD
|
HANDLE LoadImage(
HINSTANCE hinst, // handle to instance
LPCTSTR lpszName, // image to load
UINT uType, // image type
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load options
);
Value
|
Meaning
|
IMAGE_BITMAP
|
Loads a bitmap.
|
IMAGE_CURSOR
|
Loads a cursor.
|
IMAGE_ICON
|
Loads an icon.
|
Value
|
Meaning
| |
LR_DEFAULTCOLOR
|
The default flag; it does nothing. All it means is "not LR_MONOCHROME".
| |
LR_CREATEDIBSECTION
|
When the uType parameter specifies IMAGE_BITMAP, causes the function to return a DIB section bitmap rather than a compatible bitmap. This flag is useful for loading a bitmap without mapping it to the colors of the display device.
| |
LR_DEFAULTSIZE
|
Uses the width or height specified by the system metric values for cursors or icons, if the cxDesired or cyDesired values are set to zero. If this flag is not specified and cxDesired and cyDesired are set to zero, the function uses the actual resource size. If the resource contains multiple images, the function uses the size of the first image.
| |
LR_LOADFROMFILE
|
Loads the image from the file specified by the lpszName parameter. If this flag is not specified, lpszName is the name of the resource.
| |
LR_LOADMAP3DCOLORS
|
Searches the color table for the image and replaces the following shades of gray with the corresponding 3-D color:
| |
|
Color
|
Replaced with
|
|
Dk Gray,
RGB(128,128,128) |
COLOR_3DSHADOW
|
|
Gray,
RGB(192,192,192) |
COLOR_3DFACE
|
|
Lt Gray,
RGB(223,223,223) |
COLOR_3DLIGHT
|
|
Do not use this option if you are loading a bitmap with a color depth greater than 8bpp.
| |
LR_LOADTRANSPARENT
|
Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the default window color (COLOR_WINDOW). All pixels in the image that use that entry become the default window color. This value applies only to images that have corresponding color tables.
Do not use this option if you are loading a bitmap with a color depth greater than 8bpp.
If fuLoad includes both the LR_LOADTRANSPARENT and LR_LOADMAP3DCOLORS values, LRLOADTRANSPARENT takes precedence. However, the color table entry is replaced with COLOR_3DFACE rather than COLOR_WINDOW.
| |
LR_MONOCHROME
|
Loads the image in black and white.
| |
LR_SHARED
|
Shares the image handle if the image is loaded multiple times. If LR_SHARED is not set, a second call to LoadImage for the same resource will load the image again and return a different handle.
When you use this flag, the system will destroy the resource when it is no longer needed.
Do not use LR_SHARED for images that have non-standard sizes, that may change after loading, or that are loaded from a file.
When loading a system icon or cursor, you must use LR_SHARED or the function will fail to load the resource.
Windows 95/98/Me: The function finds the first image with the requested resource name in the cache, regardless of the size requested.
| |
LR_VGACOLOR
|
Uses true VGA colors.
|
Resource
|
Release function
|
Bitmap
|
DeleteObject
|
Cursor
| |
Icon
|
typedef struct _ICONINFO {
BOOL fIcon;
DWORD xHotspot;
DWORD yHotspot;
HBITMAP hbmMask;
HBITMAP hbmColor;
BOOL GetIconInfo(HICON hIcon, // icon handle
PICONINFO piconinfo // icon structure);
int GetObject(
HGDIOBJ hgdiobj, // handle to graphics object
int cbBuffer, // size of buffer for object information
LPVOID lpvObject // buffer for object information
);
HDC GetDC(HWND hWnd // handle to window);
HBITMAP CreateBitmap(
int nWidth, // bitmap width, in pixels
int nHeight, // bitmap height, in pixels
UINT cPlanes, // number of color planes
UINT cBitsPerPel, // number of bits to identify color
CONST VOID *lpvBits // color data array
);
COLORREF GetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
COLORREF SetPixel(
HDC hdc, // handle to DC
int X, // x-coordinate of pixel
int Y, // y-coordinate of pixel
COLORREF crColor // pixel color
);
HICON CreateIconIndirect(PICONINFO piconinfo // icon information);
int ReleaseDC(HWND hWnd,// handle to window HDC hDC // handle to DC);
BOOL CStringT::LoadString(HINSTANCE hInstance,UINT nID,
WORD wLanguageID);
BOOL CStringT::LoadString(HINSTANCE hInstance,UINT nID);
BOOL CStringT::LoadString(UINT nID);
int CToolTipCtrl::GetToolCount( ) const;
BOOL CToolTipCtrl::AddTool(
CWnd* pWnd,
UINT nIDText,
LPCRECT lpRectTool = NULL,
UINT_PTR nIDTool = 0
);
BOOL CToolTipCtrl::AddTool(
CWnd* pWnd,
LPCTSTR lpszText = LPSTR_TEXTCALLBACK,
LPCRECT lpRectTool = NULL,
UINT_PTR nIDTool = 0
);
void CToolTipCtrl::UpdateTipText(
LPCTSTR lpszText,
CWnd* pWnd,
UINT_PTR nIDTool = 0
);
void CToolTipCtrl::UpdateTipText(
UINT nIDText,
CWnd* pWnd,
UINT_PTR nIDTool = 0
);
BOOL IsBadReadPtr(
CONST VOID *lp, // memory address
UINT_PTR ucb // size of block
);
The IsBadReadPtr function verifies that the calling process has read access to the specified range of memory. This function is typically used when working with pointers returned from third-party libraries, where you cannot determine the memory management behavior in the third-party DLL. Threads in a process are expected to cooperate in such a way that one will not free memory that the other needs. Use of this function does not negate the need to do this. If this is not done, the application may fail in an unpredictable manner. Dereferencing potentially invalid pointers can disable stack expansion in other threads. A thread exhausting its stack, when stack expansion has been disabled, results in the immediate termination of the parent process, with no pop-up error window or diagnostic information.If the calling process has read access to some, but not all, of the bytes in the specified memory range, the return value is nonzero. In a preemptive multitasking environment, it is possible for some other thread to change the process's access to the memory being tested. Even when the function indicates that the process has read access to the specified memory, you should use structured exception handling when attempting to access the memory. Use of structured exception handling enables the system to notify the process if an access violation exception occurs, giving the process an opportunity to handle the exception.
Parameters
lp
[in] Pointer to the first byte of the memory block.
ucb
[in] Specifies the size, in bytes, of the memory block. If this parameter is zero, the return value is zero.
Return Values
If the calling process has read access to all bytes in the specified memory range, the return value is zero.If the calling process does not have read access to all bytes in the specified memory range, the return value is nonzero. If the application is compiled as a debugging version, and the process does not have read access to all bytes in the specified memory range, the function causes an assertion and breaks into the debugger. Leaving the debugger, the function continues as usual, and returns a nonzero value This behavior is by design, as a debugging aid.
Version 5.80. Indicates that the ToolTip control has the appearance of a cartoon "balloon," with rounded corners and a stem pointing to the item.
例如:
DWORD dwToolTipStyle = 0;
dwToolTipStyle |= TTS_BALLOON;
m_ToolTip.Create(this, dwToolTipStyle);
CWnd* CWnd::GetNextDlgTabItem(
CWnd* pWndCtl,
BOOL bPrevious = FALSE) const;
COleControlSiteOrWnd* CWnd::GetNextDlgTabItem(
COleControlSiteOrWnd *pCurSiteOrWnd,
BOOL bPrevious) const;
关于CWnd::OnActivate
afx_msg void CWnd::OnActivate(
UINT nState,
CWnd* pWndOther,
BOOL bMinimized
);
afx_msg BOOL CWnd::OnSetCursor(
CWnd* pWnd,
UINT nHitTest,
UINT message
);
HCURSOR SetCursor(
HCURSOR hCursor // handle to cursor
);
afx_msg void CWnd::OnCancelMode( );
BOOL CWnd::SetWindowPos(
const CWnd* pWndInsertAfter,
int x,
int y,
int cx,
int cy,
UINT nFlags
);
BOOL DestroyCursor(HCURSOR hCursor // handle to cursor to destroy);
ON_MESSAGE(message, memberFxn )
SendMessage(
(HWND) hWnd, // handle to destination window
BM_SETSTYLE, // message to send
(WPARAM) wParam, // button style
(LPARAM) lParam // redraw state
);
virtual LRESULT CWnd::DefWindowProc(
UINT message,
WPARAM wParam,
LPARAM lParam
);
SendMessage(
(HWND) hWnd, // handle to destination window
BM_SETCHECK, // message to send
(WPARAM) wParam, // check state
(LPARAM) lParam // not used; must be zero
);
Value
|
Meaning
|
BST_CHECKED
|
Sets the button state to checked.
|
BST_INDETERMINATE
|
Sets the button state to grayed, indicating an indeterminate state. Use this value only if the button has the BS_3STATE or BS_AUTO3STATE style.
|
BST_UNCHECKED
|
Sets the button state to cleared.
|
SendMessage(
(HWND) hWnd, // handle to destination window
BM_GETCHECK, // message to send
(WPARAM) wParam, // not used; must be zero
(LPARAM) lParam // not used; must be zero
);
Value
|
Meaning
|
BST_CHECKED
|
Button is checked.
|
BST_INDETERMINATE
|
Button is grayed, indicating an indeterminate state (applies only if the button has the BS_3STATE or BS_AUTO3STATE style).
|
BST_UNCHECKED
|
Button is cleared
|
typedef struct tagTRACKMOUSEEVENT {
DWORD cbSize;
DWORD dwFlags;
HWND hwndTrack;
DWORD dwHoverTime;
} TRACKMOUSEEVENT, *LPTRACKMOUSEEVENT;
Value
|
Meaning
|
TME_CANCEL
|
The caller wants to cancel a prior tracking request.
The caller should also specify the type of tracking that it wants to cancel. For example, to cancel hover tracking, the caller must pass the TME_CANCEL and TME_HOVER flags.
|
TME_HOVER
|
The caller wants hover notification. Notification is delivered as a WM_MOUSEHOVER message.
If the caller requests hover tracking while hover tracking is already active, the hover timer will be reset.
This flag is ignored if the mouse pointer is not over the specified window or area.
|
TME_LEAVE
|
The caller wants leave notification. Notification is delivered as a WM_MOUSELEAVE message.
If the mouse is not over the specified window or area, a leave notification is generated immediately and no further tracking is performed.
|
TME_NONCLIENT
|
Windows 98/Me, Windows 2000/XP: The caller wants hover and leave notification for the nonclient areas. Notification is delivered as WM_NCMOUSEHOVER and WM_NCMOUSELEAVE messages.
|
TME_QUERY
|
The function fills in the structure instead of treating it as a tracking request. The structure is filled such that had that structure been passed to TrackMouseEvent, it would generate the current tracking. The only anomaly is that the hover time-out returned is always the actual time-out and not HOVER_DEFAULT, if HOVER_DEFAULT was specified during the original TrackMouseEvent request.
|
void CWnd::ClientToScreen(LPPOINT lpPoint) const;
void CWnd::ClientToScreen(LPRECT lpRect) const;
static CWnd* PASCAL CWnd::WindowFromPoint(POINT point);
afx_msg void CWnd::OnMouseMove(UINT nFlags,CPoint point);
static CWnd* PASCAL CWnd::GetActiveWindow( );
BOOL PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);
Value
|
Meaning
|
SND_APPLICATION
|
The sound is played using an application-specific association.
|
SND_ALIAS
|
The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.
|
SND_ALIAS_ID
|
The pszSound parameter is a predefined sound identifier.
|
SND_ASYNC
|
The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
|
SND_FILENAME
|
The pszSound parameter is a filename.
|
SND_LOOP
|
The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. You must also specify the SND_ASYNC flag to indicate an asynchronous sound event.
|
SND_MEMORY
|
A sound event's file is loaded in RAM. The parameter specified by pszSound must point to an image of a sound in memory.
|
SND_NODEFAULT
|
No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.
|
SND_NOSTOP
|
The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE without playing the requested sound.
If this flag is not specified, PlaySound attempts to stop the currently playing sound so that the device can be used to play the new sound.
|
SND_NOWAIT
|
If the driver is busy, return immediately without playing the sound.
|
SND_PURGE
|
Sounds are to be stopped for the calling task. If pszSound is not NULL, all instances of the specified sound are stopped. If pszSound is NULL, all sounds that are playing on behalf of the calling task are stopped.
You must also specify the instance handle to stop SND_RESOURCE events.
|
SND_RESOURCE
|
The pszSound parameter is a resource identifier; hmod must identify the instance that contains the resource.
|
SND_SYNC
|
Synchronous playback of a sound event. PlaySound returns after the sound event completes.
|
#pragma comment( "comment-type" [, commentstring] )
#pragma comment(linker, "/include:__mySymbol")
#pragma comment( lib, "emapi" )
#pragma comment( compiler )
For comments that take a commentstring parameter, you can use a macro in any place where you would use a string literal, provided that the macro expands to a string literal. You can also concatenate any combination of string literals and macros that expand to string literals. For example, the following statement is acceptable:
#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
如何添加系统中Lib到当前项目
(1)在Project | Settings | Link | Object/library modules:输入Lib名
称,不同的Lib之间用空格格开。
(2)#pragma comment(lib,"yourlib.lib")
CMenu* CMenu::GetSubMenu(int nPos) const;
HMENU GetSubMenu(
HMENU hMenu, // handle to menu
int nPos // menu item position
);
Value
|
Meaning
|
TPM_CENTERALIGN
|
If this flag is set, the function centers the shortcut menu horizontally relative to the coordinate specified by the x parameter.
|
TPM_LEFTALIGN
|
If this flag is set, the function positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter.
|
TPM_RIGHTALIGN
|
Positions the shortcut menu so that its right side is aligned with the coordinate specified by the x parameter.
|
Value
|
Meaning
|
TPM_BOTTOMALIGN
|
If this flag is set, the function positions the shortcut menu so that its bottom side is aligned with the coordinate specified by the y parameter.
|
TPM_TOPALIGN
|
If this flag is set, the function positions the shortcut menu so that its top side is aligned with the coordinate specified by the y parameter.
|
TPM_VCENTERALIGN
|
If this flag is set, the function centers the shortcut menu vertically relative to the coordinate specified by the y parameter.
|
Value
|
Meaning
|
TPM_NONOTIFY
|
If this flag is set, the function does not send notification messages when the user clicks on a menu item.
|
TPM_RETURNCMD
|
If this flag is set, the function returns the menu item identifier of the user's selection in the return value.
|
Value
|
Meaning
|
TPM_LEFTBUTTON
|
If this flag is set, the user can select menu items with only the left mouse button.
|
TPM_RIGHTBUTTON
|
If this flag is set, the user can select menu items with both the left and right mouse buttons.
|
Value
|
Meaning
|
TPM_HORNEGANIMATION
|
Animates the menu from right to left.
|
TPM_HORPOSANIMATION
|
Animates the menu from left to right.
|
TPM_NOANIMATION
|
Displays menu without animation.
|
TPM_VERNEGANIMATION
|
Animates the menu from bottom to top.
|
TPM_VERPOSANIMATION
|
Animates the menu from top to bottom.
|
BOOL CMenu::TrackPopupMenu(
UINT nFlags,
int x,
int y,
CWnd* pWnd,
LPCRECT lpRect = 0
);
WPARAM MAKEWPARAM(
WORD wLow,
WORD wHigh
);
size_t strlen(
const char *string
);
size_t wcslen(
const wchar_t *string
);
size_t _mbslen(
const unsigned char *string
);
size_t _mbstrlen(
const char *string
);
typedef struct _SHELLEXECUTEINFO{
DWORD cbSize;
ULONG fMask;
HWND hwnd;
LPCTSTR lpVerb;
LPCTSTR lpFile;
LPCTSTR lpParameters;
LPCTSTR lpDirectory;
int nShow;
HINSTANCE hInstApp;
// Optional members
LPVOID lpIDList;
LPCTSTR lpClass;
HKEY hkeyClass;
DWORD dwHotKey;
union {
HANDLE hIcon;
HANDLE hMonitor;
} DUMMYUNIONNAME;
HANDLE hProcess;
} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
SEE_MASK_CLASSKEY
|
Use the class key given by the hkeyClass member.
|
SEE_MASK_CLASSNAME
|
Use the class name given by the lpClass member.
|
SEE_MASK_CONNECTNETDRV
|
Validate the share and connect to a drive letter. The lpFile member is a Universal Naming Convention (UNC) path of a file on a network.
|
SEE_MASK_DOENVSUBST
|
Expand any environment variables specified in the string given by the lpDirectory or lpFile member.
|
SEE_MASK_FLAG_DDEWAIT
|
Wait for the DDE conversation to terminate before returning (if the
ShellExecuteEx function causes a DDE conversation to start). For circumstances in which this flag is necessary, see the Remarks section.
|
SEE_MASK_FLAG_LOG_USAGE
|
Version 6.0. Keep track of the number of times this application has been launched. Applications that accrue sufficiently high counts appear in the Start Menu's list of most frequently used programs.
|
SEE_MASK_FLAG_NO_UI
|
Do not display an error message box if an error occurs.
|
SEE_MASK_HMONITOR
|
Use this flag when specifying a monitor on multi-monitor systems. The monitor is specified in the hMonitor member. This flag cannot be combined with SEE_MASK_ICON.
|
SEE_MASK_HOTKEY
|
Use the hot key given by the dwHotKey member.
|
SEE_MASK_ICON
|
Use the icon given by the hIcon member. This flag cannot be combined with SEE_MASK_HMONITOR.
|
SEE_MASK_IDLIST
|
Use the item identifier list given by the lpIDList member. The lpIDList member must point to an
ITEMIDLIST structure.
|
SEE_MASK_INVOKEIDLIST
|
Use the
IContextMenu interface of the selected item's
shortcut menu handler. Use either lpFile to identify the item by its file system path or lpIDList to identify the item by its PIDL. This flag allows applications to use
ShellExecuteEx to invoke verbs from shortcut menu extensions instead of the static verbs listed in the registry.
Note SEE_MASK_INVOKEIDLIST overrides SEE_MASK_IDLIST.
|
SEE_MASK_NOCLOSEPROCESS
|
Use to indicate that the hProcess member receives the process handle. This handle is typically used to allow an application to find out when a process created with
ShellExecuteEx terminates. In some cases, such as when execution is satisfied through a DDE conversation, no handle will be returned. The calling application is responsible for closing the handle when it is no longer needed.
|
SEE_MASK_NO_CONSOLE
|
Use to create a console for the new process instead of having it inherit the parent's console. It is equivalent to using a CREATE_NEW_CONSOLE flag with CreateProcess.
|
SEE_MASK_UNICODE
|
Use this flag to indicate a Unicode application.
|
edit
|
Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
|
explore
|
Explores the folder specified by lpFile.
|
find
|
Initiates a search starting from the specified directory.
|
open
|
Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder.
|
print
|
Prints the document file specified by lpFile. If lpFile is not a document file, the function will fail.
|
properties
|
Displays the file or folder's properties.
|
sei.lpParameters = "An example: /"/"/"quoted text/"/"/"";
SE_ERR_FNF
|
File not found.
|
SE_ERR_PNF
|
Path not found.
|
SE_ERR_ACCESSDENIED
|
Access denied.
|
SE_ERR_OOM
|
Out of memory.
|
SE_ERR_DLLNOTFOUND
|
Dynamic-link library not found.
|
SE_ERR_SHARE
|
Cannot share an open file.
|
SE_ERR_ASSOCINCOMPLETE
|
File association information not complete.
|
SE_ERR_DDETIMEOUT
|
DDE operation timed out.
|
SE_ERR_DDEFAIL
|
DDE operation failed.
|
SE_ERR_DDEBUSY
|
DDE operation is busy.
|
SE_ERR_NOASSOC
|
File association not available.
|
BOOL CMenu::LoadMenu(LPCTSTR lpszResourceName);
BOOL CMenu::LoadMenu(UINT nIDResource);
Value
|
Description
|
0
|
Tells Windows to discard the character that the user pressed and creates a short beep on the system speaker.
|
1
|
Tells Windows to close the current menu.
|
2
|
Informs Windows that the low-order word of the return value contains the item number for a specific item. This item is selected by Windows.
|
typedef struct tagMEASUREITEMSTRUCT {
UINT CtlType;
UINT CtlID;
UINT itemID;
UINT itemWidth;
UINT itemHeight;
DWORD itemData
} MEASUREITEMSTRUCT;
BOOL IsMenu(HMENU hMenu // handle to test);
Map entry
|
Function prototype
|
ON_CONTROL_REFLECT( wNotifyCode, memberFxn )
|
afx_msg void memberFxn ( );
|
ON_NOTIFY_REFLECT( wNotifyCode, memberFxn )
|
afx_msg void memberFxn ( NMHDR * pNotifyStruct, LRESULT* result );
|
ON_UPDATE_COMMAND_UI_REFLECT( memberFxn )
|
afx_msg void memberFxn ( CCmdUI* pCmdUI );
|
ON_WM_CTLCOLOR_REFLECT( )
|
afx_msg HBRUSH CtlColor ( CDC* pDC, UINT nCtlColor );
|
ON_WM_DRAWITEM_REFLECT( )
|
afx_msg void DrawItem ( LPDRAWITEMSTRUCT lpDrawItemStruct );
|
ON_WM_MEASUREITEM_REFLECT( )
|
afx_msg void MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct );
|
ON_WM_DELETEITEM_REFLECT( )
|
afx_msg void DeleteItem ( LPDELETEITEMSTRUCT lpDeleteItemStruct );
|
ON_WM_COMPAREITEM_REFLECT( )
|
afx_msg int CompareItem ( LPCOMPAREITEMSTRUCT lpCompareItemStruct );
|
ON_WM_CHARTOITEM_REFLECT( )
|
afx_msg int CharToItem ( UINT nKey, UINT nIndex );
|
ON_WM_VKEYTOITEM_REFLECT( )
|
afx_msg int VKeyToItem ( UINT nKey, UINT nIndex );
|
ON_WM_HSCROLL_REFLECT( )
|
afx_msg void HScroll ( UINT nSBCode, UINT nPos );
|
ON_WM_VSCROLL_REFLECT( )
|
afx_msg void VScroll ( UINT nSBCode, UINT nPos );
|
ON_WM_PARENTNOTIFY_REFLECT( )
|
afx_msg void ParentNotify ( UINT message, LPARAM lParam );
|
Map entry
|
Function prototype
|
ON_NOTIFY_REFLECT_EX( wNotifyCode, memberFxn )
|
afx_msg BOOL memberFxn ( NMHDR * pNotifyStruct, LRESULT* result );
|
ON_CONTROL_REFLECT_EX( wNotifyCode, memberFxn )
|
afx_msg BOOL memberFxn ( );
|
5. CYellowEdit::CYellowEdit()
6. {
7. m_clrText = RGB( 0, 0, 0 );
8. m_clrBkgnd = RGB( 255, 255, 0 );
9. m_brBkgnd.CreateSolidBrush( m_clrBkgnd );
}
ON_WM_CTLCOLOR_REFLECT()
// Note: other code will be in between....
HBRUSH CYellowEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
// TODO: Return a non-NULL brush if the
// parent's handler should not be called
return NULL;
}
12. pDC->SetTextColor( m_clrText ); // text
13. pDC->SetBkColor( m_clrBkgnd ); // text bkgnd
return m_brBkgnd; // ctl bkgnd
#pragma pack( [ show ] | [ push | pop ] [, identifier ] , n )
struct s
{
int i; // aligned on byte boundary 0, size is 4
short j; // aligned on byte boundary 4, size is 2
double k; // aligned on byte boundary 8, size is 8
}
// pragma_directives_pack.cpp
// C4810 expected
#pragma pack() // n defaults to 8; equivalent to /Zp8
#pragma pack(show) // C4810
#pragma pack(4) // n=4
#pragma pack(show) // C4810
#pragma pack(push, r1, 16) // n=16, pushed to stack
#pragma pack(show) // C4810
#pragma pack(pop, r1, 2) // n=2 , stack popped
#pragma pack(show) // C4810
void main()
{
}
关于字符类型
typedef char CHAR;
typedef wchar_t WCHAR;
typedef CHAR * PCHAR, * LPCH, * PCH, * NPSTR, * LPSTR, * PSTR ;
typedef CONST CHAR * LPCCH, * PCCH, * LPCSTR, * PCSTR ;
typedef WCHAR * PWCHAR, * LPWCH, * PWCH, * NWPSTR, * LPWSTR, * PWSTR ;
typedef CONST WCHAR * LPCWCH, * PCWCH, * LPCWSTR, * PCWSTR ;
#ifdef UNICODE
typedef WCHAR TCHAR, * PTCHAR ;
typedef LPWSTR LPTCH, PTCH, PTSTR, LPTSTR ;
typedef LPCWSTR LPCTSTR ;
#else
typedef char TCHAR, * PTCHAR ;
typedef LPSTR LPTCH, PTCH, PTSTR, LPTSTR ;
typedef LPCSTR LPCTSTR ;
#endif
关于DrawItem和OnPaint
(1)自绘控件笔记
不选择在 PreSubclassWindow中作“初始化”工作是因为用户可能在使用中改变属性,必须在一个经常进入的地方检查是否要重新“初始化”。把这项工作放到和绘制有关的消息响应函数里则父窗口一个 RedrawWindow() 就可以引起重新“初始化”。
一般步骤:
1.派生控件子类
2.添加 PreTranslateMessage
3.进行常规操作记下消息类型
4.在子类里处理消息
MFC的 CStatic 控件无法有效 SS_OWNERDRAW 属性,从而无法响应 OnDrawItem。
按MSDN SDK中的static控件可以使能 SS_OWNERDRAW 并发送 WM_DRAWITEM 消息。经测试 CStatic 控件可利用的只有 WM_PAINT 消息。
设有 BS_OWNERDRAW 属性的 CButton 控件先响应 OnEraseBkgnd 再响应 DrawItem。因此调整窗口尺寸等“初始化”工作可以放再 OnEraseBkgnd 里完成。
CProgressCtrl 控件通过 SetPos 、StepIt 绘制,更改进度值不会触发 OnEraseBkgnd 消息但至少会有一次 OnEraseBkgnd,可以利用来作初始化。OnPaint 不完成绘制工作,截获该消息默认的绘制将停止。
CSliderCtrl 绘制行为类似 CProgressCtrl,截获 OnPaint 默认不绘制,但状态改变时会触发 OnPaint 消息。OnEraseBkgnd 可以用来作初始化。OnTimer 在点击轨道时触发,每500ms一次,用来模拟 PageDown/Up,在鼠标放开时timer被kill掉。如果鼠标恰好在当前位置按下则不触发 OnTimer,拖曳滑块不触发 OnTimer。
CMenu 不是 CWnd 的子类但有纯虚的 MeasureItem 和 DrawItem,绘制工作能且只能依赖它们。菜单风格包括 整体背景风格、菜单项风格、文字风格,尺寸参数包括菜单项尺寸、菜单项图标尺寸、文字尺寸。以上种种还因菜单项状态不同改变。
MEASUREITEMSTRUCT 和 DRAWITEMSTRUCT 中的 itemData 在 MF_OWNERDRAW 时都是取自 AppendMenu 、InsertMenu 、ModifyMenu 的最后一个参数,所以不得不有一个结构专门管理菜单项类型、文字、图像等信息。使用 SetMenuInfo、SetMenuItemInfo、GetMenuInfo、GetMenuItemInfo 可以方便的管理菜单信息,但要实现自绘必须有 MF_OWNERDRAW 属性,因此用一个自定义结构管理菜单项的若干重要信息仍是有意义的。
自绘按钮在 MeasureItem 或 DrawItem 里设断点会引起windows菜单显示异常!折腾了很久以为是我的问题呢!
GDI+ new 出的 Bitmap 对象竟然会使用相同的地址!?而且就算地址不同也有冲突?难道不能存储大量的 Bitmap 对象吗?? GdiAlloc 和 GdipCreateBitmapFrom*** 究竟怎么管理内存,new 出的对象不 delete 也不会有任何问题, 文档太少!
CreateMenu 和 CreatePopupMenu 的绘图方式有差异,一定要确定到底是要哪种菜单。 支持子菜单需要动态创建、删除 CSkinMenu 实例,如果用Load方式载入按钮爬一遍即可;如果Insert方式加入的子菜单则由用户决定是否拓展,换言之应不作特殊处理。另外Detach、DestroyMenu、RemoveMenu 都应处理被扩展的子菜单。
CScrollBar 的消息反射OnVscroll、OnHscroll里设置pos是没有用的,大概反射消息只是用来通知不是用来操作。关于Scroll Bar的详细状态可以用GetScrollBarInfo获得。
CListBox的OwnerDraw属性只能在创建的时候指定,不能在PreSubclassWindow里用ModifyStyle改变。而且如果需要触发MeasureItem必须把OwnerDraw设成Variable,Fix时MeasureItem不被调用只能使用SetItemHeight设置高度。
CComboBox的edit部分由OnPaint控制,输入文字是发出OnEditChange,通过列表改变时发出OnSelchange。list部分由DrawItem控制,创立时必须有OwnerDraw风格。但CListBox似乎不能触发MeasureItem。
(2)DrawItem虚函数重载它可以自绘各种控件的外观. OnPaint发送一个全窗口重绘的消息,引起当前窗口全部重绘
(3) OnPaint是全窗口绘制.DrawItem是按项绘制,比如ListCtrl等,可以从函数参数直接取得相关信息.
如何为一radio单选按钮引入一对应的CButton型变量?
将radio button属性中的group选中,就可以加你要的变量了。
关于pDC->SetBkColor(RGB(255,255,255));
I don’t know why call the function“pDC->SetBkColor(RGB(255,255,255))”
void CButtonST::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
//………
if (m_csBitmaps[0].hBitmap)
{
pDC->SetBkColor(RGB(255,255,255));
DrawTheBitmap(pDC,
!sTitle.IsEmpty(),
&lpDIS->rcItem,
&captionRect,
m_bIsPressed,
m_bIsDisabled);
} // if
//………
}
创建蒙板
//I don’t know the essential of the code
} // End of CreateBitmapMask
关于DrawTheBitmap
//(1)what is the effect of this line code:
COLORREF crOldColor = ::SetBkColor(hDC, RGB(255,255,255));
//(2)I don’t know the essential of the code
::BitBlt(pDC->m_hDC, rImage.left, rImage.top,
m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);
::BitBlt(pDC->m_hDC, rImage.left, rImage.top,
m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);
void CButtonST::DrawTheBitmap(CDC* pDC, BOOL bHasTitle, RECT* rpItem,
CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled)
{
HDC hdcBmpMem = NULL;
HBITMAP hbmOldBmp = NULL;
HDC hdcMem = NULL;
HBITMAP hbmT = NULL;
BYTE byIndex = 0;
// Select the bitmap to use
if ((m_bIsCheckBox && bIsPressed) || (!m_bIsCheckBox && (bIsPressed ||
m_bMouseOnButton)))
byIndex = 0;
else
byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);
CRect rImage;
PrepareImageRect(bHasTitle, rpItem, rpCaption, bIsPressed,
m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, &rImage);
hdcBmpMem = ::CreateCompatibleDC(pDC->m_hDC);
hbmOldBmp = (HBITMAP)::SelectObject(hdcBmpMem,
m_csBitmaps[byIndex].hBitmap);
hdcMem = ::CreateCompatibleDC(NULL);
hbmT = (HBITMAP)::SelectObject(hdcMem, m_csBitmaps[byIndex].hMask);
if (bIsDisabled && m_bShowDisabledBitmap)
{
HDC hDC = NULL;
HBITMAP hBitmap = NULL;
hDC = ::CreateCompatibleDC(pDC->m_hDC);
hBitmap = ::CreateCompatibleBitmap(pDC->m_hDC,
m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight);
HBITMAP hOldBmp2 = (HBITMAP)::SelectObject(hDC, hBitmap);
RECT rRect;
rRect.left = 0;
rRect.top = 0;
rRect.right = rImage.right + 1;
rRect.bottom = rImage.bottom + 1;
::FillRect(hDC, &rRect, (HBRUSH)RGB(255, 255, 255));
COLORREF crOldColor = ::SetBkColor(hDC, RGB(255,255,255));
::BitBlt(hDC, 0, 0, m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);
::BitBlt(hDC, 0, 0, m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);
::SetBkColor(hDC, crOldColor);
::SelectObject(hDC, hOldBmp2);
::DeleteDC(hDC);
//the code above is to create a bitmap,because the DrawState
//function only accept the bitmap parameter.DrawState add
//some special state to the displayed bitmap.
pDC->DrawState( CPoint(rImage.left/*+1*/, rImage.top),
CSize(m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight),
hBitmap, DST_BITMAP | DSS_DISABLED);
::DeleteObject(hBitmap);
} // if
else
{
::BitBlt(pDC->m_hDC, rImage.left, rImage.top,
m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);
::BitBlt(pDC->m_hDC, rImage.left, rImage.top,
m_csBitmaps[byIndex].dwWidth,
m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);
} // else
::SelectObject(hdcMem, hbmT);
::DeleteDC(hdcMem);
::SelectObject(hdcBmpMem, hbmOldBmp);
::DeleteDC(hdcBmpMem);
} // End of DrawTheBitmap
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。