Link to home
Start Free TrialLog in
Avatar of Jammer1224
Jammer1224

asked on

Getting active window in BCB 6.0

Using Borland C++ Builder 6.0
Got this code:

char* oldtitle = "";
char* title= "a";
while(1)
             {

                    Sleep(10);
                    HWND wnd=GetForegroundWindow();
                    ShowMessage("Trying");
                    if(wnd) {
                        char* title;
                        GetWindowText(wnd,title,sizeof(title));
                        ShowMessage("Success");
                        DWORD err = GetLastError();
                        ShowMessage("Error code:" + IntToStr(err));
                        ShowMessage(title);

                    }
                    if (title != oldtitle) {
                       oldtitle = title;
                        DoSomeAction();
                    }



Don't know why but the title is always a null value.
Avatar of Jammer1224
Jammer1224

ASKER

Hurry up. Its urgent!
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What can i say.
Finders keepers!
Congrats on you 500 points.
Thats all I needed.