News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

detect if the window of my app is totally being covered by another window

Started by Siekmanski, May 26, 2013, 08:32:46 PM

Previous topic - Next topic

Siekmanski

Thanks Dave,
Your "IsWindowHidden" routine works!  :t

                invoke      IsWindowHidden,hWnd
                .if (eax == FALSE)
                    invoke      RenderD3d
                .else
                    invoke      Sleep,100
                .endif


Now if the window is totally covered it doesn't consume all cpu usage.  :biggrin:

Hi jj2007,
Yes you're right, but nonzero (if an update region exists) or zero (if one does not) it didn't work in my case.
Maybe it's the way D3D9 handles things???
Creative coders use backward thinking techniques as a strategy.

dedndave

there are ways to fool it, but you'd have to really go out of your way   :P

TouEnMasm

Fa is a musical note to play with CL

dedndave


dedndave

part of that function can be simplified to remove the branches
also, the masm32 library has the "rv" macro
    .if iType==NULLREGION
        mov     eax,OBS_COMPLETELYCOVERED
        jmp     FindeGetClientObscuredness
    .elseif iType==COMPLEXREGION
        mov     eax,OBS_PARTIALLYVISIBLE
        jmp     FindeGetClientObscuredness
    .endif
    INVOKE  GetClientRect,hwnd,addr rcClient
    .if FUNC(EqualRect,addr rc,addr rcClient)
        mov     eax,OBS_COMPLETELYVISIBLE
        jmp     FindeGetClientObscuredness
    .endif
    mov     eax,OBS_PARTIALLYVISIBLE

FindeGetClientObscuredness:
    ret

    .if iType==NULLREGION
        mov     eax,OBS_COMPLETELYCOVERED
    .elseif iType==COMPLEXREGION
        mov     eax,OBS_PARTIALLYVISIBLE
    .else
        INVOKE  GetClientRect,hwnd,addr rcClient
        .if rv(EqualRect,addr rc,addr rcClient)
            mov     eax,OBS_COMPLETELYVISIBLE
        .else
    mov     eax,OBS_PARTIALLYVISIBLE
        .endif
    .endif
    ret

qWord

MREAL macros - when you need floating point arithmetic while assembling!

dedndave

mine probably doesn't work, either

there is a work-around - you just have to find the handle for the worker window

hutch--

Have I missed something here or is the obvious being missed, what is wrong with checking if the potentially obscured window has the focus ?

dedndave

that would tell you if it has keyboard focus

but, he wants to stop updating the window when it is completely hidden from view
a window can be fully or partially visible and not have keyboard focus

hutch--


TouEnMasm

Quote
does not work when Windows Aero is enabled.
Don't know,what is that ?,just vista ?.
Fa is a musical note to play with CL

qWord

Quote from: ToutEnMasm on May 28, 2013, 04:20:29 AM
Quote
does not work when Windows Aero is enabled.
Don't know,what is that ?,just vista ?.
I'm not sure about the correct nomenclature, but this links should  make it clear:
http://en.wikipedia.org/wiki/Desktop_Window_Manager
http://msdn.microsoft.com/en-us/library/windows/desktop/aa969540(v=vs.85).aspx
MREAL macros - when you need floating point arithmetic while assembling!

Siekmanski

Thanks ToutEnMasm  :t

Nice example, it seems to be exactly what I need.  :biggrin:
I'll study it and test it in my source code.

edit:
Thanks guys for all the input.
this does the job, I'm happy!  :eusa_dance:
                .if (!m_Windowed)
                    invoke      RenderD3d       ; in fullscreen mode
                .else
                    invoke GetClipBox,hDC,addr rcClipBox
                    .if (eax != NULLREGION)
                        invoke      RenderD3d    ; in window mode
                    .else
                        invoke      Sleep,1
                    .endif
                .endif


F! = toggle fullscreen
Creative coders use backward thinking techniques as a strategy.