Beginner Questions

5 views
Skip to first unread message

Glenn Dodd

unread,
Dec 24, 2007, 4:17:18 AM12/24/07
to wxMax
I am just starting to work through the modules.
The below code opens 2 windows:
[codebox]
SuperStrict

Framework wx.wxApp
Import wx.wxFrame

Type MyApp Extends wxApp

Field ParentFrame:wxFrame
Field ChildFrame:wxFrame

Method OnInit:Int()
' Method Create:wxFrame(parent:wxWindow = Null, id:Int = -1,
title:String = "", x:Int = -1, y:Int = -1, w:Int = -1, h:Int = -1,
style:Int = wxDEFAULT_FRAME_STYLE)
ParentFrame = wxFrame.CreateFrame(,,"Parent Frame", 100, 100)
ParentFrame.show()
ChildFrame = wxFrame.createframe(ParentFrame,,"Child Frame",150,150)
ChildFrame.show()

Return True

End Method

End Type


New MyApp.run()

' Closing the Child Frame has no effect on the Parent Frame
' Closing the Parent Frame CLOSES the Child Frame too
[/codebox]

I now want to ask a question if the parent closes with the code below:
[codebox]
SuperStrict

Framework wx.wxApp
Import wx.wxFrame

Type MyApp Extends wxApp

' Field ParentFrame:wxFrame
Field ParentFrame:MyFrame
Field ChildFrame:wxFrame

Method OnInit:Int()
' Method Create:wxFrame(parent:wxWindow = Null, id:Int = -1,
title:String = "", x:Int = -1, y:Int = -1, w:Int = -1, h:Int = -1,
style:Int = wxDEFAULT_FRAME_STYLE)
' ParentFrame = wxFrame.CreateFrame(,,"Parent Frame", 100, 100)
ParentFrame = MyFrame.CreateFrame(,,"Parent Frame", 100, 100)
ParentFrame.show()
ChildFrame = wxFrame.createframe(ParentFrame,,"Child Frame",150,150)
ChildFrame.show()

Return True

End Method

End Type


New MyApp.run()

' Closing the Parent Frame ASKS for confirmation before closing

Type MyFrame Extends wxFrame

Function OnCloseWindow(_event:wxEvent)
Local Result:Int = Confirm("Are you sure you want to Close BOTH
Windows?")
If Result = False Then Exit
End Function

End Type
[/codebox]
but it complains about "unable to convert from wxFrame to MyFrame"


What am i doing wrong?

Cheers
Glenn

Noel Cower

unread,
Dec 24, 2007, 4:47:07 AM12/24/07
to wx...@googlegroups.com
I wonder if replying to this works.

Anyway, the problem is that wxFrame.CreateFrame does not return a
MyFrame, even if you inherit from wxFrame. You need to create it like this:

' BEGIN
SuperStrict

Import wx.wx
Import wx.wxApp
Import wx.wxFrame

Type MyApp Extends wxApp


Field ParentFrame:MyFrame
Field ChildFrame:wxFrame

Method OnInit:Int()
ParentFrame = MyFrame(New MyFrame.Create(,,"Parent Frame", 100, 100))


ParentFrame.show()
ChildFrame = wxFrame.createframe(ParentFrame,,"Child Frame",150,150)
ChildFrame.show()

Return True

End Method
End Type

Type MyFrame Extends wxFrame

Function OnCloseWindow(_event:wxEvent)
Local Result:Int = Confirm("Are you sure you want to Close BOTH Windows?")

If Result = False Then Return
End Function
End Type

New MyApp.run()
' END

-noel

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "wxMax" group.
> To post to this group, send email to wx...@googlegroups.com
> To unsubscribe from this group, send email to wxmax-un...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/wxmax?hl=en
> -~----------~----~----~----~------~----~------~--~--

Reply all
Reply to author
Forward
0 new messages