Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find Ex

3 views
Skip to first unread message

Pedram

unread,
Sep 13, 2004, 2:55:19 PM9/13/04
to
Assume a TForm named B_Form with a TMainMenu
There is Choice1 and Chioce2 in TMainMenu Items
Also there is a TEdit , TMemo and TButton...
This Project is Compiled , executed and Launched !

I need to know how can I write a Code to Select B_Form from My Current
application by FindWindow() and FindWindowEx()

:-) Thx , please guide me
I realy approciate @};-


Pedram

unread,
Sep 14, 2004, 9:45:57 AM9/14/04
to

Pedram wrote in message <4145...@newsgroups.borland.com>...

JD

unread,
Sep 14, 2004, 3:17:52 PM9/14/04
to

"Pedram" <no...@hever.sever> wrote:
>
>Pedram wrote in message <4145...@newsgroups.borland.com>...
>>Assume a TForm named B_Form with a TMainMenu
>>There is Choice1 and Chioce2 in TMainMenu Items
>>Also there is a TEdit , TMemo and TButton...
>>This Project is Compiled , executed and Launched !
>>
>>I need to know how can I write a Code to Select B_Form from My Current
>>application by FindWindow() and FindWindowEx()

To reliably be able to locate the window, you need to name the
main form class something unique, like TCompanyNameProgramName
instead of TForm1 (or B_Form).

Or, you need to make sure that the Application::Title is
unique. However, if it's an MDI application, the Application
Title will change if there is an open MDIChild form so I never
use this method unless I have no choice.

Once you find a HANDLE to the application, you need to
enumerate the child windows to get HANDLE(s) to the other
controls in the window (form) to interact with them.

HANDLE hTheHandleOfTheAppYouWant = NULL;
// define other HANDLE(s) that you want.
//-------------------------------------------------------------
BOOL CALLBACK EnumWindowsCallBack( HWND hWnd, LPARAM lParam )
{
char WindowClassName[256] = {0};
if( ::GetClassName(hWnd, WindowClassName, 255) )
{
if( stricmp(WindowClassName, (char*)lParam) == 0)
{
hTheHandleOfTheAppYouWant = hWnd;
// stop enuming
return FALSE;
}
}
return TRUE;
}
//-------------------------------------------------------------
BOOL CALLBACK EnumChildCallBack( HWND hWnd, LPARAM lParam )
{
// we're looking for the second instance of "Static"
char WindowClassName[256] = {0};
if( ::GetClassName(hWnd, WindowClassName, 255) )
{
if( stricmp(WindowClassName, (char*)lParam) == 0 )
{
++DlgCtrlCounter;
if( DlgCtrlCounter == 2 )
{
DlgCtrlHWND = hWnd;
// stop Enuming
return FALSE;
}
}
}
return TRUE;
}
//-------------------------------------------------------------

AnsiString WindowClassName = "TCompanyNameProgramName";
::EnumWindows( (WNDENUMPROC)EnumWindowsCallBack, (LPARAM)WindowClassName.c_str() );
if( hTheHandleOfTheAppYouWant )
{
WindowClassName = "Static";
::EnumChildWindows( hWnd, (WNDENUMPROC)EnumChildCallBack, (LPARAM)WindowClassName.c_str() );
}

Now that you have the handles to the controls, what are you
going to do with them? If it's your application, I would
suggest that you just use custom messages that can be sent to
the Application Handle and let it do the work.

~ JD

Pedram

unread,
Sep 14, 2004, 3:14:11 PM9/14/04
to
Thx alot !! I'll check it out and talk about it if there will something
important :-) thx again


Pedram

unread,
Sep 21, 2004, 2:47:43 PM9/21/04
to
Hi
I was talking about learning how could I use FindWindowEx !
Although I learn myself about FindWindow()
Please take a look at Zip file in borland.public.attachments to download the
Binary and source file.
You will see the project with comments.
Please take care of me :-D thx


Pedram

unread,
Sep 24, 2004, 10:25:21 AM9/24/04
to
Please Someone help

Assume a TForm named B_Form with a TMainMenu
There is Choice1 and Chioce2 in TMainMenu Items
Also there is a TEdit , TMemo and TButton...
This Project is Compiled , executed and Launched !

I need to know how can I write a Code to Select B_Form from My Current
application by FindWindow() and FindWindowEx()

:-) Thx , please guide me


I realy approciate @};-


there is also a post in attachments with the same subject name , my C++
project that I need help in.


0 new messages