is there a way to get the title of an application from its handle? finding a handle of a window thru the name is possible thru FINDWINDOW...
Posted on 2002-11-08 15:04:19 by ploptor


The GetWindowText function copies the text of the specified window's title bar (if it has one)
into a buffer. If the specified window is a control, the text of the control is copied.

int GetWindowText(
HWND hWnd, // handle of window or control with text
LPTSTR lpString, // address of buffer for text
int nMaxCount // maximum number of characters to copy
);


:grin:
Posted on 2002-11-08 15:18:16 by Graebel
I think you use GetText for that. Sorry, can't check I'm on a linux box at the moment.

edit: there you go :grin:
Posted on 2002-11-08 15:19:18 by Hiroshimator
@Graebel:
this doesnt seem to work. it returns captions of edit-boxes, statics, buttons and whatever, but not of window titles.

i'm actually looking for a way which works for the ProcessId returned by Process32First / Process32Next.
with these calls i get a process id thru PROCESSENTRY32.th32ProcessID. and if available, i want to get the title of that ID.
Posted on 2002-11-09 07:46:28 by ploptor
I haven't done this personally but MSDN says

To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.


So would another window be classified as a control?
Posted on 2002-11-09 09:01:26 by gorshing
Dear Mr.Ploptor, :alright:

You can use the GetWindowText to retrieve window captions by
reference to the window handle. Something in your code must
have gone terrible wrong. :grin:

The 'SendMessage' api with the WM_GETTEXT also works for any
type of window, edit-boxes, buttons, etc. (you know the drill).

Is there any specific reason why you use the Process32First /
Process32Next api's? NO? Then why not use EnumWindows
instead?

Posted on 2002-11-09 15:47:31 by natas