Hi, is there any way to center the default Wx::MessageDialog or Wx::message_box on parent (owner) instead of screen? I haven''t found any constant other than Wx::DEFAULT_POSITION. thanks for your help. fabio. _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Fabio Petrucci wrote:> is there any way to center the default Wx::MessageDialog or > Wx::message_box on parent (owner) instead of screen?Dialogs have a centre_on_parent method, inherited from Wx::Window, which should do what you want cheers alex
Ciao Alex,
i''ve found that method but it doesn''t work, this is what i
did:
md = Wx::MessageDialog.new(parent, message,
title, Wx::OK|Wx::ICON_EXCLAMATION)
md.centre_on_parent()
md.show_modal()
is it the right sequence?
thank you.
fabio.
On 9/5/07, Alex Fenton <alex at pressure.to>
wrote:>
> Fabio Petrucci wrote:
> > is there any way to center the default Wx::MessageDialog or
> > Wx::message_box on parent (owner) instead of screen?
> Dialogs have a centre_on_parent method, inherited from Wx::Window, which
> should do what you want
>
> cheers
> alex
>
>
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/wxruby-users/attachments/20070906/fed84ae2/attachment.html
Fabio Petrucci wrote:> Ciao Alex, > i''ve found that method but it doesn''t work, this is what i did: > > md = Wx::MessageDialog.new(parent, message, > title, Wx::OK|Wx::ICON_EXCLAMATION) > md.centre_on_parent() > md.show_modal()It looks right to me and something similar works. Could you send a complete test case and platform/version info please? cheers alex
...here is an example tested on win xp, wxruby 1.9.0:
begin
require ''wx''
rescue LoadError => no_wx_err
begin
require ''rubygems''
require ''wx''
rescue LoadError
raise no_wx_err
end
end
include Wx
DIALOGS_MODAL = 19
class MyFrame < Frame
def initialize(parent,
title,
pos,
size)
super(parent, -1, title, pos, size)
evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) }
end
def on_modal_dlg(event)
md = Wx::MessageDialog.new(self, "Should be centered on
parent...",
"centered", Wx::OK|Wx::ICON_INFORMATION)
md.centre_on_parent()
md.show_modal()
end
end
class MyApp < App
def on_init()
frame = MyFrame.new(nil, "Centered dialog example",
Point.new(20, 20), Size.new(400, 300))
# Make a menubar
file_menu = Menu.new
file_menu.append(DIALOGS_MODAL, "Mo&dal dialog\tCtrl-W")
menu_bar = MenuBar.new
menu_bar.append(file_menu, "&File")
frame.set_menu_bar(menu_bar)
frame.show()
end
end
app = MyApp.new()
app.main_loop()
On 9/6/07, Alex Fenton <alex at pressure.to>
wrote:>
> Fabio Petrucci wrote:
> > Ciao Alex,
> > i''ve found that method but it doesn''t work, this is
what i did:
> >
> > md = Wx::MessageDialog.new(parent, message,
> > title, Wx::OK|Wx::ICON_EXCLAMATION)
> > md.centre_on_parent()
> > md.show_modal()
> It looks right to me and something similar works. Could you send a
> complete test case and platform/version info please?
>
> cheers
> alex
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/wxruby-users/attachments/20070906/21d0f82f/attachment.html
Fabio Petrucci wrote:> ...here is an example tested on win xp, wxruby 1.9.0: >Looks like this won''t work with MessageDialog on Windows; see this thread on the wx mailing list: http://lists.wxwidgets.org/archive/wx-users/msg14354.html http://lists.wxwidgets.org/archive/wx-users/msg14355.html If it really must be centred, you could derive a class from Wx::Dialog cheers alex
Ok... i can get by, thanks again. cheers fabio. On 9/6/07, Alex Fenton <alex at pressure.to> wrote:> > Fabio Petrucci wrote: > > ...here is an example tested on win xp, wxruby 1.9.0: > > > Looks like this won''t work with MessageDialog on Windows; see this > thread on the wx mailing list: > > http://lists.wxwidgets.org/archive/wx-users/msg14354.html > http://lists.wxwidgets.org/archive/wx-users/msg14355.html > > If it really must be centred, you could derive a class from Wx::Dialog > > cheers > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070906/8b95eb70/attachment.html