The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: knockjoke on February 13, 2011, 11:47:15 PM

Title: how to call "DwmExtendFrameIntoClientArea"
Post by: knockjoke on February 13, 2011, 11:47:15 PM
hey, i tried it like this:


; prototype
DwmExtendFrameIntoClientArea typedef PROTO STDCALL :DWORD,:DWORD
ExtendFrameIntoClientArea equ <(type DwmExtendFrameIntoClientArea) PTR eax>

.data
dwMargins           dd 4 dup(-1)

invoke LoadLibrary, CADD("Dwmapi.dll")
invoke GetProcAddress, eax, CADD("DwmExtendFrameIntoClientArea")
.if eax > 0
invoke ExtendFrameIntoClientArea, hInst, addr dwMargins
.endif


But the window doesnt get transparent like it should be... Did I do something wrong? dwMargins needs to be set to -1 to apply it to the aero glass effect to the whole window.
Or is there another way to achieve an effect like this: http://www.codeproject.com/KB/directx/umvistad3d.aspx
Thanks.
Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: Tedd on February 14, 2011, 12:26:09 AM
Did you give your window the WS_EX_COMPOSITED extended style?

Also, the first parameter to ExtendFrameIntoClientArea should be the window handle, not hInst.
Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: Gunner on February 14, 2011, 12:39:06 AM
Also, if you are getting the proc address, why aren't you using it?

        invoke LoadLibrary, CTEXT("Dwmapi.dll")
    invoke GetProcAddress, eax,CTEXT("DwmExtendFrameIntoClientArea")
.if eax > 0
    push    offset Margin
    push    hWin
    call    eax   
.endif




Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: lingo on February 14, 2011, 02:09:55 AM
it works for me:  :wink
On_wm_activate:
; Handle window activation.
; Extend the frame into the client area.
mov ecx, [esp+1*4]                    ; ecx->hWnd ; ecx->hwnd
sub esp, sizeof MARGINS
mov [esp].MARGINS.cxLeftWidth,8
mov [esp].MARGINS.cxRightWidth,8
mov [esp].MARGINS.cyTopHeight,36*5
mov [esp].MARGINS.cyBottomHeight,37
invoke DwmExtendFrameIntoClientArea, ecx, esp ; esp->addr MARGINS
add esp, sizeof MARGINS
ret 4*4
Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: knockjoke on February 14, 2011, 12:00:17 PM
Thanks to everyone but I still didnt got it working... :(

MARGINS struct
cxLeftWidth DWORD ?
cxRightWidth DWORD ?
cyTopHeight DWORD ?
cyBottomHeight DWORD ?
MARGINS ends

PMARGINS typedef ptr MARGINS


.ELSEIF eax==WM_ACTIVATE
sub esp, sizeof MARGINS
mov [esp].MARGINS.cxLeftWidth,-1
mov [esp].MARGINS.cxRightWidth,-1
mov [esp].MARGINS.cyTopHeight,-1
mov [esp].MARGINS.cyBottomHeight,-1

invoke LoadLibrary, CADD("Dwmapi.dll")
invoke GetProcAddress, eax, CADD("DwmExtendFrameIntoClientArea")
.if eax > 0
push esp
push hWnd
call eax
.endif


Whats wrong? eax is always > 0 and the hWnd is the one from MainWndProc   PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: dedndave on February 14, 2011, 02:59:51 PM
see if it's loading the library correctly
what OS are you using ?
Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: MichaelW on February 14, 2011, 03:18:24 PM
If the library did not load correctly, then GetProcAddress should be failing. What is the return value from the called function?
Title: Re: how to call "DwmExtendFrameIntoClientArea"
Post by: knockjoke on February 14, 2011, 03:43:18 PM
Ah, got it working now.. I passed a wrong param to another function...
Thank you guys. :bg