Link to home
Start Free TrialLog in
Avatar of TonyJiz
TonyJiz

asked on

FindWindow question.

Hey,

this question is related to icq.

ICQ's messenger window name is #32770.

So I do: handlexyz := FindWindow('#32770', nil);
The textbox of icq is a RichEdit20A.

In that messenger (#32770) window there is one RichEdit20A for the textbox where you type messenges and one RichEdit20A for the messeges of the other person.

So when I do a handlendxyz := FindWindowEx(WIN, 0, 'RichEdit20A', nil);
and then a SendMessage(hwndxyz, WM_GETTEXT, 255, integer(@Buffer));
then it sometimes returns the text of the input textbox and sometimes the text of the other person.

Do you have any ideas why sometimes it returns the input textbox text and sometimes the text of the other person. I guess it has something to do with the focus. The question is, do you have any idea how to get a handle on both textboxes?

Thnx!
Avatar of Ivanov_G
Ivanov_G
Flag of Bulgaria image

you have 2 controls with name "RichEdit20A" ... ?

I recommend you to check it again. As I a tool, I can recomment you is:
http://www.greatis.com/delphicb/windowse/

> "FindWindowEx(WIN, 0, 'RichEdit20A', nil);"
WIN is the the handle of the parent window. So you should do it like this:

handlexyz := FindWindow('#32770', nil);
handlendxyz := FindWindowEx(handlexyz, 0, 'RichEdit20A', nil);
Hmm... with ICQ it is a bit hard huh... relying on #32770 alone is quite 'dangerous', because that is the name used by all standard dialogs.

I guess what you can do after the FindWindowEx is... to check the caption of the window? Because ICQ message windows contain the phrase "Message Session" at the back.

Or, you can actually enumerate through all windows and find the one that contains "Message Session" as its windows title...
Avatar of Eddie Shipman
Dragon Slayer, the second parameter of FindWindow is the Window Title, no need to use FindWindowEx.
From MSDN:

"Syntax
  HWND FindWindow(      
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName
  );

Parameters
    lpClassName
        [in] Pointer to a null-terminated string that specifies the class name or a class atom created
              by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in
              the low-order word of lpClassName; the high-order word must be zero.

        If lpClassName points to a string, it specifies the window class name. The class name can
        be any name registered with RegisterClass or RegisterClassEx, or any of the predefined
        control-class names.

        If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.

    lpWindowName
        [in] Pointer to a null-terminated string that specifies the window name (the window's title).
              If this parameter is NULL, all window names match.

Return Value

    If the function succeeds, the return value is a handle to the window that has the specified class
    name and window name.

    If the function fails, the return value is NULL. To get extended error information, call GetLastError."
Avatar of TonyJiz
TonyJiz

ASKER

Ivanov,

I used that tool. The ICQ message window is just a textbox (RichEdit20A) with a line that seperates the textbox for input and the textbox for messages from the other user. So maybe that there only is one RichEdit20A, that's possible since sometimes the GETTEXT returns the input message and sometimes it returns the messages from the other user. I have no idea why.
About the WIN handle, i copy pasted that wrong, I did do it with the handlexyz and not the win handle.

DragonSlayer,

I don't just rely on #32770, also on the filename, so no need for the message window. It's just that sometimes RichEdit20A returns the input messages and sometimes the messages from the other user. I just want to retrieve the text from both message windows.

Thnx!
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
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
Avatar of TonyJiz

ASKER

That's some great stuff Russell! Points given.

Hey could you also goto https://www.experts-exchange.com/questions/21217560/Sending-messages-to-IAccessible-handle-Question-for-the-delphi-guru's-here.html maybe you know that too.

Anyway, thnx!