Page 9 of 13
Posted: Sat Feb 04, 2006 12:30 pm
by PB
> Window Object not initialized?
Which lines gives that error? Because this works fine for me:
Code: Select all
win1 = OpenWindow(0,0,0,x_res,y_res,#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget,"Black Knight")
If InitSprite() <> 0 And InitMouse() <> 0 And OpenWindowedScreen(win1,0,0,x_res,y_res,0,0,0) <> 0
If CreateMenu(0, WindowID(win1)) ; create menus
MenuTitle("File")
MenuItem(1, "New Game")
MenuItem(2, "Load Game")
MenuItem(3, "Save Game")
MenuItem(4,"Exit Program")
MenuTitle("Help")
MenuItem(5, "About")
EndIf
EndIf
Posted: Sat Feb 04, 2006 12:30 pm
by thefool
Great

waiting for bericko now

Posted: Sat Feb 04, 2006 12:32 pm
by Berikco
thefool wrote:Great

waiting for bericko now

Me too

Posted: Sat Feb 04, 2006 12:34 pm
by Steve Elliott
Which line gives the error?
If CreateMenu(0, WindowID(win1)) ; create menus
Posted: Sat Feb 04, 2006 12:38 pm
by PB
Try replacing WindowID(win1) with WindowID(0), because WindowID() is for
a window number (in your case, 0) and win1 is the window handle... so what
you're doing is trying to use a WindowID of 4467583 or so (the handle), when
obviously no such window number exists.
Posted: Sat Feb 04, 2006 12:42 pm
by Num3
Win1=WindowID(0)
so:
Code: Select all
win1 = OpenWindow(0,0,0,x_res,y_res,#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget,"Black Knight")
If InitSprite() <> 0 And InitMouse() <> 0 And OpenWindowedScreen(win1,0,0,x_res,y_res,0,0,0) <> 0
If CreateMenu(0, win1) ; create menus
MenuTitle("File")
MenuItem(1, "New Game")
MenuItem(2, "Load Game")
MenuItem(3, "Save Game")
MenuItem(4,"Exit Program")
MenuTitle("Help")
MenuItem(5, "About")
EndIf
EndIf
or
Code: Select all
OpenWindow(0,0,0,x_res,y_res,#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget,"Black Knight")
If InitSprite() <> 0 And InitMouse() <> 0 And OpenWindowedScreen(WindowID(0),0,0,x_res,y_res,0,0,0) <> 0
If CreateMenu(0, WindowID(0)) ; create menus
MenuTitle("File")
MenuItem(1, "New Game")
MenuItem(2, "Load Game")
MenuItem(3, "Save Game")
MenuItem(4,"Exit Program")
MenuTitle("Help")
MenuItem(5, "About")
EndIf
EndIf
Posted: Sat Feb 04, 2006 12:44 pm
by PB
Strange that my snippet didn't throw up that error, though...?
Posted: Sat Feb 04, 2006 12:44 pm
by Steve Elliott
Thanks that works fine now - but win1 also has to change to 0 in commands like WindowMouseX(win1).
Posted: Sat Feb 04, 2006 1:04 pm
by SFSxOI
still no non-directx related keyboard commands
*sigh*
Oh well, back to using API for the keyboard i guess.
Posted: Sat Feb 04, 2006 1:08 pm
by thefool
Berikco wrote:thefool wrote:Great

waiting for bericko now

Me too


Posted: Sat Feb 04, 2006 1:48 pm
by Inf0Byt3
WOW!!!

This is great!!! Many thanks to Fred and to PureBasic Team for this state-of-the-art language.
Posted: Sat Feb 04, 2006 2:28 pm
by Edwin Knoppert
I was updating PBDev, a new beta is there but i need one additional part.
What is required to determine a menuevent has occured and then what id?
I have something like this but does not work:
Select EventID
Case #PB_Event_CloseWindow
CloseWindow( WindowID )
MainID = 0
Case EventMenu()
MessageRequester( Str( EventMenu() ),"", 0 )
Not working since i guess a #PB constant is still required in the select case..?
Thanks!
Posted: Sat Feb 04, 2006 2:46 pm
by Edwin Knoppert
Got it
Case #PB_Event_Menu
Debug( "EventMenu " + Str( EventMenu() ) )
Posted: Sat Feb 04, 2006 3:38 pm
by Baldrick
Sheesh, looks like we got some work in front of all of us to update our code. - Also looks like end results will be more than worth the effort.
Thanks Fred & Team!!!!
@Steve Elliott
addition to Num3 suggestion - Think maybe if you use #PB_Any for win1, this would also resolve issue for you.
Code: Select all
Enumeration
#new_game
#load_game
#save_game
#exit_program
#about
EndEnumeration
x_res=200:y_res=200
win1 = OpenWindow(#PB_Any,0,0,x_res,y_res,#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget,"Black Knight")
If win1
If InitSprite() <> 0 And InitMouse() <> 0 And OpenWindowedScreen(WindowID(win1),0,0,200,200,0,0,0) <> 0
If CreateMenu(0, WindowID(win1)) ; create menus
MenuTitle("File")
MenuItem(#new_game, "New Game")
MenuItem(#load_game, "Load Game")
MenuItem(#save_game, "Save Game")
MenuItem(#exit_program,"Exit Program")
MenuTitle("Help")
MenuItem(#about, "About")
EndIf
EndIf
EndIf
Repeat
EvId=WindowEvent():If EvId=0:Delay(1):Else:Delay(0):EndIf
If EvId=#PB_Event_CloseWindow:Quit=1:EndIf
Until Quit
End
Posted: Sat Feb 04, 2006 3:45 pm
by SFSxOI
Can we expect the feature set in the beta to also be in the final version? I'm asking because I don't want to start updating my existing code until i'm sure that what I use from the beta will also appear in the final version.