Page 1 of 1
API gadgets, panels and some hidden window?
Posted: Thu Sep 09, 2004 5:03 pm
by Karbon
I understand that PB uses a hidden window to support XP skins for panel gadgets (or something like that).
I need to add an API date picker gadget on a panel and can't because of this hidden window thing. Can anyone tell me how to find the ID of this hidden window that comes with panel gadgets?
Posted: Thu Sep 09, 2004 5:39 pm
by GreenGiant
Well I'm not sure, but I may have found a way to do it. Here's my code:
Code: Select all
Procedure EnumProc(hWnd,lParam)
Debug "Child Window: "+Str(hWnd)
EndProcedure
OpenWindow(0,0,0,400,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered,"test")
CreateGadgetList(WindowID(0))
PanelGadget(0,10,10,380,380)
EnumChildWindows_(WindowID(0),@EnumProc(),0)
Debug "Parent of Panel: "+Str(GetParent_(GadgetID(0)))
Debug "Main Window: "+Str(WindowID(0))
Debug "Gadget: "+Str(GadgetID(0))
Repeat
ev=WaitWindowEvent()
Until ev=#PB_Event_CloseWindow
If the child window I'm finding is the one you're talking about then the line
is succesfully getting the ID of it.
Posted: Thu Sep 09, 2004 6:42 pm
by Kale
This is how i do it:
Code: Select all
;===========================================================================
;-CONSTANTS
;===========================================================================
#APP_NAME = "Window Template"
Enumeration
#WINDOW_ROOT
#PANEL_CALENDAR
#FRAME_CALENDAR
#FRAME_CALENDAR2
EndEnumeration
;===========================================================================
;-PROCEDURES
;===========================================================================
;Handle an error
Procedure HandleError(Result, Text.s)
If Result = 0 : MessageRequester("Error", Text, #PB_MessageRequester_Ok) : End : EndIf
EndProcedure
;===========================================================================
;-GEOMETRY
;===========================================================================
HandleError(OpenWindow(#WINDOW_ROOT, 0, 0, 400, 300, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, #APP_NAME), "Main window could not be created.")
HandleError(CreateGadgetList(WindowID(#WINDOW_ROOT)), "Gadget list for the main window could not be created.")
PanelGadget(#PANEL_CALENDAR, 10, 10, 380, 280)
AddGadgetItem (#PANEL_CALENDAR, -1, "Calendar Example Page 1")
hCalendarFrame = Frame3DGadget(#FRAME_CALENDAR, 10, 10, 190, 155, "")
hCalendarGadget.l = CreateWindowEx_(0, "SysMonthCal32", #NULL, #WS_CHILD | #WS_VISIBLE | #WS_BORDER, 0, 0, 190, 155, hCalendarFrame, 0, GetModuleHandle_(#NULL), 0)
AddGadgetItem (#PANEL_CALENDAR, -1, "Calendar Example Page 2")
hCalendarFrame2 = Frame3DGadget(#FRAME_CALENDAR2, 40, 40, 190, 155, "")
hCalendarGadget.l = CreateWindowEx_(0, "SysMonthCal32", #NULL, #WS_CHILD | #WS_VISIBLE | #WS_BORDER, 0, 0, 190, 155, hCalendarFrame2, 0, GetModuleHandle_(#NULL), 0)
CloseGadgetList()
;===========================================================================
;-MAIN LOOP
;===========================================================================
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
End
Posted: Thu Sep 09, 2004 6:56 pm
by Karbon
interesting... Just got an "OK" from Fred about native date gadgets in PB so hopefully we won't have to hack like this for long!