- C/C++ code
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { HWND hwnd; hwnd=::FindWindow("ThunderRT6FormDC","Form1"); char c[255]; ::GetWindowTextA(hwnd,c,255); //这里可以正常取得窗体的名字 ::PostMessage(hwnd,BM_CLICK,0,0); //这里怎么发送不了BM_CLICK }
请问一下,BM_CLICK用定义吗?如果用的话请问怎么定义.如果不用的话,为什么PostMessage没有成功!
------解决方案--------------------------------------------------------
http://msdn.microsoft.com/en-us/library/bb775985(VS.85).aspx
Remarks
If the button is in a dialog box and the dialog box is not active, the BM_CLICK message might fail. To ensure success in this situation, call the SetActiveWindow function to activate the dialog box before sending the BM_CLICK message to the button.