changing resize rules at runtime

Started by Christian Weilguny, June 26, 2010, 03:35:36 PM

Previous topic - Next topic

Christian Weilguny

Hi,

is there a possibility to change the resize rules at runtime, respectively add a control at runtime and set the resize rules?

Christian

Paul Squires

It can be done. You can add controls to any Form yourself by using CreateWindowEx api. If you want to add ResizeRules to a manually created control then you should also add a call to FLY_SetControlData.


'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long
 
   Local hWndControl As Dword
   Local nResult     As Dword
   
   ' Dynamically add a new control to the Form. You need to track the control's
   ' new window handle and ID. Maybe you should do this using global variables.
   ' Calling FLY_SetControlData will set certain special properties that FF3
   ' uses to interact with the control.
 
    hWndControl = CreateWindowEx( %WS_EX_LEFT Or %WS_EX_LTRREADING, _
                                  "Button", _    ' class
                                  "Command2", _
                                  %WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_TEXT _
                                  Or %BS_PUSHBUTTON Or %BS_NOTIFY Or %BS_CENTER Or %BS_VCENTER, _
                                  10, 10, _                        ' left/top
                                  81, 33, _                        ' width/height
                                  hWndForm, 101, _                 'parent/ID
                                  App.hInstance, ByVal %Null )
   
    nResult = FLY_SetControlData( hWndControl, _                          ' Handle of the control
                                   %FALSE, _                              ' Subclass the control?
                                   %TRUE, _                               ' Allow setting of the font
                                   "Tahoma,-11,0,0,0,400,0,0,0,0,3,2,1,34", _   ' font
                                   0, _                                   ' ControlIndex
                                   %FALSE, _                              ' Allow processing of color
                                   %FALSE, _                              ' Is the specified foreground color a system color?
                                   %FALSE, _                              ' Is the specified background color a system color?
                                   0, _                                   ' Foreground color
                                   0, _                                   ' Background color
                                   -1, _                                  ' Transparent brush
                                   CodePtr(FORM1_CODEPROCEDURE), _        ' code procedure
                                   "FL,FT,FR,FB" )                        ' Resize rules

End Function

Paul Squires
PlanetSquires Software

Christian Weilguny

Thank's Paul,

this is great!

I need it for generating Buttons on the fly to activate opend windows. So the buttons will be created and deleted how the windows are opened and closed. Like a taskbar within an application.
So they should be all visible even if the mainwindow is resized. Therefor I need the resize rules.

Thank's once more,

Christian