wxWindow::GetHandle on X11R6

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
saint
Earned a small fee
Earned a small fee
Posts: 17
Joined: Mon Mar 20, 2006 11:09 am
Location: Ukraine, Dnipropetrovsk

wxWindow::GetHandle on X11R6

Post by saint »

Hi everyone.

Please help, I'm in big trouble. I've been trying to solve my problem about 4 days and don't know what to do now. Please, help, it's _very_ important for me.

THE PROBLEM:

I'm trying to create a child window using XtVaCreateManagedWidget and when I call this function with pointer to parent window that I get from wxWindow::GetHandle(), this function failes and my program crashes with "Segmentation fault".

I call this function inside of class derived from wxControl:

Code: Select all

XtVaCreateManagedWidget(..., ..., this->GetHandle(), ..., ..., 0);
What is the problem? I think it with return value of this->GetHandle(), but I don't know what to do.

SoS

Thanks in advance.
saint
Earned a small fee
Earned a small fee
Posts: 17
Joined: Mon Mar 20, 2006 11:09 am
Location: Ukraine, Dnipropetrovsk

Post by saint »

So, people, are there nobody to advise me what's the problem. Please help.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,
So, people, are there nobody to advise me what's the problem.
Perhaps there aren't! One reason for using wxWidgets is so that we don't have to worry about low-level things like this. ;)

I don't know anything about this sort of thing either, so don't expect me to know what I'm talking about. However the code that you posted has the obvious problem that you aren't casting this->GetHandle(). According to the wxWindow::GetHandle doc, you should at least write something like (GtkWidget*)this->GetHandle().

Even this is giving you the intermediate level GtkWidget. From that you will presumably need to get at the underlying GdkWindow (or something similar --- I know absolutely nothing about gdk), and from that you should be able to get at the X widget that you actually need.

Information that should be useful and accurate (unlike the above :( ) is at http://www.gtk.org/api/.

Good luck,

David
saint
Earned a small fee
Earned a small fee
Posts: 17
Joined: Mon Mar 20, 2006 11:09 am
Location: Ukraine, Dnipropetrovsk

Post by saint »

DavidHart, thanks for your answer.
the obvious problem that you aren't casting this->GetHandle()
I cast the result of GetHandle, because in other case compiler wouldn't compile the code. But the problem was in that I used X11 port of wxWidgets and it's GetHandle return X11's "Window", when I really need Motif's "Widget". So I simply use a Motif port of wxWidgets and it works. I'm very glad :D :D :D
Post Reply