• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

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.
0
Jammer1224
Asked:
Jammer1224
  • 2
1 Solution
 
Jammer1224Author Commented:
Hurry up. Its urgent!
0
 
Kent OlsenData Warehouse Architect / DBACommented:

You've got 'title' defined with two different scopes.  


0
 
Jammer1224Author Commented:
What can i say.
Finders keepers!
Congrats on you 500 points.
Thats all I needed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now