Click to See Complete Forum and Search --> : child windows or components


rossbob
December 10th, 2006, 06:30 AM
i want to include a method in a dll i have written that can copy the text from a 3rd party app. the app is called TTWin which is popular host access (telnet etc) software. so what the dll needs to be able to do is copy all the text in a panel component of the app. I am going to try and use the GetWindowText method but need to know how to find the handle of the component in the parent window. I know how to find the window handle of the parent, that isnt a problem, but have no idea how to find the panel id. i am mostly wondering if i need to find a child window because i kinda know how to do that using EnumChildWindows but i get the distinct feeling that a component is not a child window. I dont really want people to tell me how to code this whole thing, only need instructions or directions for finding the handle of a child component/window please. Please also let me know if i am heading the wrong direction or if you dont understand what ultimately i am trying to achieve.

Cheers for your help.

rossbob
December 10th, 2006, 06:42 AM
ok..i think i have worked out the it is still a child window even though it is a panel within the parent that i want to access...i know whats the classname is...can i find the handle using the class name ?

rossbob
December 10th, 2006, 10:34 AM
ok...i have worked out how to find the handle of the component...now can anyone tell me how to get the content of the window as text...MSDN says i can use the function internalGetWindowText but MS V6c++ says it cant find the method or something like that...i am including the correct includes as MSDN says window.h and winuser.h but still it fails...any help guys is much appreciated...

rossbob
December 10th, 2006, 07:19 PM
can somebody please comment...if you dont understand what im after or i have posted in the wrong forum etc etc then please let me know. Am i looking in the right direction ?

wildfrog
December 10th, 2006, 07:37 PM
MSDN says i can use the function internalGetWindowText but MS V6c++ says it cant find the method or something like that...i am including the correct includes as MSDN says window.h and winuser.h but still it fails...any help guys is much appreciated...You can read about that function here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/internalgetwindowtext.asp). Take an extra look at the remark section. It says that you'll need Windows 2000 (or newer) and that you'll have to use dynamic linking (GetProcAddress) in versions prior to XP.

Another solution is to send WM_GETTEXT directly to the control.

- petter

rossbob
December 12th, 2006, 04:50 PM
thats the way i have been trying to do it using WM_GETTEXT and SendMessage however it is still only getting the Window Caption of the window i am trying to get the text from. I have identified the component that i am certain is the correct window but no matter what i do it just gets the window caption. Any other suggestions.

MrViggy
December 12th, 2006, 05:11 PM
AFAIK, text boxes have no captions. Are you sure you have the handle of the text box that you want to get the text from?

Viggy

rossbob
December 17th, 2006, 05:27 PM
actually i am not sure of this...i am using spy++ to try and work it out and it seems to be the correct component...would spy++ give me the correct component...when using the highlight feature of spy++ it seems to be showing me the component i want as well...is there a better way of finding the correct component...do i definately not have the correct one already...

rossbob
December 17th, 2006, 06:39 PM
if i print the buffer text that i am getting will i need to convert from ansi or something like that for it to print correctly...when i test this method i am getting the buffer ammt times what looks like a 'q' characher...all the same...no difference..

rossbob
December 18th, 2006, 08:55 PM
anyone got any ideas here.

MrViggy
December 19th, 2006, 06:01 PM
Have no idea what this means:
if i print the buffer text that i am getting will i need to convert from ansi or something like that for it to print correctly...when i test this method i am getting the buffer ammt times what looks like a 'q' characher...all the same...no difference..
Can you post your code?

Viggy

rossbob
December 19th, 2006, 09:03 PM
This is my code...the first part finds the child component that i want...assuming i have the correct window (i have confirmed the hwnd is the correct one) it returns strange text..see below..i thought maybe that is ansi text or something and that i might need to convert to something else...not sure how to do that or if that is even correct. when i change my code to look for a component that has a label name my code is printing out that text as normal text.


JNIEXPORT jstring JNICALL Java_ifmsGUI_FocusApp_getTheWindowText
(JNIEnv *env, jobject obj, jstring title) {

HWND hwnd = NULL;
const char *str = NULL;
TCHAR buf[5000];

str = (env)->GetStringUTFChars(title, 0);

hwnd = FindWindow(NULL, str);

if (NULL != hwnd)
hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
if (NULL != hwnd)
hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
if (NULL != hwnd)
hwnd = FindWindowEx(hwnd, NULL, "TTTWinInternal", NULL);

(env)->ReleaseStringUTFChars(title, str);


WPARAM length = SendMessage(hwnd,WM_GETTEXTLENGTH,0,0);

SendMessage(hwnd,WM_GETTEXT,4999,(LPARAM)buf);


printf( "The item is %s\n%d", buf, length);

jstring temp = (env)->NewStringUTF(buf);

return (jstring) NULL;

}


the Strange text:

╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠H▀Ó