OOP/COM Programming with PB -- Taskbar
Posted: Thu May 02, 2002 4:36 am
Code updated for 5.20+
Restored from previous forum. Originally posted by Danilo.
Good Morning !!
Some people asked about using the CallCOM() command
for Object Oriented Programming (OOP).
Now here is a little (easy to understand) example
that hides the Application from the Windows taskbar.
Its only for demonstrating how OOP
works with PureBasic.
Its easy...
cya,
...Danilo
(registered PureBasic user)
Restored from previous forum. Originally posted by Danilo.
Good Morning !!
Some people asked about using the CallCOM() command
for Object Oriented Programming (OOP).
Now here is a little (easy to understand) example
that hides the Application from the Windows taskbar.
Its only for demonstrating how OOP
works with PureBasic.
Code: Select all
;EXAMPLE UPDATE NOTE: As the CallCOM() function library cannot
;be located, and the topic is not specific to CallCOM(), the
;example has been adapted to utilise PureBasic's built-in
;ITaskbarList interface, which provides the same functionality.
OpenWindow(0, 100, 100, 400, 200, "Window in Taskbar",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 260, 20, 120, 30, "hide from taskbar")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
If Not coInit
tb.ITaskbarList
CoInitialize_(0)
If CoCreateInstance_(?CLSID_TaskbarList, 0, 1,
?IID_ITaskbarList, @tb)
MessageRequester("Object Creation Error:",
"Unable to initialise COM.")
Else
tb\HrInit()
coInit = 1
EndIf
EndIf
If coInit
If show
tb\AddTab(WindowID(0))
SetGadgetText(0, "hide from taskbar")
show = 0
Else
tb\DeleteTab(WindowID(0))
SetGadgetText(0, "show in taskbar")
show = 1
EndIf
EndIf
EndSelect
EndSelect
Until appQuit = 1
If coInit
tb\Release()
EndIf
CoUninitialize_()
End
DataSection
CLSID_TaskbarList:
Data.i $56FDF344
Data.w $FD6D, $11D0
Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
IID_ITaskbarList:
Data.i $56fdf342
Data.w $FD6D, $11D0
Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
EndDataSection
cya,
...Danilo
(registered PureBasic user)