What am I doing wrong? (Gadgets over graphic in a window)
Posted: Mon Sep 17, 2007 4:22 pm
I've made a dialogue box. A graphically more glitzy version of an inputbox.
The graphic shows, and then the caption can be successfully drawn over it, but as soon as a gadget is added (whether it's the stringgadget or a button), the whole window turns grey!
I've split it up with delays so you can see it "in action":
"mmb" is the handle of the parent app (NOT written in PB)
Thanks for any help. I'm sure it must be something glaringly obvious.
The graphic shows, and then the caption can be successfully drawn over it, but as soon as a gadget is added (whether it's the stringgadget or a button), the whole window turns grey!
I've split it up with delays so you can see it "in action":
"mmb" is the handle of the parent app (NOT written in PB)
Code: Select all
caption$="Please type in some text:"
defaulttext$="HERE"
title$="Malfunctioning inputbox"
font=LoadFont(#PB_Any,"Courier New",12,#PB_Font_Bold)
SetGadgetFont(#PB_Default,FontID(font))
winBox=OpenWindow(#PB_Any,0,0,500,125,"",#PB_Window_ScreenCentered|#PB_Window_BorderLess);,mmb)
EnableWindow_(mmb,#False)
dialogue=WindowID(winBox)
BGImage=ImageID(LoadImage(#PB_Any,"inputbox.bmp"))
StartDrawing(WindowOutput(winBox))
DrawImage(BGImage,0,0,500,125)
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(font))
DrawText(5,2,title$,RGB(255,255,255))
DrawText(5,28,caption$,RGB(255,255,255))
StopDrawing()
Delay(2000)
MessageBeep_(#MB_ICONINFORMATION)
CreateGadgetList(dialogue)
string = StringGadget(#PB_Any,17,54,366,15,defaulttext$,#PB_String_BorderLess)
okay=ImageID(LoadImage(#PB_Any,"ok button.bmp"))
OK = ButtonImageGadget(#PB_Any,220,82,78,24,okay)
cancel=ImageID(LoadImage(#PB_Any,"cancel button.bmp"))
Cancel = ButtonImageGadget(#PB_Any,309,82,78,24,cancel)
Delay(2000)
GetAsyncKeyState_(#VK_RETURN) : GetAsyncKeyState_(#VK_ESCAPE) : StickyWindow(winBox,#True) : SetForegroundWindow_(dialogue)
MessageBeep_(#MB_ICONWARNING)
Repeat
ev=WaitWindowEvent(1) : id=EventGadget() : ret=GetAsyncKeyState_(#VK_RETURN) : esc=GetAsyncKeyState_(#VK_ESCAPE)
a=GetForegroundWindow_()
press = WaitWindowEvent()
If press = #PB_Event_Gadget
Select EventGadget()
Case OK
status=1
Case Cancel
status=0
EndSelect
EndIf
Until press=#PB_Event_CloseWindow Or EventGadget()=OK Or EventGadget()=Cancel
ProcedureReturn=GetGadgetText(string)
CloseWindow(winBox)
EnableWindow_(mmb,#True)