how to make my code runs like any windows program?

how to make my code looks like any windows program? i mean i want to my code open just like any other windows program and no in the command prompt windows. i would like to runs the code in a windows with file, tool, option, etc.. this code below is an example from my book with some change i made it to learn how struct works . any thoughts. thanks

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# include <iostream>
# include <fstream>
# include <iomanip>
# include <string>
using namespace std;
const int NO_OF_SALES_PERSON = 6;
struct nameType
{
	string firstName; 
	string middleName;
	string lastName;
};
struct addressType
{	string address1;
	string address2;
	string city;
	string state;
	string zipcode;
};
struct contactType
{
	
	string cellPhone;
	string homePhone;
	string phone;
	string email;
};

struct employeeType 
{ 
	nameType name[10];
	addressType address[10];
	contactType contact[10];
	double salary; // SalesPerson yearly sales amount
	double saleByQuarter [4]; //store the totalsale by quarter 
};

int main ()
{
	employeeType employee;
	int j;
	cout<< "Enter employee name"<<endl;	
	for (int j = 0; j < 10 ; j++)
	 cin>> employee.name[j].firstName>> employee.name[j].middleName>> employee.name[j].lastName; 
	
	cout<< employee.name[0].firstName<<"  "<<employee.name[0].lastName<<endl;
    cout<< employee.name[1].firstName<<"  "<<employee.name[1].lastName<<endl;
	cout<< employee.name[2].firstName<<"  "<<employee.name[2].lastName<<endl;
	cout<< employee.name[3].firstName<<"  "<<employee.name[3].lastName<<endl;
	cout<< employee.name[4].firstName<<"  "<<employee.name[4].lastName<<endl;
	cout<< employee.name[5].firstName<<"  "<<employee.name[5].lastName<<endl;
	cout<< employee.name[6].firstName<<"  "<<employee.name[6].lastName<<endl;
	cout<< employee.name[7].firstName<<"  "<<employee.name[7].lastName<<endl;
	cout<< employee.name[8].firstName<<"  "<<employee.name[8].lastName<<endl;
	cout<< employee.name[9].firstName<<"  "<<employee.name[9].lastName<<endl;
	

} 
Last edited on
closed account (Dy7SLyTq)
well you cant do that with console functions. you need to look up the win32 api | sfml | sdl | allegro | opengl
thanks
closed account (N36fSL3A)
Before going to those make sure you're pretty good with C/++.
click win32 applications in dev c++ or visual c++ to make windows applications
closed account (N36fSL3A)
No. It's not that simple. You have to learn the win32 API. You can't just change the project settings and expect it to be a non-console app.
You can't just change the project settings and expect it to be a non-console app.

Why not?

Visual Studio -> New Project -> New MFC Project.
Fair enough you have to learn a little mfc, but i wouldnt say you need to know the win32 api.
Last edited on
closed account (Dy7SLyTq)
you actually can change the project to make it a non console app, like mutexe said, but you cant expect it to do anything worth while, unless you learn an api, such as win32, sfml, sdl, allegro, or openg
closed account (N36fSL3A)
But that's not C/++ now is it?
closed account (Dy7SLyTq)
yes it is. what do you think those apis are written in?
i understand it isnt practical but is it technically possible to write a gui as a console app? i mean if it isn't than what did the guys who wrote win32 use to write win32?
Ok some questions:
what are the different is both are written in C++?
what is the next step?
is there any simple program, some "hello world" but running in win32 api ?
//please forgive my lack of knowledge!
This MSDN article walks you through creating a "Hello, World!" app.

Creating Win32 Applications (C++)
http://msdn.microsoft.com/en-us/library/vstudio/bb384843.aspx

While the srticle refers to Visual Studio, as it starts of with an empty project all the code will be equally usable with any other IDE which provides Windows SDK support (e.g. Code::Blocks, CodeLite, ...) Or even on the command line, if you're keen enough.

Note that while Windows API apps can be written in C++, the API itself is (or at least a lot of it is) actually C.

Andy

PS Code from article which displays message:

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
28
29
30
31
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR greeting[] = _T("Hello, World!");

    switch (message)
    {
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

        // Here your application is laid out.
        // For this introduction, we just print out "Hello, World!"
        // in the top left corner.
        TextOut(hdc,
            5, 5,
            greeting, _tcslen(greeting));
        // End application-specific layout section.

        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }

    return 0;
}
Last edited on
closed account (Dy7SLyTq)
@MarketAnarchist: do you mean making your own graphics api? of course its possible, but why would you do it? its like wanting to make your own version of the stl? and no its not possible using what op was using. you would need to use more lower level stuff
whats lower level than console? would this lower level still be c++? or would you need to use machine code like assembly or something?

I know its not practical, i just get curious about things.
closed account (Dy7SLyTq)
your getting terms mixed up. consoles not a level of programming. its an interface. the code you write is the level. you get lower level by not using abstracted things like i/ostream or printf and instead using code that is closer to the hardware
Topic archived. No new replies allowed.