in reply to [fixed] Wx with XRC, get handle on objects

All objects defined in XRC are either sizers or windows (in particular, both texts and buttons are windows, i.e. they derive from wx::Window). As FindWindowByName() only finds windows -- and not sizers -- I think its name is perfectly appropriate. FWIW here is a function which I used in one of my projects:
# call with parent window and the (string) XRC id, returns # the corresponding window sub FindByXRCID($$) { my ($win, $idname) = @_; my $id = Wx::XmlResource::GetXRCID($idname) or die("no $idname in XRC"); my $ctrl = $win->FindWindow($id) or die("window with id \"$idname\" ($id) not found in " . $win->GetName()); return $ctrl; }

Replies are listed 'Best First'.
Re^2: [fixed] Wx with XRC, get handle on objects
by wilsond (Scribe) on Jan 26, 2009 at 00:07 UTC

    Thanks for the input and the subclass info. How would you get a sizer?


    While I ask a lot of Win32 questions, I hate Windows with a passion. That's the problem with writing a cross-platform program. I'm a Linux user myself. I wish more people were.
    If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
    - Richard Dawkins
      You usually don't need to get sizers so there is no dedicated function for them. Instead you can use GetSizer() or GetContainingSizer() on a window containing/contained in the sizer you need after finding it using its id as per above.

        Hmm. I see.. and probably agree. I guess it'd be hard to get a sizer that contains only sizers? I don't think I'd ever need to, but who knows. If there's an easy answer, I'd love to know. If not, don't worry about it. it's not that important or useful to me. Thanks for the input.


        While I ask a lot of Win32 questions, I hate Windows with a passion. That's the problem with writing a cross-platform program. I'm a Linux user myself. I wish more people were.
        If you want to do evil, science provides the most powerful weapons to do evil; but equally, if you want to do good, science puts into your hands the most powerful tools to do so.
        - Richard Dawkins