The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bomz on June 30, 2011, 09:51:23 AM

Title: How get window handle, which lose active status
Post by: bomz on June 30, 2011, 09:51:23 AM
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 (http://smiles.kolobok.us/standart/pardon.gif)
Title: Re: How get window handle, which lose active status
Post by: sinsi on June 30, 2011, 10:10:56 AM
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.
Title: Re: How get window handle, which lose active status
Post by: bomz on June 30, 2011, 10:22:51 AM
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.
Title: Re: How get window handle, which lose active status
Post by: bomz on June 30, 2011, 10:49:14 AM
This only work  (http://smiles.kolobok.us/standart/black_eye.gif)
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
Title: Re: How get window handle, which lose active status
Post by: hutch-- on June 30, 2011, 12:57:51 PM
See if GetFocus(), SetFocus() and the matching 2 messages WM_KILLFOCUS and WM_SETFOCUS are any use to you.
Title: Re: How get window handle, which lose active status
Post by: bomz on June 30, 2011, 01:39:58 PM
I try it already - any success
(http://xmages.net/storage/10/1/0/7/d/upload/2055b3a5.gif)
and with Word this don't work. Word edit window is not Editclass
Title: Re: How get window handle, which lose active status
Post by: bomz on June 30, 2011, 07:57:38 PM
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
Title: Re: How get window handle, which lose active status
Post by: bomz on June 30, 2011, 10:10:08 PM
(http://smiles.kolobok.us/standart/dance2.gif)

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

(http://smiles.kolobok.us/standart/dance4.gif)

PS or mov esi, EDITOR.hwndFocus