• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

How to make a GUI

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
Since i have been programming in C++ for about a year now i was wondering how to create a gui interface for my programs. One in particular will calculate (with the help of a formula) the CPU rating when OCed.

Does GUI require a seperate program? Also, is it hard?

-Kevin

Edit: I want to put a link to that program on the forums and would rather not have people downloading a DOS based program.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Call some function that's called "window()" or something similar, depending on what libraries and languages you're using. It's not rocket science, just APIs to read.
 

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
Use a function call of window(). So what would i put in the function.

I do not know how to program in VB. I only know the basics and some advanced C++ programming. No where near the level to begin writing huge programs. I think the most i have done is 2 page program.

-Kevin
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
VC++ 6 ?

Create a MFC "dialog-based" application. You can build a simple UI using drag-and-drop in the resource editor, and ClassWizard can create skeleton code functions that are triggered when a button is clicked (pick the BN_CLICKED message).
 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Whats wrong with just calling the win32 API? Theres a good book called Programming with the win32 API, or something (its in my office so i cant tell you for sure). The problem with using any wrappers is compatability. The exact reson i started using the win32 API.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Originally posted by: homercles337
Whats wrong with just calling the win32 API? Theres a good book called Programming with the win32 API, or something (its in my office so i cant tell you for sure). The problem with using any wrappers is compatability. The exact reson i started using the win32 API.
You probably mean Petzold's Programming Windows, the bible of the win32 API.

There's nothing wrong with that approach, and the book and its CD even include skeleton programs that could be used as a starting point.

An MFC dialog-based app just has a much shorter learning time, since it hides a lot of the details from you just like VB. Also, if you statically link the MFC app the exe will run on any version of Windows without needing any DLLs or the monster .NET framework.
 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Nope, not talking about the bible. Theres a good concise book that covers both the GUI stuff and the behind the scenes stuff. Lots of examples, which i like. Youre probably much more knowledgable than i am, i have never really offically released any apps. Whats this about no need of the .net framework. I used have this cocky prick working for me (academic environment) and his apps NEVER ran for me and he always insisted it was my rig. Little stupid turd...
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Nope, not talking about the bible. Theres a good concise book that covers both the GUI stuff and the behind the scenes stuff. Lots of examples, which i like.
Petzold's Programming Windows does all that, but regardless you should be willing to admit there's more work to creating a pure win32 GUI than using drag & drop and classwizard.

Whats this about no need of the .net framework. I used have this cocky prick working for me (academic environment) and his apps NEVER ran for me ...
He was probably giving you debug builds instead of release, or not bothering to check for DLL dependencies. My point was that a statically linked MFC app doesn't require the MFC library DLLs and unlike Visual Studio .Net applications does not require the .Net framework.
 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
@Dave, yea i have Petzolds book too. I think these MS published books are the reason people always say "code bloat" when referring to MS apps. And yes, of course, i would admit that there is less work to drag/drop than pure win32 api calls. Im a scientist though, so im sure there are MANY more knowledgable people than myself on this topic. [edit] that sounded sarcastic, not meant to be. Im not a computer scientist or even a paid programmer for that matter. Although, much of my work requires extensive programming. [/edit]

Ahh, i see. Thanks for clarification. This turd that was working for me was all about .net being the best thing since sliced bread, but couldnt justify it very well. We (my advisor and myself) tried to get this guy (a grad student in the lab) to build upon existing MFC code and since he didnt know MFC he didnt want to do that. Obviously he didnt know .net all that well either, no?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
It does sound like the guy didn't know what he was talking about.

At my last job (MicroCase) our MFC-based statiscal app was bundled with well over a million college textbooks. Thomson Learning (who bought the company in '99) is still using the same MFC code base 5 years later since there has been no reason to change it.

At my current employer (Respondus) we still use MFC, again because there is no value that we can see in re-writing a working MFC app in .Net just to "be netty."

Server-side asp.net and .net components make sense, and .net might make sense if writing a new app from scratch, but re-writing for its own sake does not imbue an app with magic net powers :)
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: Nothinman
Whats wrong with just calling the win32 API?

It's ugly and a lot more work?

But that way of learning how something works is invaluable. some of us had to learn that way

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
But that way of learning how something works is invaluable. some of us had to learn that way

Invaluable? I doubt it. MS wants people to start using .Net and Windows.Forms, MFC will still be included but most likely for compatibility reasons.

That's like saying you should use raw sockets and build your own packets from scratch in your networking app. There's absolutely no reason to do it and the more you let get handled by a sytem library the less chance there is for you to do something stupid.

And on top of that if you use .Net and Windows.Forms there's a chance your app will run on non-Windows machines since there are .Net CLRs for other OSes, if you use MFC you're stuck on Windows.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Understanding how the wrappers work can provide you with an understanding on what the actual aplication interfaces with everything else.

When the wrapper does not provide what you need, then digging into it makes it easier.

For people brought up on the MFC/OWL/GUI/VB wrappers, it is hard to copmrehend what goes on behind the scenes.

When something breaks, it is the old fogeys that may have a clue.
That may be the difference between a coder, programmer and engineer.

And yes, there are exceptions on both sides of the aisle.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I know it can be helpful in debugging some things, but I still wouldn't call it invaluable. But most of my projects are unix console tools with little or no interaction.