I have started to learn C++ and would like to know where to go from now. I have been getting helped by MattyRobot. I have done Hello World, Input, Sqaure of Numbers, Making decisions, Cmd games, Operators, Repeated question and started to make a window. I would like some help on where to go from here

#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG msg;


    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = "classname";
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, "FAILED!!!!", "ERROR", MB_OK | MB_ICONEXCLAMATION);
    }

    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "classname", "Hello World", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL);

    if(hwnd == NULL)
    {
        MessageBox(NULL, "FAILED!!!", "ERROR", MB_OK | MB_ICONEXCLAMATION);
    }

    ShowWindow(hwnd, SW_SHOW);
    UpdateWindow(hwnd);


    while(GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}

Recommended Answers

All 9 Replies

What about templates, pointers and references,overloaded functions,inheritance,linked lists,binary trees,vectors,lists,deques,queues.....?Have you done that?

Thats what I was trying to tell him but he wants to go straight onto graphics!!!

Please may you suggest somewhere...I can start learning that.

don't you thing he should know more about c++ first though?

maybe... it depends what you want to do. You can always learn them both side by side. I just find that setting up a window like that it pointless for simple graphics, when you can do it in 1 line for allegro... :icon_eek:

Oh BTW MattyRobot ich bin 13 too! ZOMG

Ok. Any suggested sites?

I just recently posted some tutorials here...

http://www.jose.it-berater.org/smfforum/index.php?topic=3389.0

Lot of stuff having to do with pointers, message crackers, etc.

If you are into graphics at the Api level you should probably think about Charles Petzold's Programming Windows book. He is heavy into graphics. I can't really speak to other class framework wrappers on GDI or otherwise because I'm not into that.

commented: Thanks! +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.