The below code takes care of a form with multiple gadgets. It uses code I've found here to resize with a callback by getting the resize of the gadgets to work with the size of the original form. As you can see, some of the gadgets only need to resize and not move, others need to resize and move.
The problem is using this method isn't correct for all gadgets. Some move out of their frames. Others don't maintain the original distance between the paralell gadget. I need the distance between a frame and it's child object to be the same. I also need the distance between 2 frames to remain the same.
I.e. If an object and it's frame start at the left of a window, that object must not move away from the left border but it can grow to the right and down but must maintain the distance inside the frame of the original dimensions. If another object and frame are next to it, this object can both move and grow.
Button objects can move but never grow.
Code: Select all
;-Init Constants
#TV_FIRST = $1100
#TVM_SETBKCOLOR = #TV_FIRST+29
#TVM_SETTEXTCOLOR = #TV_FIRST+30
#WindowIndex = 0
#GadgetIndex = 0
#ImageIndex = 0
#StatusBarIndex = 0
#MenuBarIndex = 0
;-Window Constants
#Window_FangChat = #WindowIndex:#WindowIndex=#WindowIndex+1
;Window_FangChat
#MenuBar_FangChat = #MenuBarIndex:#MenuBarIndex=#MenuBarIndex+1
#MenuBar_FangChat_ViewLog = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#MenuBar_FangChat_ConnectLast = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#MenuBar_FangChat_EditConnections = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#MenuBar_FangChat_ChangeColour = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#MenuBar_FangChat_DateStamp = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#MenuBar_FangChat_HelpMe = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#MenuBar_FangChat_AboutMe = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_ChatFrame = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_ChatBox = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_TextEntryFrame = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_TextEntry = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_UserFrame = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_UserList = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_ControlFrame = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_SendText = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_SaveText = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#Gadget_FangChat_Disconnect = #GadgetIndex:#GadgetIndex=#GadgetIndex+1
#StatusBar_FangChat = #StatusBarIndex:#StatusBarIndex=#StatusBarIndex+1
#StatusBar_FangChat_Messages = 0
#StatusBar_FangChat_Port = 1
#StatusBar_FangChat_Online = 2
#StatusBar_FangChat_Disconnect = 3
Declare.l Window_FangChat()
Declare MyWindowCallback(WindowID, Message, wParam, lParam)
Declare BubbleTip(bWindow.l,bGadget.l,bText.s)
Global hWnd, OriginalWidth, OriginalHeight
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select message
Case #WM_SIZE ; Form's size has changed.
RatioW.f = WindowWidth() / OriginalWidth ; Get horizontal difference.
RatioH.f = WindowHeight() / OriginalHeight ; Get vertical difference.
ResizeGadget(#Gadget_FangChat_ChatFrame, 5 , 0 , 305 * RatioW, 225 * RatioH)
ResizeGadget(#Gadget_FangChat_ChatBox, 10 , 10 , 295 * RatioW, 210 * RatioH)
ResizeGadget(#Gadget_FangChat_TextEntryFrame, 5 , 225 * RatioH, 305 * RatioW, 35 )
ResizeGadget(#Gadget_FangChat_TextEntry, 10 , 235 * RatioH, 295 * RatioW, 20 )
ResizeGadget(#Gadget_FangChat_UserFrame, 315 * RatioW, 0 * RatioH, 180 * RatioW, 225 * RatioH)
ResizeGadget(#Gadget_FangChat_UserList, 320 * RatioW, 10 * RatioH, 170 * RatioW, 210 * RatioH)
ResizeGadget(#Gadget_FangChat_ControlFrame, 315 * RatioW, 225 * RatioH, 180 * RatioW, 35 )
ResizeGadget(#Gadget_FangChat_SendText, 320 * RatioW, 235 * RatioH, 50 , 20 )
ResizeGadget(#Gadget_FangChat_SaveText, 370 * RatioW, 235 * RatioH, 50 , 20 )
ResizeGadget(#Gadget_FangChat_Disconnect, 420 * RatioW, 235 * RatioH, 70 , 20 )
UpdateStatusBar(#StatusBar_FangChat)
EndSelect
ProcedureReturn Result
EndProcedure
Procedure.l Window_FangChat()
If OpenWindow(#Window_FangChat,26,12,500,307,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible,"FangChat")
OriginalWidth = WindowWidth() ; Original non-client width.
OriginalHeight = WindowHeight() ; Original non-client height.
CreateMenu(#MenuBar_FangChat,WindowID(#Window_FangChat))
MenuTitle("File")
MenuItem(#MenuBar_FangChat_ViewLog,"View Log File")
MenuTitle("Connections")
MenuItem(#MenuBar_FangChat_ConnectLast,"Connect To Last")
MenuItem(#MenuBar_FangChat_EditConnections,"Edit Connections")
MenuTitle("Setup")
MenuItem(#MenuBar_FangChat_ChangeColour,"Change Form Colour")
MenuItem(#MenuBar_FangChat_DateStamp,"Date/Time Stamp")
MenuTitle("Help")
MenuItem(#MenuBar_FangChat_HelpMe,"Help")
MenuItem(#MenuBar_FangChat_AboutMe,"About")
If CreateGadgetList(WindowID())
Frame3DGadget(#Gadget_FangChat_ChatFrame,5,0,305,225,"")
StringGadget(#Gadget_FangChat_ChatBox,10,10,295,210,"")
Frame3DGadget(#Gadget_FangChat_TextEntryFrame,5,225,305,35,"")
StringGadget(#Gadget_FangChat_TextEntry,10,235,295,20,"")
Frame3DGadget(#Gadget_FangChat_UserFrame,315,0,180,225,"")
ListIconGadget(#Gadget_FangChat_UserList,320,10,170,210,"ListIcon14",166)
ChangeListIconGadgetDisplay(#Gadget_FangChat_UserList, 0)
Frame3DGadget(#Gadget_FangChat_ControlFrame,315,225,180,35,"")
ButtonGadget(#Gadget_FangChat_SendText,320,235,50,20,"Send")
ButtonGadget(#Gadget_FangChat_SaveText,370,235,50,20,"Save")
ButtonGadget(#Gadget_FangChat_Disconnect,420,235,70,20,"Disconnect")
CreateStatusBar(#StatusBar_FangChat,WindowID(#Window_FangChat))
AddStatusBarField(252)
AddStatusBarField(50)
AddStatusBarField(100)
AddStatusBarField(100)
HideWindow(#Window_FangChat,0)
ProcedureReturn WindowID()
EndIf
EndIf
EndProcedure
Procedure BubbleTip(bWindow.l,bGadget.l,bText.s)
ToolTipControl=CreateWindowEx_(0,"ToolTips_Class32","",$D0000000|$40,0,0,0,0,WindowID(bWindow),0,GetModuleHandle_(0),0)
SendMessage_(ToolTipControl,1044,0,0)
SendMessage_(ToolTipControl,1043,$DFFFFF,0)
SendMessage_(ToolTipControl,1048,0,180)
Button.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Button\uFlags=$11
Button\hWnd=GadgetID(bGadget)
Button\uId=GadgetID(bGadget)
Button\lpszText=@bText
SendMessage_(ToolTipControl,$0404,0,Button)
EndProcedure
If Window_FangChat()
SetWindowCallback(@MyWindowCallback())
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow And EventWindowID() = #Window_FangChat
CloseWindow(#Window_FangChat)
EndIf
End
;
