Thursday, July 9, 2009

C++ and GUI?

I am in college and it seems like all we do is write shitty dos programs that do dumb things that no one would care about....When do you get to the point where you can write a program that is actually useful with a GUI?

C++ and GUI?
%26gt;%26gt; I am in college and it seems like all we do is write shitty dos programs





Correction, you write poor quality *console* programs. DOS is an obsolete OS that I certainly hope you are not writing code for.





%26gt;%26gt; that do dumb things that no one would care about





Because you aren't able to do things that people *would* care about. Learn to walk before you can run.





If C++ is your first programming language, then you have no prior exposure to important computer concepts and paradigms needed in serious programming. Then you are just starting to crawl.





%26gt;%26gt; .When do you get to the point where you can write a program that is actually useful with a GUI?





When you get to the point where you can write a quality console program in C++. Look, GUI programming is just an application. You can't program GUIs in C++, if, say, you don't know C++ itself. And believe me, if you are asking this question, you most likely don't know much of it.





There is no special C++ code for GUIs, or networking, and so on. They are applications of C++. When working with GUIs, you will have to learn some API, like Windows API, MFC, GTK+, QT, etc. When learning the APIs, the expectation is that you know C++. An example is WxWidgets. You subclass Window or whatever to create a window element, but if you don't understand the concept of subclassing in C++, then what's the point?





If you are really getting fed up with console programs and want to take a peek at what GUI programming is like, then I'll give you some initial steps.





1) Figure out what API you want to use. Your choice depends on your conditions. Do you want a GUI program that only works on Windows, or something that works on Macs, Windows, and Linux? What about the level of abstraction?





Choices include: (Windows only:) Win32 API, MFC, Winforms (If you have .NET), (Cross platform) GTK+, QT, WxWidgets, FLTK, and more. There is no best one.





2) Learn your toolkit of choice. The expectation is you know the programming language used by the API.





Have fun googling.
Reply:You won't in college. I've never known a college to teach visual programming, it's just not done. You are there to learn the basics and the fundamentals of programming. When you get your degree, you'll use visual programming probably almost exclusively.





What year are you? Your programs might be dumb now, but I guarantee they should be challenging by your junior / senior year. You might not find the lessons valuable now, but when you do begin visual programming, you certainly will understand why you had to learn what they are teaching you.
Reply:On DOS you will have to write your own GUI. You can start with a text-based gui. There should be a console or DOS library with nice text routines. In Turbo C it should be CRT. Maybe it is easier accessing directly the video card. It was [$B800:00]?





DOS C languages do have graphic libraries, in Turbo C++ it's BGI. You will have to find elsewhere DOS calls for mouse support, they are easy to use. Fonts are really messy. It's also kinda complicated integrating fonts and the BGI driver into an .EXE





I think the Allegro library requires a DOS 32bit C compiler, it has grapics, mosue, menus and dialogs, and maybe even sound. But I think your college professor will consider it "cheating".





The first thing I did when I began college was to write a Msgbox function in text mode, and it could also be used as menus. With it I could simulate pull down menus, etc etc. I did also write a simple graphical GUI in Turbo Pascal. I also have ASM text-mode routines, and a nice MsgBox that even supports dragging.

online survey

No comments:

Post a Comment