News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How get window handle, which lose active status

Started by bomz, June 30, 2011, 09:51:23 AM

Previous topic - Next topic

bomz

When your application window change status to ACTIVE , how get window handle, which lose active status. I try WM_ACTIVE lParam, NextWindow function, EnumWindows and WM_WINDOWPOSCHANGING but can't get handle

sinsi

Quote from: MSDNIf the low-order word of wParam is WA_ACTIVE or WA_CLICKACTIVE, lParam is the handle to the window being deactivated.
If yours is the window being activated then lParam has the other window handle.
Light travels faster than sound, that's why some people seem bright until you hear them.

bomz

in Theory yes, practically no.
http://msdn.microsoft.com/en-us/library/ms646274%28v=vs.85%29.aspx
QuoteIf the low-order word of wParam is WA_ACTIVE or WA_CLICKACTIVE, lParam is the handle to the window being deactivated. This handle can be NULL.

bomz

This only work 
invoke ShowWindow,hWnd,SW_HIDE
invoke FindWindow,addr WorkerWClName,0
mov ebx, eax
invoke Sleep, 50
invoke GetForegroundWindow
mov esi, eax
.if ebx!=eax
invoke GetWindowText, esi, addr buffer1, 256
invoke MessageBox,0,addr buffer1,0,0
.endif
invoke ShowWindow,hWnd,SW_RESTORE

I hide my window , wait 50 milisec, and get foregroundwindow

lParam of WM_ACTIVATE always NULL
.ELSEIF uMsg == WM_ACTIVATE
mov eax, wParam
.if ax==WA_INACTIVE

.else
mov eax, lParam
.if eax!=0
mov PrevActiveWindHandle, eax
.endif
.endif


with sleep it is not very standby method

hutch--

See if GetFocus(), SetFocus() and the matching 2 messages WM_KILLFOCUS and WM_SETFOCUS are any use to you.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

I try it already - any success

and with Word this don't work. Word edit window is not Editclass

bomz

I make EnumChild window which find all windows with 'edit' style in foreground window. It's show that this 'edit' windows was found, but WM_CHAR WM_SETTEXT and WM_PASTE put text only in notepad. may be deal in WM_CHAR?

;===============================================================
EnumChild proc uses edi esi hwndChild:DWORD,lParam:DWORD
LOCAL buffer[512]:BYTE

invoke GetClassName, hwndChild,ADDR buffer, 512
mov ecx, 5
lea esi, buffer
lea edi, edit
repnz cmpsb
jne @F

invoke wsprintf,ADDR buffer,ADDR template,hwndChild
invoke SetWindowText, hwnd, ADDR buffer

mov eax, FALSE
ret
@@:
mov eax, TRUE
ret
EnumChild endp
;===============================================================


invoke SendMessage, esi, WM_CHAR,edx,1

bomz



GUITHREADINFO struct
        cbSize dd ?
        flags dd ?
        hwndActive dd ?
        hwndFocus dd ?
        hwndCapture dd ?
        hwndMenuOwner dd ?
        hwndMoveSize dd ?
        hwndCaret dd ?
        rcCaret RECT <>
GUITHREADINFO ends

EDITOR GUITHREADINFO <>
mov EDITOR.cbSize, sizeof EDITOR
mov EDITOR.flags, GUI_CARETBLINKING
invoke GetGUIThreadInfo, 0, addr EDITOR
invoke PostMessage, EDITOR.hwndCaret, WM_CHAR,'L',0



PS or mov esi, EDITOR.hwndFocus