I use Borland C++ Builder 3, Win 200 Pro.
From within my program I use SendMessage to click a command button in another application. This works and another window pops up, this new window has focus, from within this new window i wont to get the handle for an edit box.
The problem is after the new window pops up my program pauses, is there any way i can return conrol to my program to continue searching for this control, am i missing a function call?
code below..
Thanks.
Code:
//---------------------------------------------------------------------------
#include <stdlib.h>
#include <vcl.h>
#include <Windows.h>
#pragma hdrstop
#include "my_IP_suite.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
HWND hWnd; //window handle
HWND hBut; //control handle
// get handle of window
hWnd = FindWindow(NULL, "Reminder");
if(! hWnd) exit(0); //if window don't found, exit program
//move through controls, get handle of command button
hBut = FindWindowEx(hWnd, NULL, "TButton", NULL);
hBut = FindWindowEx(hWnd, hBut, "TButton", NULL);
//click command button
SendMessage(hBut, BM_CLICK, NULL, NULL);
/*program pauses here, "Registration" window has focus, but program wont
continue */
//title of new window
hWnd = FindWindow(NULL, "Registration");
if(! hWnd) exit(0); //if window don't found, exit program
//move through controls, get handle of edit box
hBut = FindWindowEx(hWnd, NULL, "TButton", NULL);
hBut = FindWindowEx(hWnd, hBut, "TButton", NULL);
hBut = FindWindowEx(hWnd, hBut, "TButton", NULL);
hBut = FindWindowEx(hWnd, hBut, "TButton", NULL);
}
//---------------------------------------------------------------------------