<< Click to Display Table of Contents >> Navigation: ThinBASIC Modules > UI (User Interface) > CONTROLS > Control Commands > CONTROL SET RESIZE |
Description
Set automatic resize functionality to window control locking one or more sides.
Syntax
CONTROL SET RESIZE hWnd, CtrlID, LockLeft, LockRight, LockTop, LockBottom
Returns
None
Parameters
Name |
Type |
Optional |
Meaning |
hWnd |
Number |
No |
Handle of the dialog containing the control |
CtrlID |
Number |
No |
Control identifier assigned to the control during CONTROL ADD ... |
LockLeft |
Number |
No |
Any non zero value will lock this side when window sizing will occur |
LockRight |
Number |
No |
Any non zero value will lock this side when window sizing will occur |
LockTop |
Number |
No |
Any non zero value will lock this side when window sizing will occur |
LockBottom |
Number |
No |
Any non zero value will lock this side when window sizing will occur |
Remarks
Important: control must be correctly placed and sized on window before calling this functionality. Resizing will be proportional with initial size found when this functionality will take place.
Restrictions
See also
Examples
USES "UI"
Dim Msg As Long '---Returned messages
Dim wParam As Long '---wParam in message pump
Dim lParam As Long '---lParam in message pump
Dim hDlg As Long '---Dialog handle
Dim sInput As String '---Used to get input from field
Dim sBuffer As String '---Used to set output buffer
Dim wx As Long '---Used to get client width
Dim hy As Long '---Used to get client height
Dim Counter As Long '---Counter to count output lines
'---Control IDs
%ID_TXTBUFFER = 10 '---Output field
%ID_LBLENTER = 20 '---Input field label
%ID_TXTENTER = 30 '---Input field
'---Set starting width and height of the window
wx = 200
hy = 250
'---Create main dialog
DIALOG New 0, "Sample using Enter key from input field", -1, -1, wx, hy, _
%WS_DLGFRAME Or _
%DS_CENTER Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_OVERLAPPEDWINDOW , _
0 To hDlg
'---Show dialog
DIALOG SHOW MODELESS hDlg
'---Now start window message pump loop
While ISWINDOW(hDlg)
'---Get the message and fill wParam and lParam
Msg = GETMESSAGE(hDlg, wParam, lParam)
'---Test the returned message
Select Case Msg
'---Message fired at the very beginning when dialog is initialized
'---We use it to add necessary controls
Case %WM_INITDIALOG
CONTROL ADD TEXTBOX , hDlg, %ID_TXTBUFFER, "" , 2, 2, wx - 5, hy - 50, _
%WS_TABSTOP Or _
%ES_WANTRETURN Or _
%ES_MULTILINE Or _
%ES_AUTOHSCROLL Or _
%ES_AUTOVSCROLL Or _
%WS_VSCROLL Or _
%WS_HSCROLL
CONTROL ADD LABEL , hDlg, %ID_LBLENTER, "Type some text and press <ENTER> key", 2, hy - 40, wx - 5, 12
CONTROL ADD TEXTBOX , hDlg, %ID_TXTENTER, "" , 2, hy - 20, wx - 5, 12, %WS_TABSTOP
'---Configure the controls to automatically resize as needed
CONTROL Set RESIZE hDlg, %ID_TXTBUFFER, 1, 1, 1, 1 '---This control must resize every side
CONTROL Set RESIZE hDlg, %ID_LBLENTER , 1, 1, 0, 1 '---This control must have top size movable
CONTROL Set RESIZE hDlg, %ID_TXTENTER , 1, 1, 0, 1 '---This control must have top size movable
'---In case of keyboard pressed ...
Case %wm_keydown
'---Check which key using wParam
Select Case wParam
'---In case of <ENTER> key ...
Case 13
DoTheJob(%ID_TXTENTER, %ID_TXTBUFFER, "")
End Select
Case %WM_SYSCOMMAND
Select Case wParam
Case %SC_Close
Exit While
End Select
'---Here we go in any other case
'---This is used like an idle time, when Msg = 0
Case 0
'---%WM_IDLE is in reality equal to zero
'---It is like testing a CASE ELSE and in general can be used
'---when you need to do something in idle time
'---So, if idle, set back the focus to data entry field
CONTROL Set FOCUS hDlg, %ID_TXTENTER
End Select
Wend
'---Close the dialog
DIALOG End hDlg
Function DoTheJob(ByVal ID_In As Long, ByVal ID_Out As Long, AdditionalText As String) As Long
CONTROL Get Text hDlg, ID_In To sInput
If trim$(sInput) = "" Then
sInput = "<<<- Please type some text ->>>"
End If
Counter += 1
sInput = AdditionalText & format$(Counter, "000000") & " " & sInput
CONTROL Get Text hDlg, ID_Out To sBuffer
CONTROL Set Text hDlg, ID_Out, sInput & $CRLF & sBuffer
CONTROL Set Text hDlg, ID_In, ""
End Function