News:

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

Main Menu

Resizing borderless form

Started by jasonabullard, January 23, 2013, 08:28:52 AM

Previous topic - Next topic

jasonabullard

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:

qWord

#1
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.
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

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


MichaelW

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?
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

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

qWord

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.
MREAL macros - when you need floating point arithmetic while assembling!

jasonabullard

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. 

qWord

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).
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

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

;)

hfheatherfox07

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
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.