Results 1 to 10 of 10

Thread: C++ very EASY question

  1. #1

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

    Arrow C++ very EASY question

    ok if you have a program that has this code in it to make a windows app: (from John's tutorial post)

    Code:
    #include <windows.h>
    #include <iostream.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(BLACK_BRUSH);
    
     
    
    if(!RegisterClassEx(&wcl)) return 0; 
    
     
    
    hwnd = CreateWindow( "My Window", 
    
    "Carmageddon TDR2000", 
    
    WS_OVERLAPPEDWINDOW, 
    
    CW_USEDEFAULT, 
    
    CW_USEDEFAULT, 
    
    CW_USEDEFAULT, 
    
    CW_USEDEFAULT, 
    
    HWND_DESKTOP, 
    
    NULL, 
    
    hThisInst, 
    
    NULL ); 
    
    ShowWindow(hwnd, nWinMode); 
    
    UpdateWindow(hwnd); 
    
     
    
    int i; 
    
    while(i = GetMessage(&msg, NULL, 0, 0)) 
    
    { if (i == -1) break; 
    
        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;
    
     }
    how would you print something? like in a console app you would put
    Code:
    #include <iostream.h>
    
    int main()
    {
         cout << "Hello! Please enter your name: ";
         int x;
         cin >> x;
    }
    so how would you put that into a windows app?

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Go to New , choose win32application, create a new cpp file and put the code in there. As for the printing you could use a message box or an edit box.
    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

  3. #3

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407
    well i am very new to C++, like the amount of time i've spent on learning C++ is about 2 hours...so..i am a newbie...so, do you know any good tutorials?

  4. #4
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    don't start with windows, first get a good command of the language itself. you will need to. check the faq for the sams online book.

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  5. #5

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407
    yeah..i am going to start learning next semester in school...1st period..C++ heehee..but, it's just been bugging me about how to do that stuff in Windows so how do you do it?

  6. #6
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    if you don't know a basic sense of the language, you can't do it, it's just too complex. just start with a few console apps.

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  7. #7
    Zaei
    Guest
    Better, a whole lot of console apps.

    Z.

  8. #8
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    yeah, i have been working on and off for the last few months, and i just started with windows apps a little bit. You aren't gonna get anywhere if you don't have a really good command of the language. at least with windows programs

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    but just so you're happy, create a new win32 project and choose A "Hello, World!" application. It will contain exactly what you're searching for.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by SomethinCool
    yeah..i am going to start learning next semester in school...1st period..C++ heehee..but, it's just been bugging me about how to do that stuff in Windows so how do you do it?
    You'll still be bored when the teacher teachs you a different way (the way TEACHERS should).
    Baaaaaaaaah

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