PureBasic v4.00 - Beta 1

Developed or developing a new product in PureBasic? Tell the world about it.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Great :) waiting for bericko now ;)
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

thefool wrote:Great :) waiting for bericko now ;)
Me too :twisted:
Steve Elliott
Enthusiast
Enthusiast
Posts: 109
Joined: Sun Jan 01, 2006 9:34 pm
Location: Wales, UK

Post by Steve Elliott »

Which line gives the error?
If CreateMenu(0, WindowID(win1)) ; create menus
Project S: loading...
Intel Core2 Duo E7200 @ 2.53Ghz, 3Gb RAM Intel G45 Express
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
Last edited by PB on Sat Feb 04, 2006 12:42 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post 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 
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Strange that my snippet didn't throw up that error, though...?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Steve Elliott
Enthusiast
Enthusiast
Posts: 109
Joined: Sun Jan 01, 2006 9:34 pm
Location: Wales, UK

Post by Steve Elliott »

Thanks that works fine now - but win1 also has to change to 0 in commands like WindowMouseX(win1).
Project S: loading...
Intel Core2 Duo E7200 @ 2.53Ghz, 3Gb RAM Intel G45 Express
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

still no non-directx related keyboard commands :(

*sigh*

Oh well, back to using API for the keyboard i guess.
Last edited by SFSxOI on Sat Feb 04, 2006 1:18 pm, edited 1 time in total.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Berikco wrote:
thefool wrote:Great :) waiting for bericko now ;)
Me too :twisted:
:lol:
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

WOW!!! :shock: This is great!!! Many thanks to Fred and to PureBasic Team for this state-of-the-art language.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post 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!
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Got it :)

Case #PB_Event_Menu

Debug( "EventMenu " + Str( EventMenu() ) )
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post 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. :D
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
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post 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.
Post Reply