Results 1 to 8 of 8

Thread: Windows app

  1. #1

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    Talking Windows app

    I have a question..and it's kind of stupid but, i am just starting out. How do you make a windows app? I have the windows.h header file and i dont know a lot about C++. I am using a program called Dev-C++. If you want it, it's 7.56 MB at www.bloodshed.net. So, how do you print words and input things in a windows app? could someone please help me? does anyone know a good C++ code web site that i could go to that teaches me C++ for Win32 apps? thanks.

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    that is not good

    I have used dev-C++ for about a month. it is very good compiler because it is free. When you go the

    File>New

    Select "Windows Application" or something like that. It will automatically put the code for you. New you just run the program and you will see an empty gray window. If you want to learn more windows programming then this site would be really helpful:

    www.winprog.org

    If you don't know how to program in dos then I suggest that don't move on to windows programming. You must understand to concepts of:

    pointers
    refrences
    classes
    windows API

    and some basics of C++ such as looping switching, etc., I have been programming in windows for just one week but I have spent about a month in DOS programming. If you have any other question then just reply to this thread again. And also stick to this forum. It would be really helpful.

    Good Luck!!
    Baaaaaaaaah

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    As abdul said you must understand to concepts of:

    pointers
    refrences
    classes
    windows API

    first and then try
    http://www.winprog.org

    Code for basic windows app
    Code:
    1. open visual c++
    2. File > New
    3. Click Projects tab
    4. click Win32 Application and give it a name
    5. click finish
    6. click the File View Tab on TreeView
    7. go to File > New
    8. in the first tab Click C++ Source File and name it
    9. Copy and paste the code in the new file
    10. right click the Header folder and add Windows.h
    11. click execute
    
    #include <windows.h>
    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
    char szWinNamw[] = "MyWin";
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    				LPSTR kposzArgs, int nWinMode)
    
    
        {
        	HWND hwnd;
        	MSG msg;
        	WNDCLASSEX wcl;
        	wcl.cbSize = sizeof(WNDCLASSEX);
        	wcl.hInstance = hThisInst;
        	wcl.lpszClassName = "My Window";
        	wcl.lpfnWndProc = WindowFunc;
        	wcl.style = 0;
        	wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        	wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
        	wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
        	wcl.lpszMenuName = NULL;
        	wcl.cbClsExtra = 0;
        	wcl.cbWndExtra = 0;
        	wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
        	if(!RegisterClassEx(&wcl)) return 0;
        	hwnd = CreateWindow(
        		"My Window",
        		"Skeleton Window",
        		WS_OVERLAPPEDWINDOW,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		CW_USEDEFAULT,
        		HWND_DESKTOP,
        		NULL,
        		hThisInst,
        		NULL
        		);
        	ShowWindow(hwnd, nWinMode);
        	UpdateWindow(hwnd);
        	while(GetMessage(&msg, NULL, 0, 0))
    
    
            	{
            		TranslateMessage(&msg);
            		DispatchMessage(&msg);
            	}
            	return msg.wParam;
        }
        LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
        							WPARAM wParam, LPARAM lParam)
    
    
            {
    
    
                	switch(message)	{
                	case WM_DESTROY:
                		PostQuitMessage(0);
                		break;
                	default:
                		return DefWindowProc(hwnd, message, wParam, lParam);
                	}
                	return 0;
            }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Megatron
    Guest
    Also, just some advice. While it's quite lengthly to type up a windows program, and it makes since to simply copy and paste the window creation code, it's a good idea, when learning C++, NOT to do this. You shuld type be familiar and type up the code so you know and understand it. Once you can do this, then it's okay to copy and paste.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Hey Vlatko, can you fix your code? I don't want to have to correct your message loop each time
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Hey,parksie i knew you were going to say that. Well ok. SomethinCool, replace the
    Code:
    while(GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    with

    Code:
    int i;
    while(i = GetMessage(&msg, NULL, 0, 0)) {
        if(i == -1) break;
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by Vlatko
    Hey,parksie i knew you were going to say that. Well ok.
    I love being predictable...Nothing personal you understand

    I used to do it that way until I read through the PSDK and it said specifically not to do that So I'm just following their advice.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I am very mad at you parksie, you dared to correct me...
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width