I just bought BlitzPlus... Help, please!

BlitzPlus Forums/BlitzPlus Beginners Area/I just bought BlitzPlus... Help, please!

Your Friendly Neighborhood Geek(Posted 2008) [#1]
I made a code for the base of a program, and need help. It seems as though every time I close a tool window, I close the whole program. Could someone fix this code so that closing the window that comes up when you click File> New doesn't close the entire program. Here is the code:
------------------------------------------------------------
;program by Paul Herz

Global filename
filename="project2"

Window1=CreateWindow("Program",500,300,400,300)
SetMinWindowSize Window1,400,300
SetStatusText Window1,"©2008 ÆroBlu Software"

menu=WindowMenu(Window1)
file=CreateMenu("File",0,menu)

CreateMenu("New",1,file)
CreateMenu("Open",2,file)
CreateMenu("",0,file)
CreateMenu("Save",3,file)
CreateMenu("Save as...",4,file)
CreateMenu("",0,file)
CreateMenu("Quit",5,file)

Function newfilewindow()
file=CreateWindow("TEST",525,335,350,240,0,17)

End Function

UpdateWindowMenu Window1
;--->>MAIN<>LOOP<<---;
Repeat


id=WaitEvent()

If ID=$803 Then End

If ID=$1001 Then
EID=EventData()
Select EID
Case 1
newfilewindow()
Case 2
AppTitle("Open")
Notify("Open")

Case 3
AppTitle("Save")
Notify("Save")

Case 4
AppTitle("Save as...")
Notify("Save as...")

Case 5
AppTitle("Are You Sure?")
result=Confirm("Are You Sure You Want to Quit?",True)
If result=1 Then
End
Else
EndIf

End Select

EndIf

Forever

End


Ked(Posted 2008) [#2]
If ID=$803 Then End

There's your problem. You need to see which window has closed with EventSource.


Your Friendly Neighborhood Geek(Posted 2008) [#3]
OK Thanks,
it is late,
so I will test it
2Mar0.
9|-| -smiley of the day: Miner smiley!
--------------------------------------


Your Friendly Neighborhood Geek(Posted 2008) [#4]
but both windows
(i tested in the blitzcc console)
returns zero!
and when I try to attach a group
handle, it screws up! |-((
--------------------------------


Kev(Posted 2008) [#5]
you need to check the event, the window 'file' needs to be global


event = WaitEvent()
Select event

	Case $803
		window_closed = EventSource()
		Select window_closed
			
			Case Window1
			
			Case file
			
		End Select
End Select



Your Friendly Neighborhood Geek(Posted 2008) [#6]
thanks, that is helpful.

P.S. how the heck do you do that black bg.
and green text? Is this forum BBCode or HTML
based?

BBCode: no irony, please.


Your Friendly Neighborhood Geek(Posted 2008) [#7]
oh dag. :-( I give up. can someone just fix the code?
now nothing works:

;program by Paul Herz

Global filename
filename="project2"
Global filewin

Window1=CreateWindow("Program",500,300,400,300)
SetMinWindowSize Window1,400,300
SetStatusText Window1,"©2008 ÆroBlu Software"

menu=WindowMenu(Window1)
file=CreateMenu("File",0,menu)

CreateMenu("New",1,file)
CreateMenu("Open",2,file)
CreateMenu("",0,file)
CreateMenu("Save",3,file)
CreateMenu("Save as...",4,file)
CreateMenu("",0,file)
CreateMenu("Quit",5,file)

Function newfilewindow()
filewin=CreateWindow("TEST",525,335,350,240,0,17)
End Function

UpdateWindowMenu Window1
;--->>MAIN<>LOOP<<---;
Repeat


id=WaitEvent()
event = WaitEvent()
Select event
Case $803
window_closed = EventSource()
Select window_closed
Case Window1
Case file
End Select
End Select

If ID=$803 Then
Print EventData
EndIf

If ID=$1001 Then
EID=EventData()
Select EID
Case 1
newfilewindow()
Case 2
AppTitle("Open")
Notify("Open")

Case 3
AppTitle("Save")
Notify("Save")

Case 4
AppTitle("Save as...")
Notify("Save as...")

Case 5
AppTitle("Are You Sure?")
result=Confirm("Are You Sure You Want to Quit?",True)
If result=1 Then
End
Else
EndIf

End Select

EndIf

Forever

End

;-----------------------


Kev(Posted 2008) [#8]
take a look at the code below, we only need to call waitevent once, events can be checked using 'event' var it will contain the last generated event.

Global filename
filename="project2"
Global filewin

Window1=CreateWindow("Program",500,300,400,300)
SetMinWindowSize Window1,400,300
SetStatusText Window1,"©2008 ÆroBlu Software"

menu=WindowMenu(Window1)
file=CreateMenu("File",0,menu)

CreateMenu("New",1,file)
CreateMenu("Open",2,file)
CreateMenu("",0,file)
CreateMenu("Save",3,file)
CreateMenu("Save as...",4,file)
CreateMenu("",0,file)
CreateMenu("Quit",5,file)

Function newfilewindow()
	filewin=CreateWindow("TEST",525,335,350,240,0,17)
End Function

UpdateWindowMenu Window1
;--->>MAIN<>LOOP<<---;
Repeat


event = WaitEvent() 
Select event 
	
	Case $1001	; menu action events 
		EID=EventData()
		Select EID
			Case 1
				newfilewindow()
			Case 2
				AppTitle("Open")
				Notify("Open")

			Case 3
				AppTitle("Save")
				Notify("Save")

			Case 4
				AppTitle("Save as...")
				Notify("Save as...")

			Case 5
				AppTitle("Are You Sure?")
				result=Confirm("Are You Sure You Want to Quit?",True)
				If result=1 Then
					End
				EndIf
		End Select
		
	Case $803 ; close window events
		window_closed = EventSource() 
		Select window_closed 
			Case Window1 
				Notify "You clicked to close Window1"
			Case filewin
				Notify "You clicked to close filewin"
				HideGadget filewin 
		End Select 

End Select 

Forever

End 


code tags are {code} {/code} but change '{' and '}' for '[' and ']'

kev


Yeshu777(Posted 2008) [#9]
Asi

Forum Codes:

http://www.blitzbasic.com/faq/faq_entry.php?id=2


Your Friendly Neighborhood Geek(Posted 2008) [#10]
God, thanks a bunch, Kev. Now that I have a base ready, I don't have to be such an n00B.

-----------------------------------------------------


Your Friendly Neighborhood Geek(Posted 2008) [#11]
lets try some BBcode with {}s magic...
{i}uberitalics!{/i}
{b}UBER-BOLDINESS!{/b}
okay, fun over.
did that work...?


Your Friendly Neighborhood Geek(Posted 2008) [#12]
okay... horrible failure.


xlsior(Posted 2008) [#13]
Use [ and ] , not { }


Your Friendly Neighborhood Geek(Posted 2008) [#14]
oh...