Visual C++ 2011-5-27
?
一.命令消息
有兩個命令
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.
轉載于:https://www.cnblogs.com/Clingingboy/archive/2011/06/06/2073611.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的Visual C++ 2011-5-27的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ASP.NET中Image控件不能自动刷
- 下一篇: poj 3126