The MASM Forum

General => The Campus => Topic started by: jasonabullard on January 23, 2013, 08:28:52 AM

Title: Resizing borderless form
Post by: jasonabullard on January 23, 2013, 08:28:52 AM
Back again with something that is stumping me or I'm having a major brain fart.  Either way here is what the deal is.  I wanted to create a zune like window using two methods.  The first would be using Dwm and I have successfully accomplished this.  However, I'm running into one problem...resizing the window.  Since the borders are gone I know that I have to handle the WM_NCHITTEST message but I'm kind of stuck here...somewhat.  Here is the example of my code so far:


_WM_NCHITTEST:
assume edi:ptr POINT
assume esi:ptr RECT

push [ebp+14h]
pop edi

push 1
push edi
push [ebp+08h]
push NULL
call MapWindowPoints

lea esi, rc

push esi
push [ebp+08h]
call GetClientRect

ret HTNOWHERE


Now this code will actually cause the program to freeze any time the mouse enters into the window and the same applies if I remove ret HTNOWHERE to jmp _DEFER.  My question is how do I properly handle this message.  The examples that I have seen about resizing borderless forms use this same method but return a result of HTTOPLEFT, HTTOP, etc depending on calculations from MapWindowPoints and GetClientRect.  But any time I try to handle this message and the mouse enters the window it freezes and force closes.

I have attached the code but please excuse the mess.   :biggrin:
Title: Re: Resizing borderless form
Post by: qWord on January 23, 2013, 11:03:46 PM
The argument of the RET[N] instruction are the numbers of byte that must be cleaned up (16 for the WndProc) and not a return value. EAX is used for that purpose. Also, you may want to turn of the prologue and epilogue for the WndProc, because the stack frame is currently created two times.
Title: Re: Resizing borderless form
Post by: jj2007 on January 23, 2013, 11:30:16 PM
Quote from: qWord on January 23, 2013, 11:03:46 PM
The argument of the RET[N] instruction are the numbers of byte that must be cleaned up (16 for the WndProc) and not a return value. EAX is used for that purpose.

Indeed a source of confusion. Look at the proggie below with Olly to understand what the three variants do.

include \masm32\include\masm32rt.inc

.code
AppName   db "Masm32:", 0
aproc proc arg1, arg2
  return 12h
  ret 34h
  retn 56h
aproc endp

start:   invoke aproc, chr$("argA"), chr$("argB")
   exit
end start

Title: Re: Resizing borderless form
Post by: MichaelW on January 24, 2013, 03:29:56 PM
Assembling with ML 6.15 there is no automatic stack frame for WndProc because there are no parameters. Do the newer versions of ML do this differently?
Title: Re: Resizing borderless form
Post by: dedndave on January 24, 2013, 09:00:19 PM
i hope not   :biggrin:
but - why doesn't WndProc have 4 parameters ?
at any rate, you could force a prologue and epilogue by creating a dummy local variable
Title: Re: Resizing borderless form
Post by: qWord on January 24, 2013, 10:20:18 PM
Quote from: MichaelW on January 24, 2013, 03:29:56 PM
Assembling with ML 6.15 there is no automatic stack frame for WndProc because there are no parameters. Do the newer versions of ML do this differently?
no, i was my mistake.
Title: Re: Resizing borderless form
Post by: jasonabullard on January 25, 2013, 01:00:50 AM
Thanks for the help guys but I finally found the mistake.  For some reason (why I didn't catch it) I used the following:


lea esi, rc


instead of


lea esi, offset rc


once I changed this it worked perfectly. 
Title: Re: Resizing borderless form
Post by: qWord on January 25, 2013, 01:32:10 AM
you should note that  the code you post breaks with calling convention and corrupt the stack (WndProc). That it runs, has something to do how different windows version handles such failures ( e.g. the 64 Bit versions ignore any exception in the WndProc).
Title: Re: Resizing borderless form
Post by: jj2007 on January 25, 2013, 06:08:26 AM
Quote from: jasonabullard on January 25, 2013, 01:00:50 AM
Thanks for the help guys but I finally found the mistake.  For some reason (why I didn't catch it) I used the following:


lea esi, rc


instead of


lea esi, offset rc


once I changed this it worked perfectly.

Lucky you :t
However, it helps occasionally to look at code through Olly's eyes:
.data
rc RECT <12, 34, 56, 78>   
.code
  lea esi, rc
  lea esi, offset rc
  mov esi, offset rc

00401025       ³.  8D35 00804000    lea esi, [rc]
0040102B       ³.  8D35 00804000    lea esi, [rc]
00401031       ³.  BE 00804000      mov esi, offset rc

;)
Title: Re: Resizing borderless form
Post by: hfheatherfox07 on January 29, 2013, 01:07:11 PM
Hello ,
Were did you get uxtheme.inc and uxtheme.lib?


or can anybody login here and get it?  http://www.asmcommunity.net/board/index.php?topic=16091.0

Thank you
Title: Re: Resizing borderless form
Post by: hfheatherfox07 on January 29, 2013, 01:21:04 PM
I found one version