windows programming using template in c++ - c++

I am interested in writing simple windows-based programs for scientific calculations in c++. Is there a place I could find source code for a template that I could use? The window I would create would hardly ever vary -- it would be something similar to this (but simpler!):
http://www.lisisoft.com/imglisi/6/Science/73401version4xp.jpg
I am not a c++ programmer -- but I have created similar programs in visual basic (blush!). This is my way of learning c++ by working within a limited range of program design...mainly at first just changing the formulas and a few labels.
Can anyone help or point me in the right direction?

First off, there are a million things you need to know before you can just download some code from somewhere and try to work with it. My best advice would be to pick up an "Introduction to C++" book.
But, putting that aside, I will try to answer the question.
There are 2 main ways to make GUI apps in windows using C++:
Get a C++ GUI library, there is an extensive list here.
Work with the Windows API directly.
Once you have choosen either step 1 or 2, try to search for samples by searching the library name you have chosen followed by the word "samples" or "examples" (i.e, "WxWidgets Samples", "Qt examples" or "Windows API examples")
However, either way you choose, in order to make something like the example in your picture, I would estimate that it would take you at least 6 months (and thats if you program everyday).

For a windows C++ GUI library try reliable software library at www.relisoft.com. If you want to use native windows GUI programming you can also try using QT libraries.

Related

Creating GUIs in Win32 C++

I'm developing my first Windows desktop application and I'm trying to figure out what the best approach would be to create the program's GUI.
I know, I know... I feel stupid for asking considering the amount of data on the subject on SO. However most answers seem outdated and I'm not sure if they fit my specific project. Also tutorials for Windows 8 'metro apps' are clogging my Google search results, which is NOT what I'm looking for.
I use Visual Studio. I've followed tutorials. I have basic knowledge of C and Java and extensive experience with PHP. I'm excited to learn C++, so I'm not looking for GUIs to create a GUI (like WinForms). I also don't care about managed code and portability for now, especially since I'm trying to avoid dependencies (i.e. users having to install .NET). As long as it runs smoothly on Vista and up, I'm happy.
The application
The software will teach basic physics to kids. I'd like to create a main area and a sidebar. The main area will feature a physics animation, say a bouncing ball, along with some Q&A. Users can zoom in to the animation to measure some stuff and answer the question. Users can track their progress in the sidebar. That's pretty much it.
What I've found so far
I'm getting a bit frustrated with MSDN. Most of their examples are given in four different languages (C#, C++, etc). I can't seem to get more than a bit of Hello World code from them.
I found a GDI API on MSDN and it seems like a good start for me. However I've read quite a few answers on SO saying creating layouts in pure C++ is really hard, that we're better of using frameworks like ATL and WTL. Since I'm also going to create (somewhat interactive) animations, I've wondered whether I should use gaming-targeted APIs like Direct2D.
Since all of this is new to me, and there are a lot of options, I don't know where to start for my particular application. Any tips would be greatly appreciated!
Using the raw Win32 API (no additional downloads or third-party helpers):
Here's a good primer (introduces dialog boxes, text boxes, buttons, etc): theForger's Win32 API Tutorial
And here's where you go from there (numeric up-downs, list boxes, combo boxes, tooltips, and more): Common Controls on MSDN. Most of these require you to #include <commctrl.h>.
I also found this to be a good resource that covered what the other two didn't: Win32 Developer - Window Assets
But the Win32 API doesn't seem like it does exactly what you want. A physics app for kids should have a more visual GUI than the API can provide. Good luck, though!
If you're ok with adding additional Frameworks, I'd suggest looking at Qt.
It allows to create the GUI from code only, has a good structure, and has an Interface for 2D drawing, if required.
If you are concerned about dependencies, you only have to include the Qt DLLs to your executables; no installation is required for the user.
To get started, see my (old) tutorial "Lessons in Windows API Programming".
But you really need a good book, such as edition 5 or earlier of Charles Petzold's classic "Programming Windows".
The problem with latest edition is that it's for C# and .NET, with Charles grabbing the tail of the "new way" at just the wrong time…
Disclaimer: I haven't checked the details of edition numbers.
Using the Windows API is the simplest, but producing advanced GUIs can take a very long time. Microsoft Foundation Class is a way to make the Windows API more user friendly and OOP. Does anyone have any experience with MFC?
Why not use some 2D C++ game engine, like HGE: http://hge.relishgames.com/overview.html.

gtkmm for desktop application

Is it a good idea to use gtkmm gui toolkit for some desktop client application ?
Is this toolkit stable and is there enough documentation online ?
I used gtkmm to write professional applications and yes you can use it for real world software development.
But I also used C/GTK+ and C++/Qt and my opinion is that using Gtkmm you have the feeling that the original toolkit was meant to be used in C and the porting to C++ is ok but in many cases you feel that C++ features could have been used better.
For Comparison:
If you have to choose between Gtk and Gtkmm go for Gtkmm even though you might find yourself stuck in some not well documented or supported function. Eventually you always manage to find a solution (you can check the source code) and c++ is way better then c.
If you have to choose between Gtkmm and Qt, go for Qt. There is a HUGE gap between the two. Not only in the toolkit itself but in the documentation and all the other classes that you need when writing an application.
I started two month ago with gtkmm. I actually port a tcl/tk application and it feels very hard for my to get the things run. The only useful documentation I found is the https://developer.gnome.org/gtkmm-tutorial/3.4/
But many things described in the manual are not working! I actually run into trouble while overriding signal handlers which should work but didn't. Maybe you will take a look in gtkmm-list#gnome.org to find out what kind of problems yo will maybe run in :-)
The docs derived from the doxygen input seems useless for me, because the functions are mostly not described and the parameter names or often not very clear to me.
In comparison to tcl/tk the interface looks inconsistent. Sometimes a parameter must be provided by a text, sometimes by a pointer and sometimes by the native value itself. Especially the menus are very "mysterious" with the string based configuration. The need of having parameters as text is very unhandy! You have to convert the parameter with ostrstream into a text and parse the parameters sometimes yourself from text to real values.
I decided to give gtk+ a chance is the existence of the c++ interface. I thought it would be helpful to get the errors in compile time and not while running the app like with tcl/tk. But this is not the always true with gtkmm. With gtkmm you are also able to run into run time errors because all string parameters will be parsed during run time! This makes the things error prone!
Maybe I will start again and give Qt a chance. But a first view on it shows, that this seems not really better :-)
Writing a gui application still is a really annoying job!
gtkmm is a official supported binding of GTK (gtk.org/language-bindings.php).
"inkscape" and "ardour" are notable applications written in gtkmm
The bindings that are official GNOME Bindings follow the GNOME release schedule which guarantees API stability and time-based releases.
If you want to write your Application in C, go with GTK+ (and the GLib).
You can find a link to the documentation at http://www.gtkmm.org/ (https://developer.gnome.org/gtkmm-tutorial/).
With Glade (and ie. PyGTK) you could rapid prototype your application.
Building a GUI with Glade is easy and the resulting UI is a xml file, that is not bound to a programming language.

making a gui editor

For my school project, I would like to build a gui that someone else can use to create a gui. Upon some research I saw lot of gui builders but didn't see anything along the lines of what I am looking for.
But then I did find a tutorial using C# on here
I rather create this gui editor for linux environment.
Any suggestions to where I should start? what tools I can use? Any links to any tutorials?
Any help/direction would be greatly appreciated.
P.S. I would like to add that it only needs to be very simple. like few text input fields and some button type fields that user can arrange in the order desired.
I would recommend that you not try to build your own GUI builder. It is a daunting task that you will not be able to accomplish as a school project. C++ is fully-compiled, which means that it lacks almost every feature that enables people to build meta-tools (like GUI editors) for it. This mainly has to do with the fact that C++ does not have runtime reflection (natively, anyway). Beyond that, there is no "one GUI toolkit and/or paradigm to rule them all." This makes your problem incredibly difficult to deal with.
So: I would recommend Qt, because it works on a ton of platforms, is easy to use and is just plain awesome. You could also look at the billions of other GUI toolkits like Gtk+, Tk, FLTK, YAAF, GLUI, dlib, CLX...
I'm aware that this does not actually answer the question. However, I do not think that the author is aware of how incredibly difficult the task he has set in front of himself is.
I would recommend starting by implementing it like an interpreter. Start with a very simple command line tool that takes commands like window(300, 400, "window1") and button(50,100, "button1") etc and output the code (native or whatever other GUI code you want), to a file. The goal should be to output a file that can be run and show the GUI that was designed. Once you have that, build a GUI that uses the command line functions as a back-end.
I don't have any exact links to this, but here's an example of what you could do. Gtk has the option of loading a GUI by using a class called GtkBuilder. Glade (the usual Gtk gui editor) has support for outputting it's result as an XML file that the GtkBuilder class then reads.
It would be possible for your program to output an equivalently formed XML file that GtkBuilder could read.
I have no clue as to how difficult it would be to target that XML though.
You should use GTK+ or Qt if you are targeting the linux environment. I think the first step is to learn how to program gui, which takes some time considering you are writing c/c++ code wich is different from higher level languages. Don't you think learning to code gui programs and writing a gui builder at the same time is a little bit too much.? First you should master the basics about gui and then go on to harder projects.
Here's a link to an excellent book on gtk. (Foundations of gtk+ development - Andrew Krause)
http://books.google.com/books?id=L1BZZYRrqSgC&printsec=frontcover&dq=foundations+krause&hl=es&cd=1#v=onepage&q=&f=false
And here's a great tutorial/cookbook for gtk+.
http://zetcode.com/tutorials/gtktutorial/
The official documentation is on library.gnome.org
My final advice is learn one thing at a time.

Stock Charts in C++

I am trying to create some charts of data (eg http://www.amibroker.com/). Is there a C++ library that can do this without a lot of extra work? I'm thinking Qt or wxWindows would have something like it, but it wasn't immediately obvious.
Thanks!
FLTK is a light and portable C++ toolkit for GUI. There's a chart class. Sample.
Qwt does at least some of the things you are trying to achieve (basic plots, bar charts and so on), and integrates well with Qt.
I think you need to pick your GUI framework first, then find a charting control for the given framework, since that affects what charting controls you could feasibly use. For example, must this be portable?
For the project I'm working on (a large MFC application) we use Cedric Moonen's ChartCtrl. We've had a pretty good experience with it so far.
I've done some graph plotting with gnuplot lately, which is quite powerful. Although I think it is Linux only, which may or may not be a problem.
Also, believe it or not, some amazing things can be done with LaTeX. I've used the tkz (tikz) library to produce some awesome graphs.
Both solutions plot to a file which you can include in your interface.
They aren't C++ libraries but you can easily create the datafiles and call the necessary programs from within your C++ program (Being creative with system() and possible some shell scripts).

Modifying old Windows program for Mac OS X

This application was written for windows back in 1998,
I loved using this program, Now I want to learn how to make it
work on Mac, And maybe changing and adding functionality,
The problem is I don't know where to start, I Have studied C++ php, javascript, But don't really know how to read this code. or where to start.
Thanks for taking a look
http://github.com/klanestro/textCalc
From http://www.atomixbuttons.com/textcalc/
What is TextCalc?
TextCalc is a combination of an
expression calculator and a text
editor. Being both, it has several
advantages over conventional
calculators.
1) You can evaluate expressions like
9*4-2+95-12 just the way you write
them on paper.
2) You can put comments besides your
answer and expressions.
3) You can save, reload, edit and
print your results and expressions.
4) You do not need to write your
answer down on a paper before
computing another expression, as you
can leave the previous result in the
editor.
5) You can open an existing text data
file and perform calculations on it.
6) You can apply an expression to many
numbers at one go. For example, you
can change the list 1 2 3 4 5 to 2 4
6 8 10 by multiplying each number by
2.
7) You can sum, average, convert into
hex etc. a list of numbers easily.
The editor is capable of parsing
numbers and strings enclosed in double
quotes " ". Numbers will be colored
blue and strings will be colored red.
This makes it ideal for editing files
containing numeric data.
★✩
Based on the screenshots and info on the TextCalc site, I think this is best implemented as a Mac OS X service. You can assign a hot key to trigger your service in the System Preferences -> Keyboard -> Services.
It would actually be rather easy. You don't need to write the text editor portion, it will be available in all text areas in all apps. You will be handed the text the user has selected, and all you need to do is evaluate it. There's a built-in command line tool, bc, that you should be able to delegate this to.
There is a guide to implementing services. You will need to read through the Cocoa intro material to understand it. This is a good first project, though.
I don't think there's any reason to try to read the source of the original app in this case. You just need to know what you want the behavior to be.
Check out the Calculator example from the second chapter of Stroustrup's "The C++ Programming Language".
It looks like this application is written using MFC, which is quite Windows-centric. Translating this program to use a different API such as Cocoa would be a lot of work, and would require good familiarity with both MFC and Cocoa. Not to mention the work involved in translating the C++ to Objective-C, of course.
You may be better off running it as-is in a virtual machine such as VirtualBox, or under Wine. Unfortunately, the free version of Microsoft Visual C++ does not include MFC, so to modify this code you would have to either purchase a non-free version of MSVC, or translate the program to "bare bones" Win32, without using MFC.
The core part of this program (Expression Evaluation) has been taken from this smaller program written by Zoly Farkas.
So I would suggest the following:
Learn Objective C.
As an exercise, port Zoly Farkas' Expression Evaluation to Objective-C, to use as a library or on the command line.
Learn Cocoa.
As an exercise, create a graphical interface for your library using Cocoa. You don't need MFC.
Should be fun! :-)
I would not recommend to "port" such a old program using MFC which you cant use on a Mac anyway.
Rather i would recommend to create the skeleton of a new blank application and then to insert more or less large fragments from the old code. The skeleton may use whatever language is appropriate: C++, Objective-C, real Basic. But as the code to reuse is C++ its probably best to use C++.
If you decide to re-write it, I recommend RealBasic. It has many components that will help shorten the development cycle and you can compile the program for Windows, Mac and Linux.
Easy to learn and very productive platform.
Why not rewrite it in C# .NET and use Mono to compile it on the Mac? You can rewrite the GUI parts in Native Cocoa from c# using a wrapper. Depends on your program but this program doesn't sound like your going to sell it to the public so L+F issues are probably not an issue.
The code looks to be in C++. C++ is available on Macs.
The code relies on MFC, which if course is not available on OS X. So you'll need to pick a framework like WxWidgets, Qt, FLTK, etc. that's available on both the Mac and Windows. Then you need to translate from MFC to your new framework.
In the process you'll learn more about MFC than you intend to.