Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: C++ Help (Read 10841 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

C++ Help

Reply #25
One thing to keep in mind about C, especially when comparing it to high level languages (I consider a high level language to be something like ML, Oz, Haskell, Scheme, etc.), is that C really isn't a whole lot more than a slightly more convenient, portable "assembly".

I think a lot of what is confusing about C is that it's difficult to understand why most things are done the way that they are until you really start to understand memory management at a low level.  Pure assembly is obviously the best help there, but it's even more difficult to learn than C considering the lack of easily accessible tutorials and documentation (have fun wading through the cpu reference manual to dig up the instruction list..).

At any rate, I highly suggest picking up a copy of C Programming Language.  It's quite a small book that covers all of the important stuff and leaves out all of the unneccessary fluff.  It's probably the best C book I've ever read, and the only one I've ever really ended up needing.

C++ is a different story, but trying to jump straight into that before having a really solid understanding of C (including an understanding of how you can "fake" a lot of the features you get in C++ in plain old C) is a recipe for frustration.

C++ Help

Reply #26
Thanks Dibrom, will try and get a copy of that book.

C++ Help

Reply #27
<Random insight>

Your meta_get comparison would be a lot faster if you used const char * instead of string8. The current method would be allocating two new buffers and copying the strings before comparing them. I suppose this wouldn't be a problem if the info class used string8 and string8 had a copy constructor which could use reference counting, and even performing duplication where necessary. (For example, refcount and string both in buffer, and if something needs to modify string, internal or external call a unique() method which dupes the string and sets refcount to 1 on local copy.) That's getting a little too complicated, though.

</Random insight>

C++ Help

Reply #28
I'm continually amazed at how some of the seemingly most basic things in C++ are made so complex.  Programming languages shouldn't be (and as far as I can work out need not be) this complex.  Anyway, onto my question...

How do I implement tabs in a dialog box.  Sounds simple, I know, but damned if I can figure it out.  I've looked at MSDN, but as usual it's a highly technical view of what to do.  I've also looked at foo_history, which has helped a little, but the code spans several files, and most of it I can't get my head around.

Basically, I've set up my dialogs in the same manor as foo_history, with one main dialog page as the config page, and then seperate child dialog's for each tab.  I looked at foosion's code, but it uses so many files, you've got prefs.cpp, prefs.h, the foosion helpers, and goodness knows what else.  Seems overly complex to implement a tab.  I'm looking for the really simple, no frills apporach here.  Any help is appreciated.

@ Dibrom, I've orded that book you suggested.  I anxiously await it's arival.

C++ Help

Reply #29
I'm not real familiar with how, exactly, the foobar stuff works. But essentially you're asking about Property Sheets.

You basically create a class for each page you want to display. This class will derive from CPropertyPage. It'll hold all the controls and layout and such for the page itself. It'll have all the member variables in it to hold the data you get from these controls and so forth.

All these pages get held in a CPropertySheet. You instantiate a CPropertySheet object. Then you instantiate an object for each one of these CPropertyPage derived-classes. For each one of these you create, you add it to the PropertySheet via it's AddPage() function.

How you then get that property sheet to display in the foobar preferences, I do not know. Normally you'd tell it to DoModal() to display a dialog box, or you'd Create() it to do it modelessly. You can probably figure out how to do it by looking at how foo_history does it.

But in any case, that's the gist of it.

C++ Help

Reply #30
Although I havn't used tabs personally, just by looking at MSDN, you dont really need to use property sheets, although you can.  I think thats making it more complex than regular tabs.
All you need to do is create the tab control.
Then wait for messages that the selection changed.
And then display the right page.
You said you read MSDN, were you looking at the example code, its pretty basic and links to all the important macros, messages, and structures.
In the example code:
DoCreateTabControl() creates the tab control and adds the tabs.
MainWindowProc() handles the most basic messages.
TCN_SELCHANGE is wParam of WM_NOTIFY which tells you that they changed the tab.

the important macros are:
TabCtrl_InsertItem()
TabCtrl_GetCurSel()
TabCtrl_AdjustRect()

I'm sure someone more familiar with tabs will be able to provide more info.

 

C++ Help

Reply #31
Meh. Six of one, half dozen of the other. If you're already using MFC, property sheets seem simpler.