why ?

This is a discussion on why ? within the C++ Programming forums, part of the General Programming Boards category; #include <windows.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS ...

  1. #1
    Unregistered
    Guest

    why ?

    #include <windows.h>

    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

    int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

    {
    WNDCLASS WndClass;
    WndClass.style = 0;
    WndClass.cbClsExtra = 0;
    WndClass.cbWndExtra = 0;
    WndClass.lpfnWndProc = WndProc;
    WndClass.hInstance = hInstance;
    WndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW +1);
    WndClass.hCursor = 0;
    WndClass.hIcon = 0;
    WndClass.lpszMenuName = 0;
    WndClass.lpszClassName = "WinProg";

    RegisterClass(&WndClass);

    HWND hWindow;
    hWindow = CreateWindow("WinProg","Window",WS_OVERLAPPEDWINDO W,0,0,400,400,NULL,NULL,hInstance,NULL);
    ShowWindow(hWindow, nCmdShow);

    UpdateWindow(hWindow);

    MSG Message;
    while (GetMessage(&Message,NULL,0,0))
    {
    DispatchMessage(&Message);
    }
    return (Message.wParam);
    }

    LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
    {
    switch(uiMessage)
    {
    case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
    default:
    return DefWindowProc (hWnd, uiMessage,wParam, lParam);

    }
    }


    The window shows up fine but a dos window also pops up in the back, how do you get rid of the dos window ?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Its your compiler (or more accurately - the linker)......the difference between a console app and a win32 app is a simple linker parameter.....

    On VC++ you would create a windows app instead of a console app....same goes for Codewarrior & Devc++

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21