![]() |
|
#1
|
|||
|
|||
Problems with TabsSorry to bother you all again, but I've seem to hit a brick wall while experimenting with tabs. This should work, but I can't, for the life of me, figure out why it dosn't. Any help would be much appriciated.
CPP / C++ / C Code:
EDIT: I just remembered yet another question that was bothering me... Recently, I've made a few smallish, mostly useless, programs that include a dialog box, which is, obviously, a resource. Now, it works fine on my computer, running WinXP Home, but when I try to take them to school, running XP Professional, some of the programs using dialogs don't even start. Or, when they do, start acting erratic and don't do what they're supposed to. Is this because of my compiler, my resource compiler, my pathetic coding skills, or some other reason which I have yet to know about? |
|||
|
#2
|
|||
|
|||
|
Quote:
Important disclaimer: I'm not a Windows programmer, but I thought your problem was an interesting opportunity for me to learn a little about tab controls. It looks like you have done the heavy lifting; I just tweaked your SaveTabInfo and SwitchTabInfo a little. The main thing is, if I am reading MSDN correctly: you should set the mask bit for TCIF_PARAM in order to get the text pointer when calling TabCtrl_GetItem() and TabCtrl_SetItem(). I also cleaned up the GlobalAlloc-GlobalFree sequence, I think --- check it carefully, in case I missed something. Anyhow, here are the routines that I changed. (Note the change in CreateWindows: I use sprintf() to format the tab text, and that requires you to include <stdio.h> at the beginning. This method is cleaner than your overwriting characters in the string literal --- technically a no-no, although this version of Borland seems to work with it.) CPP / C++ / C Code:
If I have made any errors or bad assumptions (great or small) I trust that someone will set me straight. In the meanwhile, it seems to be working. Regards, Dave |
|
#3
|
|||
|
|||
|
Ah, that last GlobalFree() and that other flag were the problems, thank you for correcting me on those, it works perfectly now. You had a small bug in the saving function, though, in which you used TabCtrl_GetItem() before initiating any of the variables, I also added in a little loop at the end to free all the allocated memory. So, here's the code, if you want to see the complete working version.
CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
|
Quote:
Ahhh, yes! I appreciate the corrections. I don't know how that GetItem() snuck ahead of the other stuff. Sometimes these things have a mind of their own. I wasn't sure about a final GlobalFree. I know that everything obtained by malloc() must be be free()ed; didn't know about the Windows equivalents. Thanks for the information and example. Nice. Regards, Dave |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cd burner problems | ringmaster | Computer Hardware Forum | 7 | 25-Jul-2006 03:34 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 07:06 |
| Q: selecting a deactivated TAB? (+more on tabs) | Marius Giurgi | FLTK Forum | 4 | 23-Nov-2004 13:03 |
| Geforce fx 5600 problems | SyLuM | Computer Hardware Forum | 0 | 08-Aug-2004 21:41 |
| Chaintech Geforce 5600 FX problems | bartster74 | Computer Hardware Forum | 8 | 04-May-2004 14:16 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The