Thread: Help Making GUI

  1. #1
    Registered User
    Join Date
    Oct 2002

    Help Making GUI

    Hi, I am relatively new to C++, and as of now I'm just learning basic console programs using Visual C++ as a compiler. Anyways, I used the "Simple Win32 Program" option to turn one of my programs into a GUI, and I ran into a couple compiling errors. What do I need to do? Include windows.h?
    Here is the code:
    /* proj1.cpp : Defines the entry point for the application.
    /* Full & Part Time Pay Calculator
     Asks user for hours worked and if they are a full or part time employee.
     It then calculates wages according to pay rates.
    #include "stdafx.h"
    #include <iostream.h>
    #include <iomanip.h>
    #include <windows.h>
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    int main()
    	double full = 4.50;
    	double part = 4.00;
    	int hours;
    	double pay;
    	int emp;
    	cout << "How many hours?:";
    	cin >> hours;
    	cout << "\nFull or Part-Time?:\n";
    	cout << "\nFull Time: 1\n";
    	cout << "\nPart Time: 2\n";
    	cin >> emp;
    	if (emp == 1)
    		if (hours <= 40)
    			pay = (hours * full);
    			cout << setprecision(2) << pay;
    	else {
    		pay = (hours * part) + (hours - 40 * (4.50 * 1.5));
    		cout << setprecision(2) << pay;
    	if (emp == 2)
    		pay = (hours * part);
    		cout << setprecision(2) << pay;
    	return 0;
    After compiling it I get these errors:
    Configuration: proj1 - Win32 Debug--------------------
    C:\Documents and Settings\Ken\My Documents\proj1\proj1.cpp(22) : error C2601: 'main' : local function definitions are illegal
    C:\Documents and Settings\Ken\My Documents\proj1\proj1.cpp(68) : warning C4508: 'WinMain' : function should return a value; 'void' return type assumed
    Error executing cl.exe.

    proj1.exe - 1 error(s), 1 warning(s)
    I would appreciate any help. Also, I would like to know when running the .exe with just basic console DOS windows, how do you get the window to stay open when it prints output? They usually just close so nobody can see it. Thanks again for helping a n00b out.

  2. #2
    I lurk
    Join Date
    Aug 2002
    Windows apps start in WinMain. Console apps start in main.
    You start here:

  3. #3
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    If your still just learning C++ I would say you should ignore GUI's until you understand it well. I've been programming for a couple of years now and still shudder when I see Win32 code!!
    Couldn't think of anything interesting, cool or funny - sorry.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making sprites
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 02-20-2010, 07:00 AM
  2. How to move a sprite around inside a windows GUI
    By BuezaWebDev in forum C++ Programming
    Replies: 5
    Last Post: 04-07-2005, 09:42 PM
  3. GUI Design Question (Seeking an opinion)
    By Exile in forum C++ Programming
    Replies: 9
    Last Post: 02-10-2005, 07:47 AM
  4. Creating a 2D GUI using Direct3D
    By codec in forum Game Programming
    Replies: 8
    Last Post: 09-23-2004, 11:57 AM
  5. Making control...
    By Finchie_88 in forum C++ Programming
    Replies: 2
    Last Post: 09-07-2004, 01:42 PM