Einzelnen Beitrag anzeigen
Ungelesen 23.08.09, 21:15   #4
wect
Anfänger
 
Registriert seit: Aug 2009
Beiträge: 5
Bedankt: 0
wect ist noch neu hier! | 0 Respekt Punkte
Standard

Code:
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
TCHAR szClassName[] = TEXT("WindowsApp");

int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    PTSTR lpszArgument,
                    int iCmdShow)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG msg;            /* Here messages to the application are saved */
    WNDCLASSEX wndcl;        /* Data structure for the windowclass */

    /* The Window structure */
    wndcl.hInstance = hInstance;
    wndcl.lpszClassName = szClassName;
    wndcl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wndcl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wndcl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wndcl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wndcl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wndcl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wndcl.lpszMenuName = NULL;                 /* No menu */
    wndcl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wndcl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wndcl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wndcl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           TEXT("Windows App"), /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           CW_USEDEFAULT,       /* The programs width */
           CW_USEDEFAULT,       /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hInstance,           /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, iCmdShow);
    UpdateWindow(hwnd);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&msg, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&msg);
        /* Send message to WindowProcedure */
        DispatchMessage(&msg);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return msg.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
Das wäre erstmal ein Fenster.
wect ist offline   Mit Zitat antworten