Dialog does not send the events

Just starting out? Need help? Post your questions and find answers here.
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Dialog does not send the events

Post by PB_Rainer »

Hello,
I have a problem in my program:
  • The Prog opens a BMP-File
    reads a colorstatistc
    makes a palettepicture with the used colors
When I open the Dialog_1 to work on the BMP everything is ok. All gadgets are sending the events, it works perfekt.

When I first open the Statistic-Dialog_2 to see the percentage also is working in this dialog, it is ok.

When I now open the Dialog_1 again, after opening and closing Dialog_2 before, to work on the BMP, no Gadget is sending the event to the eventloop. I can not work with the gadgets. the gadgets are not disabled. Comboboxes are openig and scrolling, but absolutely no other reaction on clicked buttons and so on.

I looked at all positions in the source, cannot find any disabling of the Dialog_1 or any gadget in it.

Has anyone any idea why a dialog does not send the events to the eventloop when another Dialog was opened before.

Regards
Rainer
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Dialog does not send the events

Post by wombats »

Can you show an example?

Do you free the dialog when you are done with it?
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Dialog does not send the events

Post by BarryG »

PB_Rainer wrote:Has anyone any idea why a dialog does not send the events to the eventloop when another Dialog was opened before.
Not without seeing your code, but I know for sure that it's a coding problem that you've missed/overlooked.
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Re: Dialog does not send the events

Post by PB_Rainer »

Thanks for your interest on this problem.

The Code ist more than 4000 lines. All comments are in german language.
It is very difficult to explain for others what I do with this program.
It is a very special software for Carpet-Designers and Carpet-Weavers.

I do not work with Dialogs based on xml-Files. The dialogs are made with PureBasic Designer.
I call them with OpenWindowname and close them with CloseWindow(Windowname)

I checked all disablings, enablings or SetActiveWindow(), HideWindow()

cannot find the mistake.

Calling the Dialog_2 several times succsecively there is no mistake. The Dialog_2 is always working correct.
If I call Dialog_2 first and then Dialog_1, Dialog_1 ist dead.

Thanks
Rainer
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Dialog does not send the events

Post by Demivec »

My guess is that you use the same ID numbers for gadgets in in both Dialogs. Depending on what the gadgets are you would get a working Dialog_2 but not a working Dialog_1.

The way to check for this is if you the constants you use for the gadgets have the same value (even if they have different names). If you use instead use #PB_Any to generate the ID's then this probably isn't the issue.


Good Luck!
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Dialog does not send the events

Post by BarryG »

PB_Rainer wrote:When I now open the Dialog_1 again, after opening and closing Dialog_2 before, to work on the BMP, no Gadget is sending the event to the eventloop. I can not work with the gadgets. the gadgets are not disabled. Comboboxes are openig and scrolling, but absolutely no other reaction on clicked buttons and so on.
Sounds like you're using more than one event loop. Is that the case? WaitWindowEvent() should only be called once, to handle all events (dialog clicks, etc) for all dialogs.
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Re: Dialog does not send the events

Post by PB_Rainer »

Hi,
that's right I use 2 Eventloops:

Here the Source, sorry a little bit long!

Code: Select all

Repeat
	Event = WaitWindowEvent()	
	Select EventWindow()
		Case TabWindow
			TabWindow_Events(Event) ; Dieser Prozedurname ist immer der Fenstername gefolgt von '_Events'
			If Event = #PB_Event_CloseWindow 
				CloseWindow(TabWindow)
				ProgExit = 1
			ElseIf Event = #PB_Event_SizeWindow
				ExamineDesktops()
				GetWindowRect_(FindWindow_("Shell_TrayWnd",0),taskwin.RECT)
				TaskBarHeight = (taskwin \ bottom - taskwin \ top)
				MyFrame = FrameGadget(#PB_Any,0,52,WindowWidth(TabWindow , #PB_Window_FrameCoordinate),4,"",#PB_Frame_Double)
				For x = 1 To  GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerWidth) Step 500
					SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X,x)
				Next
				For y = 1 To GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) Step 500
					SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y,y)
				Next				
 				ScrollAreaWidth = GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerWidth) - GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X)
 				ScrollAreaHeight = GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) - GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y)
 				WindowBounds(TabWindow, 1280, 768, DesktopWidth(0), DesktopHeight(0))
				If OriginalImage
					Original_Image_Draw()
					Palette_DrawFromDesign(OriginalFile, "Original", 0)
				EndIf
				If SteuerstreifenImage
					Steuerstreifen_Image_Draw()
					Palette_DrawFromDesign(TempFileName, "SteuerStreifen", SteuerStreifenLen)
				EndIf
			EndIf
		Case ListWindow
			ListWindow_Events(Event)
			If Event = #PB_Event_CloseWindow 
				CloseWindow(ListWindow) 
				If OriginalImageLoaded = #True And SteuerStreifenImageLoaded = #True
					DisableEnable_ToolBarButtons(0,0,0,1,0,0,1,0)
				ElseIf OriginalImageLoaded = #True And SteuerStreifenImageLoaded = #False
					DisableEnable_ToolBarButtons(0,0,1,0,0,0,1,0)
				EndIf
			EndIf		
		Case SteuerstreifenWindow
			SteuerstreifenWindow_Events(Event)
			If Event = #PB_Event_CloseWindow 
				CloseWindow(SteuerstreifenWindow) 
				DisableEnable_ToolBarButtons(0,0,1,0,0,0,1,0)	
			EndIf	
		Case ProgramSetupWindow
			ProgramSetupWindow_Events(Event)
			If Event = #PB_Event_CloseWindow 
				CloseWindow(ProgramSetupWindow)
				DisableEnable_ToolBarButtons(0,0,1,1,1,0,0,0)
			EndIf	
		Case NewBindingWindow
			NewBindingWindow_Events(Event)
			If Event = #PB_Event_CloseWindow 
				CloseWindow(NewBindingWindow)
				SetActiveWindow(SteuerstreifenWindow)
				DisableWindow(SteuerstreifenWindow, #False)
			EndIf	
		Case Steuerstreifen_BindingViewer
			Steuerstreifen_BindingViewer_Events(event)
			If Event = #PB_Event_CloseWindow 
				CloseWindow(Steuerstreifen_BindingViewer)
				SetActiveWindow(SteuerstreifenWindow)
				DisableWindow(SteuerstreifenWindow, #False)
			EndIf
	EndSelect
; First part is for the windows/Dialogs in the program with their own Eventloop

;***************************************************************

; Second part handles all keyboard/menu/toolbarevents and hotkeys
		
	Select Event	
  	Case #PB_Event_Menu
      Select EventMenu()
      	Case 1903
      		DisplayPopupMenu(100,WindowID(TabWindow), (WindowX(TabWindow, #PB_Window_InnerCoordinate) + 1), (WindowY(TabWindow, #PB_Window_InnerCoordinate) + 57))
      	Case 3001 To 3030
      		GetMenuItemText(100, EventMenu())
      		If Not Left(GetMenuItemText(100, EventMenu()), 4) = StSt_None
      			Design_LoadFromList(GetMenuItemText(100, EventMenu()))
      		EndIf
      	Case #Toolbar_load, 1003
      		Icon_Load(EventMenu())
      	Case #ToolBar_Liste, 1903
      		DisplayPopupMenu(100,WindowID(TabWindow), (WindowX(TabWindow, #PB_Window_InnerCoordinate) + 1), (WindowY(TabWindow, #PB_Window_InnerCoordinate) + 57))
				Case #Toolbar_Save, 1002
					Icon_Save(EventMenu())
				Case #Toolbar_Make, 1004
					Icon_Make(EventMenu())
				Case #Toolbar_Statistic, 1006
					Icon_Statistic(EventMenu())
				Case #Toolbar_Help, 1001
					Icon_Help(EventMenu())
				Case #Toolbar_Setup, 1007
					Icon_Setup(EventMenu())
				Case 1010 ; Zoom 0
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetState(TrackBar_Original) > 0)
							SetGadgetState(TrackBar_Original, 0)
							Original_Image_Zoom(EventType)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetState(TrackBar_SteuerStreifen) > 0)
							SetGadgetState(TrackBar_SteuerStreifen, 0)
							Steuerstreifen_Image_Zoom(EventType)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1011 ; Zoom kleiner
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetState(TrackBar_Original) > 0) And (GetGadgetState(TrackBar_Original) <= 10) 
							SetGadgetState(TrackBar_Original, (GetGadgetState(TrackBar_Original) - 1))
							Original_Image_Zoom(EventType)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetState(TrackBar_SteuerStreifen) > 0) And (GetGadgetState(TrackBar_SteuerStreifen) <= 10) 
							SetGadgetState(TrackBar_SteuerStreifen, (GetGadgetState(TrackBar_SteuerStreifen) - 1))
							Steuerstreifen_Image_Zoom(EventType)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1012 ; Zoom größer
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetState(TrackBar_Original) => 0) And (GetGadgetState(TrackBar_Original) <= 9) 
							SetGadgetState(TrackBar_Original, (GetGadgetState(TrackBar_Original) + 1))
							Original_Image_Zoom(EventType)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetState(TrackBar_SteuerStreifen) => 0) And (GetGadgetState(TrackBar_SteuerStreifen) <= 9) 
							SetGadgetState(TrackBar_SteuerStreifen, (GetGadgetState(TrackBar_SteuerStreifen) + 1))
							Steuerstreifen_Image_Zoom(EventType)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1101 ; Entspricht NumPad 1 Ende
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X , 0)
						EndIf
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight + 1))
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y , GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight))
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X , 0)
						EndIf
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y , GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight))
						EndIf
					EndIf
				Case 1102 ; Entspricht NumPad 2 Down
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y ,GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y) + 200)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_Y) < GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y ,GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y) + 200)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1103 ; Entspricht NumPad 3 Page down
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X ,GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerWidth))
						EndIf
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y , GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight))
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X , GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerWidth))
						EndIf
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y , GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight))
						EndIf
					EndIf							
				Case 1104 ; Entspricht NumPad 4 Left
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_X) > 0) 
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X ,GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X) - 200)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_X) > 0) 
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X ,GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X) - 200)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1106 ; Entspricht NumPad 6 Right
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_X) < GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerWidth) - (ScrollAreaWidth+1))
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X ,GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X) + 200)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_X) < GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerWidth) - (ScrollAreaWidth+1))
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X ,GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X) + 200)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1107 ; Entspricht NumPad 7 Pos1
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X ,0)
						EndIf
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y , 0)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X , 0)
						EndIf
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y , 0)
						EndIf
					EndIf
				Case 1108 ; Entspricht NumPad 8 Up
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_Y) > 0) 
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y ,GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y) - 200)
						Else
							Beep_(800,300)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_Y) > 0) 
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y ,GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y) - 200)
						Else
							Beep_(800,300)
						EndIf
					EndIf
				Case 1109 ; Entspricht NumPad 9 Page up
					If GetGadgetState(Panel_1) = 0
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_X ,GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerWidth))
						EndIf
						If (GetGadgetAttribute(ScrollArea_Original, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Original,#PB_ScrollArea_Y , 0)
						EndIf
					ElseIf GetGadgetState(Panel_1) = 2
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_X) >= 0) 
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_X , GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerWidth))
						EndIf
						If (GetGadgetAttribute(ScrollArea_Steuerstreifen, #PB_ScrollArea_Y) <= GetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_InnerHeight) - (ScrollAreaHeight+1))
							SetGadgetAttribute(ScrollArea_Steuerstreifen,#PB_ScrollArea_Y , 0)
						EndIf
					EndIf
				Case 1200
					If GetGadgetState(Panel_1) <> 0
						If OriginalImageLoaded = #True
							SetGadgetState(Panel_1,0)
						Else
							Beep_(800,300)	
						EndIf
					EndIf
				Case 1201
					If GetGadgetState(Panel_1) <> 1
						If OriginalPaletteLoaded = #True
							SetGadgetState(Panel_1,1)
						Else
							Beep_(800,300)	
						EndIf
					EndIf
				Case 1202
					If GetGadgetState(Panel_1) <> 2
						If SteuerStreifenImageLoaded = #True
							SetGadgetState(Panel_1,2)
						Else
							Beep_(800,300)	
						EndIf
					EndIf
				Case 1203
					If GetGadgetState(Panel_1) <> 3
						If SteuerStreifenPaletteLoaded = #True
							SetGadgetState(Panel_1,3)
						Else
							Beep_(800,300)	
						EndIf
					EndIf
				Case #Toolbar_Exit, 9999
					Icon_Exit(EventMenu())
					ProgExit = 1
			EndSelect
	EndSelect	
Until ProgExit = 1 
It is one code between repeat >> until

Some informations:

TabWindow is the mainWindow, opened first.
This window contains the panel with 4 pages, scrollareas, canvasgadgets, trackbars and the toolbar, from which all other windows will be opened.
In the first part, all windows with their own eventloops are checked and handled.

In the second part all other actions, belonging to the TabWindow (MainWindow), are handled, events from/for panel-pages, scrollbars, trackbars, scrollareas, keyboard-hotkeys and so on.

What and where is the mistake with two event loops in one repeat >> until loop?

Hopeful regards
Rainer
Last edited by PB_Rainer on Tue Oct 15, 2019 10:29 am, edited 1 time in total.
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Re: Dialog does not send the events

Post by PB_Rainer »

Demivec wrote:My guess is that you use the same ID numbers for gadgets in in both Dialogs. Depending on what the gadgets are you would get a working Dialog_2 but not a working Dialog_1.

The way to check for this is if you the constants you use for the gadgets have the same value (even if they have different names). If you use instead use #PB_Any to generate the ID's then this probably isn't the issue.


Good Luck!
Hello and thanks,

but all Windows/Gadgets are initialized with #PB_Any
That can not be the problem normally!?

Regards Rainer
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Dialog does not send the events

Post by spikey »

Does the problem exhibit the same all the way down the chain of window/event handlers? If you open ListWindow before TabWindow - is TabWindow then broken? If you open SteuerstreifenWindow before ListWindow is ListWindow broken? How about TabWindow?

Or is the behaviour different at different points - if so which ones?

What do the TabWindow_Events, ListWindow_Events() etc procedures actually contain? Do they have an independent loop in them?

When the problem exhibits do the popup menus still appear/respond; do the numeric keyboard shortcuts still work?
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Re: Dialog does not send the events

Post by PB_Rainer »

spikey wrote:Does the problem exhibit the same all the way down the chain of window/event handlers? If you open ListWindow before TabWindow - is TabWindow then broken? If you open SteuerstreifenWindow before ListWindow is ListWindow broken? How about TabWindow?

Or is the behaviour different at different points - if so which ones?

What do the TabWindow_Events, ListWindow_Events() etc procedures actually contain? Do they have an independent loop in them?

When the problem exhibits do the popup menus still appear/respond; do the numeric keyboard shortcuts still work?
TabWindow makes no problem. It is the mainwindow which has to be opend first. It contains the toolbar from where all actions start.
After loading BMP and opening SteuerstreifenWindow, StuerstreifenWindow works perfect.
If I Start Listwindow before SteuerstreifenWindow, SteuerstreifenWindow is not working. But it is not disabled not the window not the gadgets. You can scroll the comboboxes, click the buttons bau no reaction!

In the moment I helped myself with a trick. Listwindow can only be opened after calling SteuertsreifenWindow and run the processes in it. That helps but is not the wanted way.

Rainer
User avatar
Kiffi
Addict
Addict
Posts: 1353
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Dialog does not send the events

Post by Kiffi »

@PB_Rainer,

Let's get started simple: You use EnableExplicit?

You only use global variables where they are really needed?
Hygge
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Dialog does not send the events

Post by Joris »

My 50 cents.
I think this setup gives you a much better overview on your code (and easier way to analyse) :

Code: Select all

Repeat
   Event = WaitWindowEvent()   
   Select EventWindow()
      Case TabWindow :    TabWindow_Events(Event)
      Case ListWindow :   ListWindow_Events(Event)
      Case SteuerstreifenWindow : SteuerstreifenWindow_Events(Event)
      Case ProgramSetupWindow :   ProgramSetupWindow_Events(Event)
      Case NewBindingWindow :     NewBindingWindow_Events(Event)
      Case Steuerstreifen_BindingViewer :  Steuerstreifen_BindingViewer_Events(event)
   EndSelect
; First part is for the windows/Dialogs in the program with their own Eventloop

Place all (above) removed event parts together in each nnnWindow_Events(Event) Procedure like so :

Code: Select all

Procedure TabWindow_Events(Event)
 Select Event  
 Case #PB_Event_Menu
 ...
 Case #PB_Event_CloseWindow
 ....
 Case #PB_Event_SizeWindow
 ....
 EndSelect
EndProcedure
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Re: Dialog does not send the events

Post by PB_Rainer »

Joris wrote:My 50 cents.
I think this setup gives you a much better overview on your code (and easier way to analyse) :

Code: Select all

Repeat
   Event = WaitWindowEvent()   
   Select EventWindow()
      Case TabWindow :    TabWindow_Events(Event)
      Case ListWindow :   ListWindow_Events(Event)
      Case SteuerstreifenWindow : SteuerstreifenWindow_Events(Event)
      Case ProgramSetupWindow :   ProgramSetupWindow_Events(Event)
      Case NewBindingWindow :     NewBindingWindow_Events(Event)
      Case Steuerstreifen_BindingViewer :  Steuerstreifen_BindingViewer_Events(event)
   EndSelect
; First part is for the windows/Dialogs in the program with their own Eventloop

Place all (above) removed event parts together in each nnnWindow_Events(Event) Procedure like so :

Code: Select all

Procedure TabWindow_Events(Event)
 Select Event  
 Case #PB_Event_Menu
 ...
 Case #PB_Event_CloseWindow
 ....
 Case #PB_Event_SizeWindow
 ....
 EndSelect
EndProcedure
Ok, I understand what you want to get with this, a better structured eventloop. But each of the Windows still has it's own Eventloop, called first after the Case statement.

Code: Select all

 Case ProgramSetupWindow
         ProgramSetupWindow_Events(Event)
...
Case NewBindingWindow
         NewBindingWindow_Events(Event)
and so on. Should I eliminate the eventloop in each Window and make instaed the Procedures as you wrote?

Would be like this then:

Code: Select all

;******************************************************************************************************************************
; The event procedure created by the form-designer
;******************************************************************************************************************************

Procedure ListWindow_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case Liste_Abbrechen
          Liste_Cancel(EventType())          
        Case Liste_drucken
          Liste_Print(EventType())          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

;******************************************************************************************************************************
; adtional events in the main eventloop
;******************************************************************************************************************************
Case ListWindow
			ListWindow_Events(Event)
			If Event = #PB_Event_CloseWindow 
				CloseWindow(ListWindow) 
				If OriginalImageLoaded = #True And SteuerStreifenImageLoaded = #True
					DisableEnable_ToolBarButtons(0,0,0,1,0,0,1,0)
				ElseIf OriginalImageLoaded = #True And SteuerStreifenImageLoaded = #False
					DisableEnable_ToolBarButtons(0,0,1,0,0,0,1,0)
				EndIf
			EndIf
			
;******************************************************************************************************************************
;******************************************************************************************************************************
;	So I have to write a new event-procedure in the mainprogram and eliminate the event-procedure in the several windows?
; New eventloop procedure in the main eventloop. Contains all events created by the formdesigner and the additional events
;******************************************************************************************************************************			
;******************************************************************************************************************************
			
Procedure ListWindow_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      CloseWindow(ListWindow) 
				If OriginalImageLoaded = #True And SteuerStreifenImageLoaded = #True
					DisableEnable_ToolBarButtons(0,0,0,1,0,0,1,0)
				ElseIf OriginalImageLoaded = #True And SteuerStreifenImageLoaded = #False
					DisableEnable_ToolBarButtons(0,0,1,0,0,0,1,0)
				EndIf
				ProcedureReturn #False ; I think this statement is not necessary anymore? Is it?
				
    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case Liste_Abbrechen
          Liste_Cancel(EventType())          
        Case Liste_drucken
          Liste_Print(EventType())          
      EndSelect
  EndSelect
  ProcedureReturn #True	; I think this statement is not necessary anymore? Is it?
EndProcedure

;******************************************************************************************************************************
regards Rainer
Last edited by PB_Rainer on Tue Oct 15, 2019 8:49 pm, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Dialog does not send the events

Post by mk-soft »

A double call of WaitWindowEvent is not valid (advisable), because otherwise it can come with wrong query to a loss of message. There is only one point where the events can be passed to the program for all windows, menus, gadgets.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
PB_Rainer
User
User
Posts: 80
Joined: Fri Jun 07, 2019 1:56 pm

Re: Dialog does not send the events

Post by PB_Rainer »

mk-soft wrote:A double call of WaitWindowEvent is not valid (advisable), because otherwise it can come with wrong query to a loss of message. There is only one point where the events can be passed to the program for all windows, menus, gadgets.
Yes I understand, but there is only one call of WaitWindowEvent.
Post Reply