The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bomz on June 25, 2011, 08:45:08 AM

Title: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 08:45:08 AM
How save window position but exclude case it maximize

this save window position when it resized excluding case it maximize
.ELSEIF uMsg==WM_SIZE
.if wParam==SIZE_RESTORED
invoke GetWindowRect, hWnd, addr rect

but also need save window position when it MOVE
if use WM_MOVE - this message send also when window maximized and it send before WM_SIZE
WM_MOVING WM_RESIZING send in the very beginning of moving or resizing when window not change it size/position already
(http://smiles.kolobok.us/light_skin/unknw.gif)
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 09:46:34 AM
This work
.ELSEIF uMsg==WM_WINDOWPOSCHANGED
mov ebx, lParam
add ebx, 24
mov eax, [ebx]
.if eax !=32804 && eax !=536877207
sub ebx, 4
mov eax, [ebx]
mov WHeight, eax
sub ebx, 4
mov eax, [ebx]
mov WWidth, eax
sub ebx, 4
mov eax, [ebx]
mov YPosition, eax
sub ebx, 4
mov eax, [ebx]
mov XPosition, eax

.endif
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 10:06:45 AM
My application have button - stay on top , this corectly .if eax !=32804 && eax !=536877207 && eax !=6163

But may be exist more simple method, or right method ? ? ?
Title: Re: Save window position exclude it maximize
Post by: jj2007 on June 25, 2011, 11:52:08 AM
Quote from: bomz on June 25, 2011, 10:06:45 AM
My application have button - stay on top , this corectly .if eax !=32804 && eax !=536877207 && eax !=6163

But may be exist more simple method, or right method ? ? ?

You do not like IsZoomed??
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 11:57:27 AM
I don't know about it
Title: Re: Save window position exclude it maximize
Post by: jj2007 on June 25, 2011, 12:08:49 PM
.if !rv(IsZoomed, hWnd)
      invoke GetWindowRect, hWnd, addr rect
      ...
.endif
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 12:12:09 PM
This need the saving of windows position/size in two places of code. my method only one. I hope that it is possible to get windows size minimal which window remmember when back from maximize
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 01:53:44 PM
      .if eax !=32804 && eax !=536877207 && eax !=6163 && eax !=33072 && eax !=536877187 && eax !=6155

Your method better. This parametres need when window minimize to tray


.ELSEIF uMsg==WM_MOVE
invoke IsZoomed, hWnd
.if eax == 0
invoke GetWindowRect, hWnd, addr XPosition
mov eax, XPosition
mov ebx, YPosition
sub WWidth, eax
sub WHeight, ebx
.endif

.ELSEIF uMsg==WM_SIZE
.if wParam==SIZE_MINIMIZED

.elseif wParam==SIZE_RESTORED
invoke GetWindowRect, hWnd, addr XPosition
mov eax, XPosition
mov ebx, YPosition
sub WWidth, eax
sub WHeight, ebx


It's better to prevent all unknown events which may cause ZERO size of windows (http://smiles.kolobok.us/light_skin/search.gif)
Title: Re: Save window position exclude it maximize
Post by: dedndave on June 25, 2011, 03:41:31 PM
i thought i was the only one that looked at wParam in WM_SIZE   :P

;WM_MOVE

;EDX = hWin

        INVOKE  GetWindowRect,edx,offset wr
        jmp short WndPr3

;WM_SIZE

;ECX = WM_SIZE = 5
;EDX = hWin

;if maximized, we set MaxFlag = 0
;otherwise, we set MaxFlag = hWin

;wParam:
;
;SIZE_RESTORED  EQU 0
;The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies
;
;SIZE_MINIMIZED EQU 1
;The window has been minimized
;
;SIZE_MAXIMIZED EQU 2
;The window has been maximized
;
;SIZE_MAXSHOW   EQU 3
;Message is sent to all pop-up windows when some other window has been restored to its former size
;
;SIZE_MAXHIDE   EQU 4
;Message is sent to all pop-up windows when some other window is maximized

WndPr0: shr     ecx,1              ;ECX = 2
        sub     ecx,wParam
        jz      WndPr2             ;SIZE_MAXIMIZED

        jc      WndPr3             ;SIZE_MAXSHOW or SIZE_MAXHIDE

        dec     ecx
        jnz     WndPr1             ;SIZE_RESTORED

        mov     MaxFlag,edx        ;SIZE_MINIMIZED
        jmp short WndPr3

WndPr1: push    edx
        INVOKE  GetWindowRect,edx,offset wr
        pop     ecx

WndPr2: mov     MaxFlag,ecx
        movzx   eax,word ptr lParam+2
        movzx   ecx,word ptr lParam
        call    wmSize

WndPr3: xor     eax,eax
        ret
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 04:06:21 PM
it's not enough to decide task because to save windows position/size needs not only scan WM_SIZE but WM_MOVE too.
Title: Re: Save window position exclude it maximize
Post by: dedndave on June 25, 2011, 04:18:22 PM
yes - i added my WM_MOVE code in the post above
the "wr" RECT always has the current window rectangle
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 04:58:08 PM
sure? when window MAXIMIZE it get as WM_MOVE first and than WM_SIZE. and problem is not in WM_SIZE but in WM_MOVE
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 05:06:51 PM
WS_TABSTOP not working
invoke LoadAccelerators,hInstance,IDR_MAINACCEL
mov hAccel,eax
.while TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.break .if (!eax)
invoke IsDialogMessage,hwnd,addr msg
.if eax==FALSE
invoke TranslateAccelerator,hwnd,hAccel,addr msg
.if eax==0
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endif
.endif
.endw


invoke CreateWindowEx, NULL, addr ListViewClassName, NULL,\
WS_CHILD or WS_VISIBLE or LVS_REPORT or LVS_SHAREIMAGELISTS or LVS_SHOWSELALWAYS or WS_TABSTOP,\
0,0,0,0, hWnd, NULL, hInstance, NULL
mov hList, eax


want TAB set focus to LISTVIEW (http://smiles.kolobok.us/light_skin/scratch_one-s_head.gif)
Title: Re: Save window position exclude it maximize
Post by: dedndave on June 25, 2011, 05:21:23 PM
sorry - i should have mentioned this....

i wanted the "wr" RECT to retain the most recent un-maximized window size
that info is saved in an INF file as the window size - also in the INF, a bit is set if maximized
i am using it a little differently than you are   :P
Title: Re: Save window position exclude it maximize
Post by: bomz on June 25, 2011, 07:23:23 PM
find new extreme situation - ALT + TAB. back to WM_WINDOWPOSCHANGED
.ELSEIF uMsg==WM_WINDOWPOSCHANGED
mov ebx, lParam
add ebx, 24
mov eax, [ebx]
.if eax==2053 || eax==4 || eax==4102
sub ebx, 4
mov eax, [ebx]
mov WHeight, eax
sub ebx, 4
mov eax, [ebx]
mov WWidth, eax
sub ebx, 4
mov eax, [ebx]
mov YPosition, eax
sub ebx, 4
mov eax, [ebx]
mov XPosition, eax
.endif
invoke DefWindowProc,hWnd,uMsg,wParam,lParam


for save maximize-minimize flag - 32804. this message send each time when window max/min

if application use sndPlaySound
.if eax==2053 || eax==4 || eax==4102 || eax==2049