I need to create and delete a undetermined amount of windows, how would I keep all the handles of those windows as hWnd##? (hwnd01,hwnd02....) ex. In mIRC when you join a channel the window is created, when you leave the window is deleted...
Posted on 2000-12-01 01:04:00 by the grinch
you can make a arrays of DWORD that would handle your handle In that way, the number of handle will be limited, but you can set a high value.
Posted on 2000-12-01 03:39:00 by (scalp)
If your "windows" are MDI child ones, it won't be a problem at all because Windows keeps all the handles internally. You can always grab the active window handle or even enumerate all child windows. If the windows are created from the same class, you don't even have to keep track of the handles yourself. Windows sends you the handle when it calls your window procedure. If you want to differentiate between the "instances" of windows from the same class, store some ID in cbWndExtra. Your code can then extract the value when it receives the window handle and act accordingly.
Posted on 2000-12-01 05:27:00 by Iczelion
I quite agree with everything just said. But to keep it going... There is often the need to keep track of some number of "things" you cannot determine beforehand. For example, sure, one could track 10 user-opened windows in hWnd1 thru hWnd10 variables, and when the user requests an 11th window, instead pop-up an annoying "WTF are you tring to do? Make me THINK?" message signed "the programmer." Ummm, this is perhaps not the best method. Static variables in .data are quite limiting. Stack and heap variables are much more flexable. Interesting. Hey, FUN too. No more trying to determine how long a string might need be, just alloc as much room as you need, determined at runtime. Yep, more code. Also much more flexable too. So, how to keep track of an arbitrarirly long list? Try a linked list. A linked list is a data structure that can hold all the information about a particular class of beast, plus one extra element: a pointer to the NEXT item in the list. Thus, with a single pointer (to the first element in this linked list) one may walk to any element in it, perhaps counting how many one finds till finally, the last list element NEXT pointer indicates "no more" (perhaps by containing a NULL). The list starts life as a NULL pointer, as items are added the memory for them is alloc'ed and they are added to the last element's NEXT pointer (or the initial pointer for the first item). Of course, code must be worked out to manage such a list (ie, how to delete and add items to the list), but such stuff may be re-used forever.
Posted on 2000-12-02 01:21:00 by TTom
Thanks, helps alot :)
Posted on 2000-12-02 19:48:00 by the grinch