Announcement

Collapse
No announcement yet.

C/C++ - WINAPI Klasse, Vererbung Problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • C/C++ - WINAPI Klasse, Vererbung Problem

    Hi ich habe eine Haupt Klasse

    <pre>class FRM_CLASS
    {
    public:
    FRM_CLASS();
    ~FRM_CLASS();

    bool Timer(){};

    virtual bool Create(UINT uMsg, WPARAM wParam, LPARAM lParam){};
    ...
    LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
    static int WINAPI WindowsProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
    ...
    }

    int WINAPI FRM_CLASS::WindowsProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
    if ( uMsg == WM_CREATE )
    SetWindowLong( hWnd, GWL_USERDATA, lParam);

    FRM_CLASS *wnd = (FRM_CLASS*)GetWindowLong(hWnd, GWL_USERDATA);

    return wnd->WndProc(hWnd, uMsg, wParam, lParam);
    }

    LRESULT CALLBACK FRM_CLASS::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    switch (uMsg)
    {
    case WM_CREATE:
    {
    Create(uMsg, wParam, lParam);
    } break;
    ...
    }</pre>

    und dann

    <pre>class FRM_STARTER : FRM_CLASS
    {
    public:
    bool Create(UINT uMsg, WPARAM wParam, LPARAM lParam);
    private:
    HWND hEditName, hEditIP, hButtonStart, hButtonLevelMaker;
    HBITMAP hBitmapLogo;

    };

    bool FRM_STARTER::Create(UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    hEditName = CreateWindow("EDIT", "", WS_VISIBLE|WS_CHILD|WS_BORDER, 230, 70, 150, 20, hWnd, 0, hInstance,0);
    hEditIP = CreateWindow("EDIT", "", WS_VISIBLE|WS_CHILD|WS_BORDER, 230, 100, 150, 20, hWnd, 0, hInstance,0);
    hButtonLevelMaker = CreateWindow("Button", "Level Maker", WS_BORDER | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 230, 130, 100, 20, hWnd, NULL, hInstance, NULL);
    hButtonStart = CreateWindow("Button", "OK", WS_BORDER | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 340, 130, 40, 20, hWnd, NULL, hInstance, NULL);

    hBitmapLogo=(HBITMAP) LoadImage (hInstance,"logo.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTS IZE | LR_LOADFROMFILE | LR_CREATEDIBSECTION);

    return true;
    }</pre>

    nun möchte ich das die Funktion Create in der Kind Klasse definiert wird aber in der Eltern Klasse aufgerufen wird

    anscheinend funktionierts nicht weil ich die Funktionen in der Windows Prozedur
    LRESULT CALLBACK FRM_CLASS::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    ausführen lassen will

    kann man das irgendwie so hinbiegen das sie laufen?

    P.S.: Hoffe mal ihr habt mich verstanden

    P.P.S.: Achja hier die Fehlermeldung:

    <pre>---------------------------
    Benachrichtigung über Debugger-Exception
    ---------------------------
    Im Projekt p_daldria.exe ist eine Exception der Klasse EAccessViolation aufgetreten. Meldung: 'Zugriffsverletzung bei Adresse 0040153F. Lesen von Adresse 00000000'. Prozeß wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen.
    ---------------------------
    OK Hilfe
    --------------------------- </pre>
    (EAccessViolation ist die Exception-Klasse für Fehler, die durch ungültige Speicherzugriffe ausgelöst werden.)

    Hoffe ihr könnt mir helfen.
Working...
X