Why not embed the external app window in a static gadget ?dell_jockey wrote:what I'm after is to write an app that has some buttons and other controls, and that also has a rectangle on its gui that is completely transparent - the idea being to have an already existing app running 'behind' it on the exact screen location of the transparent rectangle that my app would sport.
Below a quick and dirty code to embed the windows calculator.
Code: Select all
Enumeration
#Window_0
EndEnumeration
Enumeration
#Container_0
#Button_1
#Button_2
#Button_3
#Button_4
EndEnumeration
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 486, 213, 400, 400, "Embedded Windows Calculator", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
ButtonGadget(#Button_1, 44, 365, 100, 28, "1")
ButtonGadget(#Button_2, 268, 365, 93, 28, "2")
ButtonGadget(#Button_3, 12, 185, 20, 64, "3")
ButtonGadget(#Button_4, 374, 191, 19, 62, "4")
ImageGadget(#Container_0, 74, 60, 246, 226, #Null)
HideGadget(#Container_0, #True)
CloseGadgetList()
EndIf
EndProcedure
OpenWindow_Window_0()
MyCalc = RunProgram("calc.exe","","",#PB_Program_Hide | #PB_Program_Open)
If MyCalc
While hMyCalc = #Null
hMyCalc = FindWindow_(@"SciCalc", 0)
Wend
EndIf
GetWindowRect_(hMyCalc, @RectMyCalc.RECT)
SetParent_(hMyCalc, GadgetID(#Container_0))
ShowWindow_(hMyCalc, #SW_SHOWMAXIMIZED)
; hide external window caption and borders
MoveWindow_(hMyCalc, - GetSystemMetrics_(#SM_CYFRAME), - GetSystemMetrics_(#SM_CYCAPTION) - GetSystemMetrics_(#SM_CYFRAME), RectMyCalc\bottom - RectMyCalc\top, RectMyCalc\right - RectMyCalc\left, #True)
; one could also resize the container according to the external window dimensions
HideGadget(#Container_0, #False)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
If MyCalc
KillProgram(MyCalc)
CloseProgram(MyCalc)
EndIf
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
