News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SetMenu problem

Started by dedndave, February 06, 2011, 03:14:24 AM

Previous topic - Next topic

dedndave

i have a strange problem with SetMenu
it seems that it alters an unrelated dword in initialized data
has anyone else had this kind of trouble?
        .DATA
WinStates        dd 1Fh
;
;
WndProc PROC    hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

        mov     ecx,uMsg
;
;
;
        cmp     ecx,WM_CREATE
        jz      WndPrY
;
;
;
WndPrY: INVOKE  wmCreate,hWnd
        jmp     WndPr0
;
;
;
wmCreate PROC   USES EDI hWnd:HWND

        xor     edi,edi
        INVOKE  LoadMenu,hInstance,IDM_MAINMENU
        mov     hMenu,eax

push WinStates

        INVOKE  SetMenu,hWnd,eax

pop  WinStates
;
;

the push/pop WinStates instructions fix the problem   :dazzled:

jj2007

Very odd, Dave.
WinStates is the first item in .data ? Have you watched in Olly what's happening? Can you post the full code?

dedndave

i think i figured it out ;)
when you call SetMenu, it must send a WM_SIZE message
at any rate, i am close - lol

MichaelW

How could a WM_SIZE message cause your problem?
eschew obfuscation

jj2007

Quote from: dedndave on February 06, 2011, 10:52:41 AM
when you call SetMenu, it must send a WM_SIZE message

Maybe, but even then, on return the value of WinStates is still the same. Use a global var to check if your check is balanced, often that is the problem.

dedndave

my wmSize routine alters WinStates
the routine is in the test phase, and at this point zeros WinStates
however, it is invalid - and i do not want it called until all the control windows are created
the control windows are created right after SetMenu   :P
i'll figure it out today
if i have to, i'll disable wmSize until all control windows are created

dedndave

the solution was simple
in wmCreate, i create all the control windows before i load/set the menu   :bg

dedndave



what's wrong with this picture.....
        ALIGN   16

        OPTION  PROLOGUE:PrologueDef
        OPTION  EPILOGUE:EpilogueDef

wmSize  PROC    dwWidth:DWORD,dwHeight:DWORD

that'll teach me to use copy/paste

jj2007

Let me guess:
...
ret 8
?  :bg

dedndave

#9
oddly enough - that didn't cause the problems
but - EBP was pointing to the wrong place, that's for sure - lol
all kinds of stuff was happening
i fought that fucker for a week

i appreciate the help that i have gotten from Edgar, Jochen, and Alex

EDIT - updated code below

dedndave

by the way...
what tipped me off was when the horizontal scroll bar Y position moved when sizing the window horiontally - lol
i knew i had passed the parms correctly - checked and double-checked   :P

donkey

Hi Dave,

Glad you got it done, it did present some interesting problems and it appears that you've solved them all.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

i wonder what you thought of the way i handled DeferWindowPos   :P
i mean - pushing everything onto the stack then looping

donkey

Good idea, I usually use invoke because GoAsm will assemble it properly for 32/64 bit platforms while push/call will fail but if the app is only ever going to be for 32 bit its a good way to get the job done. Tends to obfuscate the code a bit though, makes it a bit harder to read through the source but that's not an issue if you're the only one whose going to be editing it.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

lol
it seems all my best code is like that
it makes perfect sense to me   :bg
i could eliminate the SHOW loop - and combine it into the HIDE loop - save a few bytes
but, it might be slower, having to draw certain windows twice

EDIT - come to think of it, i could do the shows and hides in a single loop after positioning
a little more complicated, but i think i'll give it a try