Hi, ALL,
What I should cast the GetHandle() to on wxGTK?
The doc says it should be "GtkWidget", but I got the error saying:
"variable GtkWidget handle has initializer but incomplete type"
"invalid use of undefined type 'struct GtkWidget'"
"defs.h: forward declaration of 'struct GtkWidget'"
What sgould I do? The first 2 errors I got from my source code...
Thank you.
[gtk] GetGandle() cast
-
- Can't get richer than this
- Posts: 802
- Joined: Mon Dec 27, 2004 10:46 am
- Location: Estonia, Tallinn
- Contact:
Your source files don't know anything about GTK+. You need to #include <gtk/gtk.h>
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
-
- Can't get richer than this
- Posts: 802
- Joined: Mon Dec 27, 2004 10:46 am
- Location: Estonia, Tallinn
- Contact:
wxGTK's wxWindow::GetHandle already returns a GtkWidget object, no need to cast it if you store it in a GtkWidget (as it the practice in GTK+). If you know what more specific object it is, you can cast to it as it is done in the GTK+ world. If you don't know, then you should probably not be touching it imho.ONEEYEMAN wrote:Thank you for the reply.
I am using the "gtk" port and X11 port. What types it should be casted to? I thought that gtk2 is GTK.
Thank you.
As for X11, I don't know why that came up now.
There is the wxGTK port (which can be compiled against gtk1 or gtk2, the former highly discouraged), and there is a wxX11 port. They are completely different things (sharing some common code across all ports), and have no platform specific code shared, beside some font handling classes.
The wxGTK port is mature and supported, while wxX11 is none of that.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
Thank you for the reply, leio.
Originally, I was using the following code:
When I removed the casting for the right value, I got only the first error message: "variable GtkWidget handle has initializer but incomplete type".
Any other suggestion?
[EDIT]
The source code for the wx/gtk/window.h suggests to use "WXWidgets". Changing the handle type and removing the casting solved the problem.
[/EDIT]
Thank you.
Originally, I was using the following code:
Code: Select all
#ifdef __WXMSW__
HWND handle = (HWND) this->GetHandle();
#else
GtkWidget handle = (GtkWidget) this->GetHandle();
#endif
Any other suggestion?
[EDIT]
The source code for the wx/gtk/window.h suggests to use "WXWidgets". Changing the handle type and removing the casting solved the problem.
[/EDIT]
Thank you.
-
- Can't get richer than this
- Posts: 802
- Joined: Mon Dec 27, 2004 10:46 am
- Location: Estonia, Tallinn
- Contact:
Here you needed something like this:ONEEYEMAN wrote:When I removed the casting for the right value, I got only the first error message: "variable GtkWidget handle has initializer but incomplete type".Code: Select all
#ifdef __WXMSW__ HWND handle = (HWND) this->GetHandle(); #else GtkWidget handle = (GtkWidget) this->GetHandle(); #endif
Any other suggestion?
Code: Select all
#ifdef __WXMSW__
HWND handle = (HWND) this->GetHandle();
#elif __WXGTK__
GtkWidget * handle = this->GetHandle();
#else
// Handle other ports
#endif
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
OS's: Gentoo Linux, WinXP; WX: CVS HEAD
Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/