How to make WinApp of WinConsoleApp code?

Aug 6, 2011 at 8:39pm
Hi,
I've wrote easy windows console app on MS Visual 2008.. this programm consists of easy operators and code.. with if and so on.. it looks like (its not the same programm):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <conio.h>
using namespace std;
void main () 
{
  float M[10],max,y;
  int i;
  y=0;
for (i=0;i<10;i++)
  {
  cout << "M[" << i<< "]=";
  cin >> M[i];
  }
  max=M[0];
for (i=0;i<10;i++)
  {
  if (M[i]>max)
  max=M[i];
  }
 for (i=0;i<10;i++)
  {
  if (max==M[i])
  y=y+1;
  }
 cout << "\nMaksimalo elementu skaits: " <<y;
getch();
}


My program is desicion making programm, it asks users and give answers, they choose only 1 answer and at the end programm makes some calculations and gives result.. So my question is - how difficult is to transfer such working!! console code to win app.. if i never did that.. i know only how to make easy programms on win console app. Can u advice me something or just to say - is it possible to transfer that code or I need to write absolutely new with another operators etc.. for winapp?
Aug 7, 2011 at 3:26pm
hey, no1 can help?
Aug 7, 2011 at 3:41pm
It's a bit of a jump from a console application to a GUI app.

To start with, you have to get to grips with event based programming (cf. a simple sequence, as used by the program you posted). It is possible to write a console application in this style, so you could consider that as an intermediate step.

I am not sure what you mean by "another operator". But the input and output function required by GUI apps are quite different to the ones commonly used by console apps. Only the maths would remain the same.

This online tutorial looks reasonable, and includes plenty of code samples.
http://www.winprog.org/tutorial/

The book for standard WIN32 (and WIN64, I presume) GUI programming is Charles Petzold's "Programming Windows".

Andy

P.S. Petzold's book teaches programming using the WIN32 API directly. In practice, a lot of commercial development use GUI toolkits like MFC and Qt, which wrap the C API in classes.
Last edited on Aug 12, 2011 at 5:03pm
Aug 7, 2011 at 4:39pm
Thanks for your answer!

By another operators i mean commands for the same purpose.. :D
I'm using only simple code with for, if, break, continue, cin, cout.. nothing more difficult.
And I don't need programm with installation.. Why I need GUI, its lack of different languages characters and mby it could be good to add some pictures.. that's all.

Thank you for link, will try to check it. But book I think is too seriously for me. I have expierence with php, html, css making websites and some exp with win32 console prgrs.. hope will be able to make easy GUI app.. :)
Aug 7, 2011 at 7:54pm
A dialog based app might be a easy starting point, if you happy with a limited GUI (assorted input/output fields, a few buttons, and an image or two). They are pretty easy to code.
Aug 7, 2011 at 9:34pm
Yes, thats what i need!!! Pretty easy to code.. but I would like to use my win console app code.. its not hard, but long .. so what can u advice me to make such limited gui? :)
Aug 7, 2011 at 10:30pm
I just had a look for a good tutorial web site, but I couldn't find one.

It is described in the book I mentioned! So if you have a library you can borrow it from (there is a calculator example...)

:-) But there's an old version on the web. As it's a simple WIN32 app, it's age should be no problem.

ftp://ftp.charlespetzold.com/ProgWin95/CHAP11

It's the files beginning HEXCALC (though I would skip the .exe)

You main issue is going to be the resource file. If I remember right, the resource editor is not included with the Express version of VC++. So you'll have to do it by hand. Which shouldn't be too painful if you're just doing one or two dialogs.

Andy

P.S. Regarding resource editors: MSDN forum discussion...
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/abd8eb65-9462-42f8-bf57-3b7cdfea30be

Which led to:
http://www.resedit.net/

Also see:
http://en.wikipedia.org/wiki/Resource_(Windows)
Last edited on Aug 7, 2011 at 10:37pm
Topic archived. No new replies allowed.