christianssen
19-04-2010, 10:45
good morning. I need help, sorry. :?
perhaps somebody has time to update this ui code for current and modern callbacks and text input with %VK_Return messages. Found this example at this board. made some tests. but if I close my seconde dialog the first dialog with textbuffer and enter key disappear too.
it's antique to use this dialog form for first main dialog isn't it ? I am confused. be gentle, it's only a test example, not perfect.
my test example:
' Empty GUI script created on 04-19-2010 08:34:14 by denis (ThinAIR)
Uses "UI"
Dim Msg As Long
Dim wParam As Long
Dim lParam As Long
Dim hDlg As Long
Dim sInput As String
Dim myNewString As String
Dim sBuffer As String
Dim wx As Long
Dim hy As Long
Dim Counter As Long
'---Control IDs
%ID_TXTBUFFER = 10
%ID_LBLENTER = 20
%ID_TXTENTER = 30
%ID_TXTMY = 40
%ID_TXTENTER2 = 50
%ID_Button = 60
%ButtonClose = 1001
%ButtonDialog = 1002
%ID_TXTBOX = 1003
%ButtonClose2 = 1004
'---Set starting width and height of the window
wx = 240
hy = 300
Function TBMain() As Long
'---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)
If GetWindowKeyState (hdlg, %VK_RETURN) <> 0 Then
DoTheJob(%ID_TXTENTER, %ID_TXTBUFFER, "")
Sleep 150
End If
'---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, "textbuffer" , 2, 2, wx - 5, hy - 70, _
%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 in textbox below and press <ENTER> key", 2, hy - 46, wx - 5, 12
Control Add Textbox , hDlg, %ID_TXTENTER, "here to type in words!" , 2, hy - 20, wx - 5, 12, %WS_TABSTOP
Control Add Textbox , hDlg, %ID_TXTENTER2, "", 2, hy - 60, wx - 5, 12, %WS_TABSTOP
Control Add Button , hDlg, %ID_Button, "< more >", 2, hy - 34, wx - 5, 12, Call newDialog
'---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
Case %WM_SYSCOMMAND
Select Case wParam
Case %SC_CLOSE
Exit While
End Select
End Select
Wend
Dialog End hDlg
End Function
'-----------------------------------------------------------------------------------------------
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
'------------------------------------------------
' Callback function used to handle dialog events
'------------------------------------------------
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
'-callback ----------------------------------------------------------------------------------------------
CallBack Function newDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
If CBWPARAM = %ID_BUTTON Then
Dialog New 0, "test",-1,-1, 330, 203, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
Control Add Button, hDlg, %ButtonClose, "Click to kill", 240, 50, 60, 60
Control Add Button, hDlg, %ButtonDialog, "new Dialog", 180, 50, 60, 60, Call newDialog2
Control Add Textbox , hDlg, %ID_TXTBOX, "test more text lines", 10, 50, 150, 82, _
%WS_TABSTOP Or _
%ES_WANTRETURN Or _
%ES_MULTILINE Or _
%ES_AUTOHSCROLL Or _
%ES_AUTOVSCROLL Or _
%WS_VSCROLL Or _
%WS_HSCROLL
Dialog Show Modal hDlg Call cbDialog
End If
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
'-----------------------------------------
CallBack Function newDialog2() As Long
'-----------------------------------------
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
If CBWPARAM = %ButtonDialog Then
Dialog New 0, "Sample 2 using Enter key from input field", -1, -1, 200, 260, _ 'wx, hy, _
%WS_DLGFRAME Or _
%DS_CENTER Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_OVERLAPPEDWINDOW , _
0 To hDlg
Control Add Button, hDlg, %ButtonClose, "Click to kill", 40, 50, 60, 60
Dialog Show Modal hDlg Call cbDialog
End If
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
'-----------------------------------------------------------------------------------
'--sub only for testing ------------------------------------------------------------------------
Sub mydialog()
Dialog New 0, "test Dialog1",-1,-1, 330, 203, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
Control Add Button, hDlg, %ButtonClose, "Click to kill", 90, 50, 150, 100
Dialog Show Modal hDlg Call cbDialog
End Sub
'-------------- test ends
want to understand more about ui and dialogs.
for what cases better to use "dialog new" and where "dialog pixels" ?
thanks. bye, denis
perhaps somebody has time to update this ui code for current and modern callbacks and text input with %VK_Return messages. Found this example at this board. made some tests. but if I close my seconde dialog the first dialog with textbuffer and enter key disappear too.
it's antique to use this dialog form for first main dialog isn't it ? I am confused. be gentle, it's only a test example, not perfect.
my test example:
' Empty GUI script created on 04-19-2010 08:34:14 by denis (ThinAIR)
Uses "UI"
Dim Msg As Long
Dim wParam As Long
Dim lParam As Long
Dim hDlg As Long
Dim sInput As String
Dim myNewString As String
Dim sBuffer As String
Dim wx As Long
Dim hy As Long
Dim Counter As Long
'---Control IDs
%ID_TXTBUFFER = 10
%ID_LBLENTER = 20
%ID_TXTENTER = 30
%ID_TXTMY = 40
%ID_TXTENTER2 = 50
%ID_Button = 60
%ButtonClose = 1001
%ButtonDialog = 1002
%ID_TXTBOX = 1003
%ButtonClose2 = 1004
'---Set starting width and height of the window
wx = 240
hy = 300
Function TBMain() As Long
'---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)
If GetWindowKeyState (hdlg, %VK_RETURN) <> 0 Then
DoTheJob(%ID_TXTENTER, %ID_TXTBUFFER, "")
Sleep 150
End If
'---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, "textbuffer" , 2, 2, wx - 5, hy - 70, _
%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 in textbox below and press <ENTER> key", 2, hy - 46, wx - 5, 12
Control Add Textbox , hDlg, %ID_TXTENTER, "here to type in words!" , 2, hy - 20, wx - 5, 12, %WS_TABSTOP
Control Add Textbox , hDlg, %ID_TXTENTER2, "", 2, hy - 60, wx - 5, 12, %WS_TABSTOP
Control Add Button , hDlg, %ID_Button, "< more >", 2, hy - 34, wx - 5, 12, Call newDialog
'---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
Case %WM_SYSCOMMAND
Select Case wParam
Case %SC_CLOSE
Exit While
End Select
End Select
Wend
Dialog End hDlg
End Function
'-----------------------------------------------------------------------------------------------
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
'------------------------------------------------
' Callback function used to handle dialog events
'------------------------------------------------
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
'-callback ----------------------------------------------------------------------------------------------
CallBack Function newDialog() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
If CBWPARAM = %ID_BUTTON Then
Dialog New 0, "test",-1,-1, 330, 203, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
Control Add Button, hDlg, %ButtonClose, "Click to kill", 240, 50, 60, 60
Control Add Button, hDlg, %ButtonDialog, "new Dialog", 180, 50, 60, 60, Call newDialog2
Control Add Textbox , hDlg, %ID_TXTBOX, "test more text lines", 10, 50, 150, 82, _
%WS_TABSTOP Or _
%ES_WANTRETURN Or _
%ES_MULTILINE Or _
%ES_AUTOHSCROLL Or _
%ES_AUTOVSCROLL Or _
%WS_VSCROLL Or _
%WS_HSCROLL
Dialog Show Modal hDlg Call cbDialog
End If
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
'-----------------------------------------
CallBack Function newDialog2() As Long
'-----------------------------------------
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
If CBWPARAM = %ButtonDialog Then
Dialog New 0, "Sample 2 using Enter key from input field", -1, -1, 200, 260, _ 'wx, hy, _
%WS_DLGFRAME Or _
%DS_CENTER Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_OVERLAPPEDWINDOW , _
0 To hDlg
Control Add Button, hDlg, %ButtonClose, "Click to kill", 40, 50, 60, 60
Dialog Show Modal hDlg Call cbDialog
End If
Case %WM_DESTROY
MsgBox 0, "Window is to be destroyed."
End Select
End Function
'-----------------------------------------------------------------------------------
'--sub only for testing ------------------------------------------------------------------------
Sub mydialog()
Dialog New 0, "test Dialog1",-1,-1, 330, 203, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
Control Add Button, hDlg, %ButtonClose, "Click to kill", 90, 50, 150, 100
Dialog Show Modal hDlg Call cbDialog
End Sub
'-------------- test ends
want to understand more about ui and dialogs.
for what cases better to use "dialog new" and where "dialog pixels" ?
thanks. bye, denis