I just bought BlitzPlus... Help, please!
BlitzPlus Forums/BlitzPlus Beginners Area/I just bought BlitzPlus... Help, please!| 
 | ||
| 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 | 
| 
 | ||
|  If ID=$803 Then End  There's your problem. You need to see which window has closed with EventSource. | 
| 
 | ||
| OK Thanks, it is late, so I will test it 2Mar0. 9|-| -smiley of the day: Miner smiley! -------------------------------------- | 
| 
 | ||
| but both windows (i tested in the blitzcc console) returns zero! and when I try to attach a group handle, it screws up! |-(( -------------------------------- | 
| 
 | ||
| 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 | 
| 
 | ||
| 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. | 
| 
 | ||
| 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 ;----------------------- | 
| 
 | ||
| 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 | 
| 
 | ||
| Asi Forum Codes: http://www.blitzbasic.com/faq/faq_entry.php?id=2 | 
| 
 | ||
| God, thanks a bunch, Kev. Now that I have a base ready, I don't have to be such an n00B. ----------------------------------------------------- | 
| 
 | ||
| lets try some BBcode with {}s magic... {i}uberitalics!{/i} {b}UBER-BOLDINESS!{/b} okay, fun over. did that work...? | 
| 
 | ||
| okay... horrible failure. | 
| 
 | ||
| Use [ and ] , not { } | 
| 
 | ||
| oh... |