Was ist besser?



  • Hallo!
    Was ist besser, wenn ich mit Klassen winapi programmiere (Bsp.:
    class WinMaker
    {
    public:
    WinMaker (): _hwnd (0) {}
    WinMaker (char const * caption,
    char const * className,
    HINSTANCE hInstance);
    void Show (int cmdShow)
    {
    ::ShowWindow (_hwnd, cmdShow);
    ::UpdateWindow (_hwnd);
    }
    protected:
    HWND _hwnd;
    };
    WinMaker::WinMaker (char const * caption,
    char const * className,
    HINSTANCE hInstance)
    {
    _hwnd = ::CreateWindow (
    className, // name of a registered window class
    caption, // window caption
    WS_OVERLAPPEDWINDOW, // window style
    CW_USEDEFAULT, // x position
    CW_USEDEFAULT, // y position
    CW_USEDEFAULT, // witdh
    CW_USEDEFAULT, // height
    0, // handle to parent window
    0, // handle to menu
    hInstance, // application instance
    0); // window creation data
    }
    )
    oder wenn ich ohne Klassen programmiere (Bsp.:
    ?
    WndClassEx.cbSize = sizeof(WNDCLASSEX);
    WndClassEx.style = CS_HREDRAW | CS_VREDRAW;
    WndClassEx.lpfnWndProc = WndProc;
    WndClassEx.cbClsExtra = 0;
    WndClassEx.cbWndExtra = 0;
    WndClassEx.hInstance = hInstance;
    WndClassEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    WndClassEx.hCursor = LoadCursor(NULL, IDC_ARROW);
    WndClassEx.hbrBackground = (HBRUSH)(COLOR_3DSHADOW+1);
    WndClassEx.lpszMenuName = "MAIN";
    WndClassEx.lpszClassName = g_szAppName;
    WndClassEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    if(!RegisterClassEx(&WndClassEx))
    {
    ?
    ?
    g_hMainWindow = CreateWindowEx(WS_EX_APPWINDOW, g_szAppName,
    "titel", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
    0, 0, hInstance, NULL);
    ?
    )



  • Wenn du die Wrapperklasse richtig aufbaust, dann kannst du mit wenigen
    Funktionsaufrufen ein Fenster erstellen und musst nicht immer alles
    neu schreiben.


Anmelden zum Antworten