SendMessage to a 3-party application (built with c++ builder)
Hi, All
I have an 3-party application built with c++ builder. The window
hierarchy is
TForm1--TPageControl--TTabSheet.
There are several tabsheets, I want to using SendMessage to switch
between sheet 0 and sheet 3. Besides, there are 2 TBitBtn in sheet 0,
I want to Send BM_CLICK message to them.
I got two problems, please help
1) Sometimes the application can't switch between the two sheets, but
not always, my code is below
//this function is used to find the TPageControl window. using
FindWindow and FindWindowEx.
HWND CMyClass::FindTPageControl()
{
//code omitted
}
//this function is used to switch sheet. I send a WM_LBUTTONDOWN
message to the TPageControl window.
void CMyClass::ChangePageIdx(HWND hPage, int Value)
{
HWND hParent = ::GetParent(hPage);
CRect rcParent;
::GetWindowRect(hParent, &rcParent);
CPoint pt0(rcParent.left+60, rcParent.top+40);
::ScreenToClient(hPage, &pt0);
::SendMessage(hPage, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pt0.x,
pt0.y));
}
after debug, I found I can always get the handle of the TPageControl,
but the SendMessage doesn't always work.
2) The second problem is: sometimes the two buttons won't respond to
my BM_CLICK message. the code is below:
//this function is used to find the TBitBtn window, using FindWindow
and FindWindowEx.
HWND CMyClass::FindTButton()
{
//code omitted
}
HWND hwnd=FindTbutton();
SendMessage(hWnd,BM_CLICK,0,0);
the same as the first question, the handle of the TBitBtn can always
be found, but the SendMessage doesn't work.
please suggest what I should do to ensure the 3-party application
responds to my application every time. thanks