Hi all of you,

I'm programming quite some time in asm but I'm encountering very stupid problem with local vars. Probably I;m overlooking something or its my own stupidity :(. So now to the problem, I have a MDI application where I need to keep some local vars and structures, for example hFile for file. I'm opening file at WM_CREATE and storing the handle. then depends on selection of MDI windows I want to change menu according to the filetype but as I noticed by debugging value of my hFile is changing. How I can avoid that??? Here is piece of code:



MDIproc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL hFile:DWORD
LOCAL hWndTree:DWORD
LOCAL hImageList:DWORD
LOCAL hBitmap:DWORD
LOCAL hRAMAProgr:DWORD,hRAMBProgr:DWORD,hMemo:DWORD
LOCAL hRAM:DWORD,hROM:DWORD,hRAMA:DWORD,hRAMB:DWORD,hROMA:DWORD,hROMB:DWORD ; basic tree handles
LOCAL hRAMTones[32]:DWORD,hROMTones[64]:DWORD
LOCAL txtBufer[256]:BYTE

LOCAL tvis:TV_INSERTSTRUCT
LOCAL smp:SMP_Definition
LOCAL memo:SMP_Memo

.if uMsg == WM_CREATE
.if mdiFlag==IDM_NEWDISK

.elseif mdiFlag==IDM_OPENDISK
invoke di_open,hWin,addr smp ; open file and return handle in eax
.if eax==-1
invoke SendMessage,hWin,WM_CLOSE,0,0
mov mdiBusy,0
.endif
mov hFile,eax
PrintLine
PrintHex hFile
PrintHex addr hFile
.endif
mov mdiBusy,0

.elseif uMsg == WM_MDIACTIVATE
PrintText "mdiactivate"
mov eax,hWin
.if lParam == eax
PrintLine
; mov eax,hFile
PrintHex hFile
PrintHex addr hFile
.endif

.elseif uMsg == WM_KEYUP
.if wParam == VK_F6
invoke SendMessage,hClient,WM_MDINEXT,NULL,0
.endif

.endif

invoke DefMDIChildProc,hWin,uMsg,wParam,lParam
Ret0:
ret

MDIproc endp



Thanks for advices

frankie





Posted on 2002-09-23 03:05:54 by frankies
Well, there can be many errors in this code. I don't know which are errors and which are not.

One obvious thing is that hFile is never set to anything when uMsg == WM_MDIACTIVATE.


...Wait! You don't expect the value of hFile to be preserved after you have returned from the proc, do you?
Posted on 2002-09-23 03:48:07 by gliptic

How I can avoid that???


Make it global. :)
Posted on 2002-09-23 04:07:16 by bazik
Well thanks for replies,


first to gliptic:

I know also that WM_MDIACTIVATE isn't changing content of hFile, I don't expect var's to be avaiable when I will finish procedure (in this case close MDI window = or am I wrong?) I just want to keep file handle until MDI window is alive.

now to bazik:

sorry I can't make it global (how I can predict how many MDI windows will be opened) and every MDI window is opening a file. I think it's a bit bullshitish to define for ex. 128 file hadle variables as global and then list in between them. Then I don't really see the use of local vars. Or they are just for one use??? Or I'm getting insane or I dont know anything anymore.

anyway thanks for replies.

Now I trying different things for ex. I noticed that hWin var is always keeping value (or is alway written new?)

frankie
Posted on 2002-09-23 04:23:13 by frankies
Have a look at this topic:
Best place to store a controls data?

Thomas
Posted on 2002-09-23 04:34:18 by Thomas

Have a look at this topic:
Best place to store a controls data?

Thomas


Thats what I wanted to suggest next ;)
Posted on 2002-09-23 04:36:03 by bazik
Thanks guys very much for your help, I'm glad to fix this problem of my stupidity. Sometimes we can't see the errors just because of our eyes in front of them ;o)

Anyway thanks a lot.

frankie
Posted on 2002-09-23 04:43:47 by frankies