Problem when using wxGenericColourDialog Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

Problem when using wxGenericColourDialog

Post by samsam598 »

Greetings!

I encountered an issue when I use wxGenericColourDialog with wx2.8.11+vc++2008 under windows.Below code is borrowed from the dialog demo on the wx website.
In "include/wx/msw/setup.h" wxUSE_COLOURDLG is set to 1 when I built wx,but the code can not pass compiler.
the command line of compiling wx is as below:
nmake -f makefile.vc BUILD=release SHARED=0 MONOLITHIC=1 UNICODE=1


Below is the open menu's event handler:

Code: Select all

#include <wx/colordlg.h>
#include <wx/generic/colrdlgg.h>
#include 
oid dialogappFrame::OnChooseColorGenericClick(wxCommandEvent& event)
{
    wxColourData m_clrData;
    m_clrData.SetColour(myCanvas->GetBackgroundColour());
    m_clrData.SetChooseFull(true);


    for(int i=0;i<16;i++)
    {
        wxColor color((unsigned char)(i*16),(unsigned char)(i*16),(unsigned char)(i*16));
        m_clrData.SetCustomColour(i,color);
    }
    wxGenericColourDialog* dialog=new wxGenericColourDialog(this,&m_clrData);

    if(dialog->ShowModal()==wxID_OK)
    {
        m_clrData=dialog->GetColourData();
        myCanvas->SetBackgroundColour(m_clrData.GetColour());
        myCanvas->ClearBackground();
        myCanvas->Refresh();
    }
    dialog->Destroy();


}

Error Message:

dialogappMain.obj||error LNK2019: unresolved external symbol "public: __thiscall wxGenericColourDialog::wxGenericColourDialog(class wxWindow *,class wxColourData *)" (??0wxGenericColourDialog@@QAE@PAVwxWindow@@PAVwxColourData@@@Z) referenced in function "protected: void __thiscall dialogappFrame::OnChooseColorGenericClick(class wxCommandEvent &)" (?OnChooseColorGenericClick@dialogappFrame@@IAEXAAVwxCommandEvent@@@Z)|
bin\Release\dialogapp.exe||fatal error LNK1120: 1 unresolved externals|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 4 seconds) ===|

I totally have no clue what's wrong here.

Thanks for your help in advance.
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
tan
wxWorld Domination!
wxWorld Domination!
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan »

Hi,
well, wxGenericColourDialog is built only in UNIVERSAL build mode (WXUNIV=1, it, in turn, defines __WXUNIVERSAL__). Use wxColourDialog instead (it will work for UNIVERSAL mode too).

From colordlg.h

Code: Select all

...
#if wxUSE_COLOURDLG

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    #include "wx/msw/colordlg.h"
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
    #include "wx/mac/colordlg.h"
#elif defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
    #include "wx/gtk/colordlg.h"
#elif defined(__WXPALMOS__)
    #include "wx/palmos/colordlg.h"
#else
    #include "wx/generic/colrdlgg.h"

    #define wxColourDialog wxGenericColourDialog
#endif
...
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

Post by samsam598 »

tan wrote:Hi,
well, wxGenericColourDialog is built only in UNIVERSAL build mode (WXUNIV=1, it, in turn, defines __WXUNIVERSAL__). Use wxColourDialog instead (it will work for UNIVERSAL mode too).

From colordlg.h

Code: Select all

...
#if wxUSE_COLOURDLG

#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
    #include "wx/msw/colordlg.h"
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
    #include "wx/mac/colordlg.h"
#elif defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
    #include "wx/gtk/colordlg.h"
#elif defined(__WXPALMOS__)
    #include "wx/palmos/colordlg.h"
#else
    #include "wx/generic/colrdlgg.h"

    #define wxColourDialog wxGenericColourDialog
#endif
...
Got it.Thank you so much!
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

Post by samsam598 »

Duplicated reply.
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Post Reply