代码改变世界

Win32 API (2012/11/4)

2012-11-04 13:45  Clingingboy  阅读(510)  评论(0编辑  收藏  举报

 

一.HiliteMenuItem

The HiliteMenuItem function highlights or removes the highlighting from an item in a menu bar.

image

就是这种状态

Menu API的设计原则都是父项负责对子项的操作

二.菜单状态

UINT uState=pSubMenu->GetMenuState(ID_TEST_MENU,MF_BYCOMMAND);
BOOL bChecked= uState&MF_CHECKED;

从这张表可以看到菜单所有的状态

image

三.GetDC和GetWindowDC的区别

  • The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area.
  • The GetDC function retrieves a handle to a display device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC.
  • The GetDCEx function retrieves a handle to a display device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC.

    This function is an extension to the GetDC function, which gives an application more control over how and whether clipping occurs in the client area.

四.WM_ACTIVATE 消息

The WM_ACTIVATE message is sent to both the window being activated and the window being deactivated. If the windows use the same input queue, the message is sent synchronously, first to the window procedure of the top-level window being deactivated, then to the window procedure of the top-level window being activated. If the windows use different input queues, the message is sent asynchronously, so the window is activated immediately.

参考:

http://www.cnblogs.com/afarmer/archive/2009/12/21/1629329.html

五.MapWindowPoints

可以用于计算相对两个窗口之间的坐标距离的计算和转换ClientToScreen

http://blog.csdn.net/fengbangyue/article/details/5617778

六.ExtCreatePen

Ext代表Extension扩展的意思,属于CreatePen的加强版,属于C语言函数没有C++语法扩展所特有的函数名特征

image

七.GetWindowPlacement && SetWindowPlacement

The GetWindowPlacement function retrieves the show state and the restored, minimized, and maximized positions of the specified window.

image

WINDOWPLACEMENT placement={0};
placement.length=sizeof(WINDOWPLACEMENT);
GetWindowPlacement(&placement);
placement.rcNormalPosition.left=1;
SetWindowPlacement(&placement);

八.ShowOwnedPopups

The ShowOwnedPopups function shows or hides all pop-up windows owned by the specified window.

Remarks

ShowOwnedPopups shows only windows hidden by a previous call to ShowOwnedPopups. For example, if a pop-up window is hidden by using the ShowWindow function, subsequently calling ShowOwnedPopups with the fShow parameter set to TRUE does not cause the window to be shown.