wxWidgets control subclassing Problem



  • Hallo,

    ich brauche einen etwas veränderten wxGridCellFloatEditor. Den Original-Code wollte ich nicht verändern, darum möchte ich die Klasse subclassen (was für ein Wort!)

    Der Linker wirft jetzt diesen Fehler aus:

    cuelist.obj : error LNK2019: unresolved external symbol "public: __thiscall specialGridCellFloatEditor::specialGridCellFloatEditor(int,int)" (??0specialGridCellFloatEditor@@QAE@HH@Z) referenced in function "public: void __thiscall CueListDlg::CreateControls(void)" (?CreateControls@CueListDlg@@QAEXXZ)
    *** NMAKE : fatal error U1077: '"D:\Programming\Microsoft Visual Studio 8\vc\bin\link.EXE"' : return code '0x460'
    VCRelease\livelight.exe : fatal error LNK1120: 1 unresolved externals

    Ich weiß, der Fehler ist trivial, ich komm aber nicht drauf. Ich mache subclassing zu selten.

    So sieht der code aus:

    Aufruf in cuelist.cpp:

    #include "specialgridcellfloateditor.h"
    ...
        specialGridCellFloatEditor* gridFloatEditorWTime = new specialGridCellFloatEditor(-1,1);
        wtimegrid->SetDefaultEditor(gridFloatEditorWTime);
    

    specialgridcellfloateditor.h:

    #ifndef _SPECIALGRIDCTRL_H_
    #define _SPECIALGRIDCTRL_H_
    
    #ifdef __GNUG__
    #pragma interface "specialgridcellfloateditor.cpp"
    #endif
    
    // includes
    #include "wx/wx.h"
    #include "wx/grid.h"
    
    class /*WXDLLIMPEXP_ADV*/ specialGridCellFloatEditor : public wxGridCellFloatEditor
    {
        DECLARE_CLASS( specialGridCellFloatEditor )
        public:
            specialGridCellFloatEditor(){};
    
            specialGridCellFloatEditor(int width = -1, int precision = -1);
    };
    
    #endif
    

    specialgridcellfloateditor.cpp:

    #ifdef __GNUG__
    #pragma implementation "specialgridcellfloateditor.h"
    #endif
    
    #include "wx/wx.h"
    #include "wx/grid.h"
    #include "specialgridcellfloateditor.h"
    
    IMPLEMENT_CLASS( specialGridCellFloatEditor, wxGridCellFloatEditor )
    
    specialGridCellFloatEditor::specialGridCellFloatEditor(int width = -1, int precision = -1)
    {
     //   m_width = width;          
     //   m_precision = precision;
    }
    
    bool specialGridCellFloatEditor::EndEdit(int row, int col,
                                         wxGrid* grid)
    {
        double value = 0.0;
        wxString text(Text()->GetValue());
    
        if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_FLOAT))
            grid->GetTable()->SetValueAsDouble(row, col, value);
        else
            grid->GetTable()->SetValue(row, col, text);
        return true;
    
    }
    

  • Mod

    Der Linker findet das Objekt nicht. Evtl. muss du die Klasse noch dem Projekt hinzufügen.



  • Hallo phlox,

    ich habe parallel an dem Problem weitergearbeitet und just als mich Deine Nachricht ereilte, funktionierte es plötzlich. Danke.

    Ich bin immer noch nicht sicher, wo der Fehler genau liegt. Es scheint, dass das irgendetwas mit den DECLARE_DYNAMIC_CLASS / DECLARE_NO_COPY_CLASS Macros zu tun hat.

    Ich habe jetzt von wxGridCellTextEditor abgeleitet und es funktioniert wunderbar.


Anmelden zum Antworten