Code: Select all
;Controlling windows From external app
;By einander
;feb 9 - 2006
;PB 3.94 beta 2 - Updated for PB 4.6
;RECEIVER APP
#SEP=Chr(215) ; field separator
;
Structure ATOM ; structure containing fields to Control Selected window
String.S ; you can Add/replace with your own fields
TextRGB.L
WinRGB.L
FontName.S
FontSize.L
EndStructure
;
Global List.ATOM
;
Macro StripAtom ; replaces the identifier (atom) with the string and strip the fields to LIST\
Buff$ = Space($400)
GlobalGetAtomName_(WParam,Buff$,Len(Buff$)) ; buff$ is the string with fields
List\String = StringField(Buff$, 1, #SEP)
List\TextRGB=Val(StringField(Buff$,2,#SEP))
List\WinRGB=Val(StringField(Buff$,3,#SEP))
List\FontName=StringField(Buff$,4,#SEP)
List\FontSize=Val(StringField(Buff$,5,#SEP))
EndMacro
;Msg receives the destination Window
;wParam receives the identifier for the string that contains the fields to Control the destination window
Procedure CallBack(HWnd, Msg, WParam, LParam)
Result = #PB_ProcessPureBasicEvents
If Msg=100 Or Msg=200 Or Msg=300 ; destination Window
StripAtom ; now LIST\ have the Control values
LoadFont(0,List\FontName,List\FontSize)
StartDrawing(WindowOutput(Msg))
StickyWindow(Msg, #True)
Box(0,0,WindowWidth(Msg),WindowHeight(Msg),List\WinRGB)
DrawingMode(1)
DrawingFont(FontID(0))
DrawText(10,10,List\String,List\TextRGB)
GlobalDeleteAtom_(WParam)
StopDrawing()
FreeFont(0)
EndIf
ProcedureReturn Result
EndProcedure
;
OpenWindow(100, 80, 100, 300, 100, "Receiver Window 1", #PB_Window_SystemMenu )
OpenWindow(200, 80, 250, 300, 100, "Receiver Window 2", #PB_Window_SystemMenu )
OpenWindow(300, 80, 400, 300, 100, "Receiver Window 3", #PB_Window_SystemMenu )
SetWindowCallback(@CallBack())
Repeat
Ev = WaitWindowEvent()
Until Ev = #PB_Event_CloseWindow