From: Stefano Smania MD on
I use C since 1988 but I'm newbie about wxwidgets. I've a (stupid?)
problem with Connect() function. I've to create some wxBitmapButton
runtime for a dynamic graphical menu. I need to use the Connect function
to handle mouse events.

I use Connect function in this mode:

bool ss_GfxMenu::SetParentChild(struct ss_GfxMenuItem *parent,struct
ss_GfxMenuItem*child)
{
...

struct wxBitmapButton * bb;
bb=parent->ItemButton;

Connect(bb->GetId(),
wxEVT_LEFT_DOWN,wxMouseEventHandler(ss_GfxMenu::ShowChild));

...


TheShowChild function has this prototype:

class ss_GfxMenu
{
...
void ShowChild( wxMouseEvent& event );
...

~ss_GfxMenu(void);
};

...and the funtion is:

void ss_GfxMenu::ShowChild( wxMouseEvent& event )

{

}

Compiling (Win, mingw32) I obtain this compiler error:
.....\ss_gfxfloatmenu.cpp||In member function `bool
ss_GfxMenu::SetParentChild(ss_GfxMenuItem*, ss_GfxMenuItem*)'


....\ss_gfxfloatmenu.cpp|227|error: invalid static_cast from type `void
(ss_GfxMenu::*)(wxMouseEvent&)' to type `void
(wxEvtHandler::*)(wxMouseEvent&)'


Havce you any idea to resolve it? Searching on internet I've not found
the solution.

Thanks

Stefano






From: kvnsateesh on
On Dec 22, 2:05 am, Stefano Smania MD <smania2...(a)alice.it> wrote:
> I use C since 1988 but I'm newbie about wxwidgets. I've a (stupid?)
> problem with Connect() function. I've to create some wxBitmapButton
> runtime for a dynamic graphical menu. I need to use the Connect function
> to handle mouse events.
>
> I use Connect function in this mode:
>
> bool ss_GfxMenu::SetParentChild(struct ss_GfxMenuItem *parent,struct
> ss_GfxMenuItem*child)
> {
>      ...
>
>      struct wxBitmapButton * bb;
>      bb=parent->ItemButton;
>
>      Connect(bb->GetId(),
> wxEVT_LEFT_DOWN,wxMouseEventHandler(ss_GfxMenu::ShowChild));
>
>         ...
>
> TheShowChild function has this prototype:
>
> class ss_GfxMenu
> {
>         ...
>          void ShowChild( wxMouseEvent& event );
>         ...
>
>          ~ss_GfxMenu(void);
>
> };
>
> ..and the funtion is:
>
> void ss_GfxMenu::ShowChild( wxMouseEvent& event )
>
> {
>
> }
>
> Compiling (Win, mingw32) I obtain this compiler error:
> ....\ss_gfxfloatmenu.cpp||In member function `bool
> ss_GfxMenu::SetParentChild(ss_GfxMenuItem*, ss_GfxMenuItem*)'
>
> ...\ss_gfxfloatmenu.cpp|227|error: invalid static_cast from type `void
> (ss_GfxMenu::*)(wxMouseEvent&)' to type `void
> (wxEvtHandler::*)(wxMouseEvent&)'
>
> Havce you any idea to resolve it? Searching on internet I've not found
> the solution.
>
> Thanks
>
> Stefano


Hi Stefano,
I think you have not derived your 'ss_GfxMenu' class from
'wxEvtHandler' class. You should derive your class from wxEvtHandler
before you could make use any dynamic/static event handling.

-Satish Kumar