I use the callback below to resize a form and its' gadgets as well as colour some objects on that one window and I don't want to resize or colour any other sub window. It's okay as long as no other windows are opened (originally designed only for that one window) but when you open any of the other sub windows, either they are the wrong size or the main window gets resized incorrectly.
How do I prevent the callback from working on any other window except the one I want? Something to do with #WM_GETMINMAXINFO I think.
Code: Select all
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents 
  Select message
    Case #WM_CTLCOLOREDIT
      SetTextColor_(wParam, #Foreground_Edit)
      SetBkMode_(wParam, #TRANSPARENT)
      Result = ColorBrush_Edit
    Case #WM_GETMINMAXINFO      ; Restrict the minimum size to 500x(307 + MenuHeight()), borders included
      Result = 0
      *ptr.MINMAXINFO       = lParam
      *ptr\ptMinTrackSize\x = 500
      *ptr\ptMinTrackSize\y = 306 + MenuHeight()
    Case #WM_SIZE ; Form's size has changed.
      winwidth.l  = WindowWidth()
      winheight.l = WindowHeight()
      RatioW.f   = winwidth  / OriginalWidth   ; Get horizontal difference.
      RatioH.f   = winheight / OriginalHeight  ; Get vertical difference.
      width.l    = 295 * RatioW
      height.l   = winheight - 82
      ResizeGadget(#Gadget_chatbox_chatframe,       5,          0,           width + 3,             height + 3)
      ResizeRichEdit(#Gadget_chatbox_chatbox,       5,         10,           width - 7,             height - 14)
      
      ResizeGadget(#Gadget_chatbox_entryframe,     -1,         height,       width + 3,             35)
      ResizeGadget(#Gadget_chatbox_entrybox,       10,         height + 10,  width - 7,             20)
      
      ResizeGadget(#Gadget_chatbox_userframe,      width + 11, -1,           winwidth - width - 17, height + 3)
      ResizeGadget(#Gadget_chatbox_userbox,        width + 16, -1,           winwidth - width - 27, height - 12)
      
      ResizeGadget(#Gadget_chatbox_buttonframe,    width + 11, height,       winwidth - width - 17, 35)
      xpos.l = width + 25
      RatioW = (winwidth - width - 35) / 170
      ResizeGadget(#Gadget_chatbox_sendtext,       xpos - 10,  height + 10,  50 * RatioW + 3,       20)
      xpos + (50 * RatioW)
      ResizeGadget(#Gadget_chatbox_savelog,        xpos -  7,  height + 10,  50 * RatioW + 3,       20)
      xpos + (50 * RatioW)
      ResizeGadget(#Gadget_chatbox_disconnect,     xpos -  4,  height + 10,  70 * RatioW + 4,       20)
      UpdateStatusBar(#StatusBar_chatbox)
      RedrawWindow_(WindowID(), 0, 0, #RDW_INVALIDATE)
  EndSelect
  
  ProcedureReturn Result
EndProcedure 
