• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Visual C++ 2011-5-27

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

 

有两个命令

1.WM_SYSCOMMAND

这个命令与本身程序有关,如最小化窗体,关闭窗体等

2.WM_APPCOMMAND

这个命令可以控制操作系统本身的很多功能,如打开浏览器,邮箱,调节音量等.

使用非常简单,无须额外的处理

SendMessage(hwnd,WM_APPCOMMAND, (WPARAM)hwnd, MAKELPARAM(0x0000, APPCOMMAND_VOLUME_UP));  

二.SHDeleteKey,RegDeleteKey

Deletes a subkey and all its descendants. The function will remove the key and all of the key's values from the registry.

发现SH开头的函数都是那么的方便

RegDeleteKey

Deletes a subkey and its values.

三.GetWindowThreadProcessId

获取创建该窗体线程的进程

//获得应用程序指针
CDemoApp* pApp = (CDemoApp*)AfxGetApp();
//获得主窗口指针
CWnd* pMainWnd = pApp->m_pMainWnd;
DWORD word=::GetCurrentProcessId();
DWORD pword;
GetWindowThreadProcessId(pMainWnd->GetSafeHwnd(),&pword);
ASSERT(word==pword);

四.SendMessageTimeout

If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set.

五.LoadImage && CopyImage

Loads an icon, cursor, animated cursor, or bitmap.

     wndclass.hIcon=LoadImage(hInstance,MAKEINTRESOURCE (IDI_ICON),IMAGE_ICON,32,32,LR_DEFAULTCOLOR);
     //wndclass.hIcon         = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON)) ;

可以理解为LoadImage为LoadIcon、LoadCursor、LoadBitmap的一个全局函数,但是销毁资源时候还是需要用到DestoryIcon,DestoryCursor等

HANDLE CopyImage(      
                HANDLE 
            hImage,
    UINT 
            uType,
    int 
            cxDesired,
    int 
            cyDesired,
    UINT 
            fuFlags
);

同理CopyImage也可以复制原有的Icon、Cursor、Bitmap等资源

六.GetInputState

The GetInputState function determines whether there are mouse-button or keyboard messages in the calling thread's message queue.

七.SendInput

The SendInput function synthesizes keystrokes, mouse motions, and button clicks.

http://baike.baidu.com/view/3638567.htm

模拟鼠标,键盘事件

八.AttachThreadInput

Windows created in different threads typically process input independently of each other. That is, they have their own input states (focus, active, capture windows, key state, queue status, and so on), and they are not synchronized with the input processing of other threads. By using the AttachThreadInput function, a thread can attach its input processing to another thread. This also allows threads to share their input states, so they can call the SetFocus function to set the keyboard focus to a window of a different thread. This also allows threads to get key-state information. These capabilities are not generally possible.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#简单的工厂模式发布时间:2022-07-14
下一篇:
C#中的委托是什么-下(Func与Action)发布时间:2022-07-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap