a2c Subj : Can I query Delphi GUI APP controls from inside C++ DLL? To : borland.public.cpp.borlandcpp From : ajkirkle@yahoo.com (Adam) Date : Mon Jul 07 2003 08:11 am Please help - I am trying to get some control/window data from a GUI written in Delphi, from inside a Hook application I have written in C++. The problem is that I don't know how to get some of the data from these Delphi controls. I used pretty standard way to hook the GUI app, using: SetWindowsHookEx(WH_CBT, (HOOKPROC)msghook, hInst, 0); Within my hook processing function (msghook), I have: case HCBT_ACTIVATE: if(m_szModule[0] == '\0') GetProcessName(m_szModule); if ((0== stricmp(m_szModule, "GUIApp.exe"))) { // logs all child windows EnumChildWindows(hWnd, EnumChildProc, 0); } -------------------------------------------- // Call back function that will retrieve and log Window ID, // Window Class Name, and the WindowText BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) { int idChild = GetWindowLong(hwndChild, GWL_ID); char szText[100]; char szClassName[100]; char szBuf[1024]; ::GetWindowText(hwndChild, szText, sizeof(szText)); GetClassName(hwndChild, szClassName, sizeof(szClassName)); sprintf(szBuf, "**** id:%02d, ClassName:%s, [%s]", idChild, szClassName, szText); logFile.LogMessage(szBuf); return TRUE; } -------------------------------------------- The problem is that the output revealed that all the controls of this GUI app do not have Text assosciated with them. GetWindowText returned empty strings. 07/03 06:05:16: **** id:262484, ClassName:TPanel, [] 07/03 06:05:16: **** id:852418, ClassName:TListBox, [] 07/03 06:05:16: **** id:197008, ClassName:THeaderControl, [] 07/03 06:05:16: **** id:197176, ClassName:TSortGrid, [] 07/03 06:05:16: **** id:197104, ClassName:TEdit, [] 07/03 06:05:16: **** id:197084, ClassName:TPanel, [] 07/03 06:05:16: **** id:197094, ClassName:TPanel, [3/07/03 6:04] As you can see above, only one had any text associated with it. I know that all of these controls do have text. I also hooked the TextOutA and TextOutW API's to see what was being drawn on the screen. I will see things like: 07/03 06:05:16: W(0,0)Text on Control1 07/03 06:05:16: W(0,0)Text on Control2 07/03 06:05:16: W(0,0)Text on Control3 So, basically the string "Text on Control1" is the text that appears on the first TPanel from above (id:262484). Is there any way that I can query the TPanel/Window to find this information? I really appreciate any help anyone can provide. . 0