View Full Version : Need Help With Windows Applications In C++
01-02-2003, 09:25 PM
For all of you programmers out there familiar with C++, how would you program a button to open a new window in a dialog based executible file?
01-02-2003, 09:29 PM
I'm a little confused by what you're trying to do. Are you using MFC or the straight Windows API? Do you have the button/main window code done and you're just trying to open a second window? Finally, what do you want to have appear in this new window?
Anyway, either reply here or email me and I'll hook you up with some code snippets for any/all of these cases (I have a lot laying around from RoboGUI and RoboEmu).
01-02-2003, 09:33 PM
First of all, I'm using MFC and second of all, I want the button displaying "Search" to open a new window and search for a specific file in a database. So far, I have about half of the project done. All of the windows are made, and all the buttons, etc. are in place. All I have to do is program the buttons to open new windows, save files, load files, search for files using specific keywords, and import pictures.
01-02-2003, 09:44 PM
In that case, just create a message handler for the button using Class Wizard. Assuming you decide to call it something like OnSearchButton and your class for your search dialog is called CSearchDlg, the function would look something like this:
if(ret==-1 || IDABORT)
//ret contains value passed to EndDialog. Process accordingly
That's the basics. If you're looking for something more advanced, email me.
01-02-2003, 09:46 PM
Uh, where exactly in the code would you put this? I'm actually more familiar with DOS based and I wanted to learn Windows based.
01-02-2003, 09:53 PM
Try this book.
Programming Windows by Charles Petzold (http://www.amazon.com/exec/obidos/tg/detail/-/157231995X/qid=1041562236/sr=8-2/ref=sr_8_2/002-0650594-8469667?v=glance&s=books&n=507846)
I know you may not want to read books, but it's the best Windows programming book you can buy. It's probabaly the only one you really need.
01-04-2003, 11:10 PM
Actually, One by Andre LaMonth is pretty good (I think it's called "Tips By Window Guru's" or something like that (search for it over at GameDev.Net (http://www.gamedev.net)))
01-05-2003, 01:35 AM
Beware of Lamothe books... they're good to learn by, but the rule of thumb is never, ever use the style of coding he does. 99% of the time it's considered just plain bad form and nastily inefficient. Still, I learned DirectX through one of his books, and after hanging around some real programmers to straighten out my misuse of some stuff, it worked real well :) More on-topic, if you're using MSVC++ 6, I belive double-clicking the search button in the resource editor while holding CTRL will bring up the place you need to put the aforementioned code. You'll need to make a class for your search dialog, and the same procedure (or at least a similar one; I'm doing this from memory) will create that class from the resource. Good luck and happy coding.
PS - Gamedev.net rules, and you really need to check out the chat. It'll solve all your programming woes.
01-05-2003, 01:37 AM
Yeah, just ditch the CTRL key--you don't need it.
01-05-2003, 10:13 AM
GameDev is alright, but they still need to update their articles more. But more topic, this actually might depend on your compiler. Because MSVC++ .NET is different than MSVC++ 6 (or below). I'm not exact on this statement, but I've seen it, and read reviews about how MSV* .NET is different than MSV* (where the stars stand for like 'B' for Visual Basic)...plus, MSVC++ .NET seems more like VB 6 for the fact that you have drag-and-drops (unless I was looking at a wrong box)
vBulletin® v3.6.4, Copyright ©2000-2018, Jelsoft Enterprises Ltd.