Okay, I have this at the end of my WM_CREATE of ChildProc (the process for the mdi child window):

mov Tie.imask, TCIF_TEXT
mov Tie.pszText, offset MDIChildTitle
invoke SendMessage, hTabWin, TCM_INSERTITEM, ?, addr Tie

It works for putting a tab on the control with the filename, but the index number is where my problem is. I need to get that index number from the mdi child window somehow when its closing to delete the tab that corresponds to it. I'm kindof stumped ;)

Thanks again everyone
Posted on 2001-07-29 13:45:23 by karl
or is there a better srategy for putting the tabs on there?

i dunno, hell
Posted on 2001-07-29 13:47:19 by karl
Use Structures, and dynamically allocate some heap for this structure of memory...

On every new Created Child Window, you build a new tab.. So at this point you may have a global variable or something that gives you the total # of MDI's at the moment.. use this # as the Tab #... As well allocate memory off the heap for your structure, and place all needed information withing this structure.. (IE.. child handle.. Tab #, anything else that causes this headache).. Then use the SetWindowLong to store the address to this newly structured heap memory...

So l8r when you need to do somthing about "a" child window, just use Getwindowlong.. Get the address to the structured memory, get the handle and the tab id out of it, and then do behaviors like remove tab etc.. etc.

Warning: If you allocate heap memory, you must free it befor your program exits! So more management is needed on the creation of Child Windows and there Destroying.. As well if you just exit or ALT-F4 you should parse all windows for the memory addresses and destroy each of them before the program leaves...

Selling point here: This is one area that Objects would serve as an asset. A properly written Object (such as a Heap Memory manager object) would internally allocate memory from a structure size, and keep track of it in a linked list, as well as returning the memory address. On exiting the program.. your only need to "DESTROY managerObject".. and internally it should walk though its list and free any memory allocated... This saves alot of headache making sure you dont have memory leaks etc. etc. As well, being an object, separate instances can be created to group certain processes needing heap memory... IE) one instance could be named MDIChildWindowHeaps, and another could be NetworkingHeaps.. etc. etc Here if your done with networking stuff only.. but the program itself is not finished.. you can "DESTROY NetworkingHeaps" and only heap memory allocated through this object (presumable Networking stuff) will be free'd...

Anywho, Back to earth :), I think the first solution should fix your delema if i got your problem understood...

Posted on 2001-07-29 23:07:37 by NaN
very, very confused. i dont know how to create structures in masm, nor do i know how to allocate a heap of memory. i need more to know which funtions i should study to point me in the right direction.. other than set/getwindowlong, although they seem weird to me also.. Why couldnt i just use the 32bit number that GWL_USERDATA supplies for each one, and set that to the index of the tab, then when the window closes, i would just have to getwindowlong,gwl_userdata ... and each tab index would have the same number as its corresponding window.. i tried that with no luck... the code compiled but didnt seem to work.. do you think that method could've been possible, or was that number that gwl_data supplied not okay to use with the index of a tab?
Sorry i'm such a newbie.. i've come so far, and i've been slacking lately as my programs are getting more complicated... i'm moving soon and will be stuck with no internet for a while so i need to get things going! :) NaN you have been a great help.. thanks!
Posted on 2001-07-30 00:05:29 by karl
ahh! i see you have a discussion about struct's on your webpage! how wonderful!! pretend like i didnt say that though, and help like you usually about the rest of the stuff :)
Posted on 2001-07-30 00:18:03 by karl
Im glad that its going to good use... (for a bit i was wondering if it was not important knowledge... :) )

as for your current problem..

(Note: this is uncompiled code)

mySrtuct STRUCT
hWnd dd ?
hTabID dd ?
myStruct ENDS


invoke GetProcessHeap
invoke HeapAlloc, eax, NULL, SIZEOF myStruct
mov MyNewDataAddressForThisChildWindow, eax

invoke SetWindowLong, hThisWindow, GWL_USERDATA, MyNewDataAddressForThisChildWindow

;because this in now annoying to have a very long name..
mov edx, MyNewDataAddressForThisChildWindow
mov (myStruct PRT [edx]).hWnd, CurrentChildWindowhandle
mov (myStruct PRT [edx]).hTabID, The#IGaveWhenICreatedANewTab

.... ; Somewhere else in your code when dealing with ANY child window

invoke GetWindowLong, hWnd, GWL_USERDATA
mov edx, eax

; eax has the child window handle
mov eax, (myStruct PTR [edx]).hWnd

; now ecx has the TAB ID# for this specific window
mov ecx, (myStruct PRT [edx]).TabID

;Now do generic behaviours....

This is the method... lean and mean style.. it will need "moulding" to how you wrote your code.. but this IS it in essence... hope this is more clear.. (as i know it is not a perfectly compilable solution)..

Posted on 2001-07-31 00:53:56 by NaN
BTW... Dont forget to free the memory allocated!!! (i did in my above post, so...)

....; Somewhere else in you code, free the memory no longer being used..

invoke GetProcessHeap
invoke HeapFree, eax, NULL, OldAllocatedHeapMemory

Posted on 2001-07-31 00:56:10 by NaN
Cant seem to get this right... take a look if you can get a chance

Posted on 2001-08-09 11:04:48 by karl