Hello again Faildeath; I'm so glad that it helps. Another issue to take note of is the number of gadgets the background window has, and their Z-Order. If it has more than one gadget, the example I had posted earlier would simply send the specified text to the first gadget of that window. To handle this, you should use the GetWindow() function with the #GW_HWNDNEXT flag to enumerate the gadgets, and you must also know the gadget-order for that window. This example illustrates that:
Code: Select all
EnableExplicit
Enumeration
#MainWindow
#BackgroundWindow
#Gadget_1
#Gadget_2
#Gadget_3
#Gadget_4
#Button_1
#Button_2
#Button_3
#Button_4
EndEnumeration
Define appQuit, wFlags = 13107201, hWnd, cWnd_1, cWnd_2, cWnd_3, cWnd_4
OpenWindow(#BackgroundWindow, 0, 0, 400, 190, "The Background Window", wFlags)
ButtonGadget(#Gadget_1, 10, 30, 100, 40, "Button")
OptionGadget(#Gadget_2, 290, 30, 100, 40, "Option")
StringGadget(#Gadget_3, 10, 100, 100, 80, "String")
EditorGadget(#Gadget_4, 290, 100, 100, 80, #PB_Text_Right)
SetGadgetText(#Gadget_4, "Editor")
OpenWindow(#MainWindow, 0, 0, 160, 220, "Front Window", wFlags)
ButtonGadget(#Button_1, 10, 35, 60, 60, "Send to 1st Child", #PB_Button_MultiLine)
ButtonGadget(#Button_2, 90, 35, 60, 60, "Send to 2nd Child", #PB_Button_MultiLine)
ButtonGadget(#Button_3, 10, 125, 60, 60, "Send to 3rd Child", #PB_Button_MultiLine)
ButtonGadget(#Button_4, 90, 125, 60, 60, "Send to 4th Child", #PB_Button_MultiLine)
hWnd = FindWindow_(0, "The Background Window")
cWnd_1 = GetWindow_(hWnd, #GW_CHILD)
cWnd_2 = GetWindow_(cWnd_1, #GW_HWNDNEXT)
cWnd_3 = GetWindow_(cWnd_2, #GW_HWNDNEXT)
cWnd_4 = GetWindow_(cWnd_3, #GW_HWNDNEXT)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Button_1
SendMessage_(cWnd_1, #WM_SETTEXT, 0, "First gadget...")
Case #Button_2
SendMessage_(cWnd_2, #WM_SETTEXT, 0, "Second gadget...")
Case #Button_3
SendMessage_(cWnd_3, #WM_SETTEXT, 0, "Third gadget...")
Case #Button_4
SendMessage_(cWnd_4, #WM_SETTEXT, 0, "Fourth gadget...")
EndSelect
EndSelect
Until appQuit = 1