StringGadget in Modal Dialog & Event Loop
Posted: Fri Nov 18, 2005 1:04 pm
Environment is JaPBe, 3.94, WinXP
I am not sure what is going on here.
If I place a string gadget into a modal dialogue box and initiate the box inside a WaitWindowEvent loop, the box closes immediately.
However if the StringGadget is commented out, the box acts as it should.
Also a StringGadget can appear in the dialogue box if the box is initiated outside the loop, say right after the parent window is opened.
I cannot find a solution.
Any help available?
PS: I have stripped this down heaps, still a bit large. Apologies.
Thanks!
Edited to allow long lines to wrap (so you don't have to sideways scroll - don't you hate that!?)
I am not sure what is going on here.
If I place a string gadget into a modal dialogue box and initiate the box inside a WaitWindowEvent loop, the box closes immediately.
However if the StringGadget is commented out, the box acts as it should.
Also a StringGadget can appear in the dialogue box if the box is initiated outside the loop, say right after the parent window is opened.
I cannot find a solution.
Any help available?
PS: I have stripped this down heaps, still a bit large. Apologies.
Code: Select all
Enumeration ;windows
#_win
EndEnumeration
Enumeration ; gadgets
#_gTabs
#_gLiImages
#_gdTxtPrompt
#_gdStrPrompt
#_gdTxtSource
#_gdBtnSource
#_gdStrSource
#_gdBtnOK
#_gdBtnCancel
EndEnumeration
Enumeration ; Panel tab numbering
#_tabGeneral
#_tabImages
#_tabSpeak1
#_tabSpeak2
#_tabSpeak3
#_tabSpeak4
#_tabSpeak5
#_tabHelp
EndEnumeration
UsePNGImageDecoder()
UseJPEGImageDecoder()
Structure DLG_TEMPLATE
style.l
dwExtendedStyle.l
cdit.w
x.w
y.w
cx.w
cy.w
menu.w
class.w
title.l
EndStructure
Global dlg.DLG_TEMPLATE
dlg\style=#WS_POPUP | #WS_BORDER | #WS_SYSMENU | #DS_MODALFRAME | #WS_CAPTION | #DS_CENTER
dlg\cx=200
dlg\cy=100
Procedure imgDlg(hW, uMsg, wParam, lParam)
Select uMsg
Case #WM_INITDIALOG
CreateGadgetList(hW)
; ****************************************
; UNCOMMENT STRING GADGET TO GET DROP-OUT
; ***************************************
; StringGadget(#_gdStrPrompt,202,20,100,20,"")
ButtonGadget(#_gdBtnOK,150,175,60,22,"OK")
SetWindowText_(hW,"Image Selector")
Case #WM_COMMAND
Debug Str(wParam & $FFFF)
EndDialog_(hW,wParam & $FFFF)
EndSelect
ProcedureReturn 0
EndProcedure
Procedure hideImgOpts(tf)
HideGadget(#_gLiImages,tf)
DisableGadget(#_gLiImages,tf)
EndProcedure
hWnd=OpenWindow(#_win, 20,20, 400,400, #PB_Window_Invisible | #PB_Window_MinimizeGadget | #PB_Window_SystemMenu,"ABC123: NEW SET WIZARD")
If hWnd
CreateGadgetList(WindowID(#_win))
PanelGadget(#_gTabs,0,0,400,22)
AddGadgetItem(#_gTabs,-1,"General")
AddGadgetItem(#_gTabs,-1,"Images")
AddGadgetItem(#_gTabs,-1,"Voice1")
AddGadgetItem(#_gTabs,-1,"Voice2")
AddGadgetItem(#_gTabs,-1,"Voice3")
AddGadgetItem(#_gTabs,-1,"Voice4")
AddGadgetItem(#_gTabs,-1,"Voice5")
AddGadgetItem(#_gTabs,-1,"Help")
CloseGadgetList()
ListIconGadget(#_gLiImages, 2,22, 396,377, "Item", 35, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#_gLiImages,1,"Prompt",100)
AddGadgetColumn(#_gLiImages,2,"Image Path",238)
For i=1 To 50
AddGadgetItem(#_gLiImages,-1,Str(i)+Chr(10)+"")
Next
hideImgOpts(#True)
HideWindow(#_win,#False)
AdvancedGadgetEvents(#True)
Repeat
event=WaitWindowEvent()
eventType=EventType()
eventGad=EventGadgetID()
Select event
Case #PB_Event_CloseWindow
Quit=1
Case #PB_Event_Gadget
Select eventGad
Case #_gTabs
If GetGadgetState(#_gTabs)=#_tabGeneral
hideImgOpts(#True)
ElseIf GetGadgetState(#_gTabs)=#_tabImages
hideImgOpts(#False)
ElseIf GetGadgetState(#_gTabs)=#_tabSpeak1
hideImgOpts(#True)
ElseIf GetGadgetState(#_gTabs)=#_tabSpeak2
hideImgOpts(#True)
ElseIf GetGadgetState(#_gTabs)=#_tabSpeak3
hideImgOpts(#True)
ElseIf GetGadgetState(#_gTabs)=#_tabSpeak4
hideImgOpts(#True)
ElseIf GetGadgetState(#_gTabs)=#_tabSpeak5
hideImgOpts(#True)
ElseIf GetGadgetState(#_gTabs)=#_tabHelp
hideImgOpts(#True)
EndIf
Case #_gLiImages
If eventType=#PB_EventType_RightClick
dlg\cx=200
dlg\cy=100
DialogBoxIndirectParam_(hWnd,dlg,hWnd,@imgDlg(),0)
EndIf
EndSelect
EndSelect
Until Quit=1
EndIf
Edited to allow long lines to wrap (so you don't have to sideways scroll - don't you hate that!?)