Results 1 to 27 of 27

Thread: InputBox with full unicode support v. 2.5 and v. 2.55

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    InputBox with full unicode support v. 2.5 and v. 2.55

    The possibility of calling InputBox with unicode support has already been discussed on this forum, but in fact, I can provide you with the correct source code of the InputBox function.

    v. 2.5

    Code:
    Option Explicit
    '////////////////////////////////////////////
    '// Module for calling Unicode InputBox    //
    '// Copyright (c) 2024-02-01 by HackerVlad //
    '// e-mail: vladislavpeshkov@yandex.ru     //
    '// Version 2.5                            //
    '////////////////////////////////////////////
    
    Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamW" (ByVal hInstance As Long, ByVal lpTemplate As Long, ByVal hWndParent As Long, ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Long
    Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryW" (ByVal lpLibFileName As Long) As Long
    Private Declare Function EndDialog Lib "user32" (ByVal hDlg As Long, ByVal nResult As Long) As Long
    Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function SetDlgItemText Lib "user32" Alias "SetDlgItemTextW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As Long) As Long
    Private Declare Function GetDlgItemText Lib "user32" Alias "GetDlgItemTextW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As Long, ByVal nMaxCount As Long) As Long
    Private Declare Function GetDlgItem Lib "user32" (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextW" (ByVal hwnd As Long, ByVal lpString As Long) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal CX As Long, ByVal CY As Long, ByVal wFlags As Long) As Long
    Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
    Private Declare Function WinHelp Lib "user32" Alias "WinHelpW" (ByVal hwnd As Long, ByVal lpHelpFile As Long, ByVal wCommand As Long, ByVal dwData As Long) As Long
    Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpW" (ByVal hwndCaller As Long, ByVal pszFile As Long, ByVal uCommand As Long, ByVal dwData As Long) As Long
    
    Private Const IDOK = 1
    Private Const IDCANCEL = 2
    Private Const ID_EDIT = 4900
    Private Const ID_STATIC = 4901
    Private Const ID_HELP = 4902
    Private Const WM_COMMAND = &H111
    Private Const WM_INITDIALOG = &H110
    Private Const WM_HELP = &H53
    Private Const WM_DESTROY = &H2
    
    Private Const SW_HIDE = 0
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const WM_GETTEXTLENGTH As Long = &HE
    Private Const EM_SETSEL = &HB1
    Private Const SPI_GETWORKAREA = 48
    Private Const HH_DISPLAY_TOPIC = &H0
    Private Const HH_HELP_CONTEXT = &HF
    Private Const HELP_CONTEXT = &H1
    Private Const HELP_INDEX = &H3
    Private Const HELP_QUIT = &H2
    
    Private Type RECT
        iLeft As Long
        iTop As Long
        iRight As Long
        iBottom As Long
    End Type
    
    Dim sInputText As String
    Dim sTitleText As String
    Dim sDefaultText As String
    Dim CenterOnWorkspace As Boolean ' Analog of DS_CENTER
    Dim iXPos As Integer
    Dim iYPos As Integer
    Dim sHelpFile As String
    Dim lContext As Long
    Dim IsWinHelpRunning As Boolean
    
    ' Call InputBox from msvbvm60.dll with unicode support
    Public Function InputBoxW(ByVal hParent As Long, ByVal strPrompt As String, Optional ByVal strTitle As String, Optional ByVal strDefault As String, Optional intXPos As Integer, Optional intYPos As Integer, Optional strHelpFile As String, Optional intContext As Long, Optional CenterOnMonitorWorkspace As Boolean) As String
        Dim msvbvm60 As Long
        
        msvbvm60 = LoadLibrary(StrPtr("msvbvm60.dll"))
        
        If msvbvm60 <> 0 Then
            sTitleText = strTitle
            sDefaultText = strDefault
            CenterOnWorkspace = CenterOnMonitorWorkspace
            iXPos = intXPos
            iYPos = intYPos
            sHelpFile = strHelpFile
            lContext = intContext
            IsWinHelpRunning = False
            
            DialogBoxParam msvbvm60, 4031, hParent, AddressOf DlgProc, StrPtr(strPrompt) ' The very cherished code that calls InputBox
        End If
        
        InputBoxW = sInputText
        sInputText = vbNullString
        sTitleText = vbNullString
        sDefaultText = vbNullString
        sHelpFile = vbNullString
    End Function
    
    ' Dialog box message processing function
    Private Function DlgProc(ByVal hwndDlg As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim NotifyCode As Long
        Dim ItemID As Long
        Dim wndRect As RECT
        Dim rcWork As RECT
        Dim TextLen As Long
        Dim lLeft As Long
        Dim lTop As Long
        
        Select Case uMsg
            Case WM_INITDIALOG
                If Len(sTitleText) = 0 Then sTitleText = App.Title
                SetWindowText hwndDlg, StrPtr(sTitleText)
                
                If Len(sHelpFile) = 0 Then
                    ShowWindow GetDlgItem(hwndDlg, ID_HELP), SW_HIDE
                End If
                
                SetDlgItemText hwndDlg, ID_STATIC, lParam
                
                ' Determining the size of the window
                GetWindowRect hwndDlg, wndRect
                
                ' Determine the size of the working area of the screen
                SystemParametersInfo SPI_GETWORKAREA, 0, rcWork, 0
                
                If CenterOnWorkspace = False Then ' Standard alignment
                    If (iXPos Or iYPos) = 0 Then
                        ' Absolutely perfect dialog box alignment code, exactly like the original InputBox function does
                        lLeft = rcWork.iLeft + (rcWork.iRight - rcWork.iLeft - (wndRect.iRight - wndRect.iLeft)) \ 2
                        lTop = rcWork.iTop + (rcWork.iBottom - rcWork.iTop - (wndRect.iBottom - wndRect.iTop)) \ 3
                    Else
                        lLeft = iXPos
                        lTop = iYPos
                    End If
                Else ' Centering on the working area of the screen (analogous to the DS_CENTER style)
                    lLeft = ((rcWork.iRight - rcWork.iLeft) - (wndRect.iRight - wndRect.iLeft)) / 2
                    lTop = ((rcWork.iBottom - rcWork.iTop) - (wndRect.iBottom - wndRect.iTop)) / 2
                End If
                
                SetWindowPos hwndDlg, 0, lLeft, lTop, 0, 0, SWP_NOSIZE Or SWP_NOZORDER ' Alignment of the dialog box
                
                If Len(sDefaultText) > 0 Then
                    SetDlgItemText hwndDlg, ID_EDIT, StrPtr(sDefaultText)
                    SendDlgItemMessage hwndDlg, ID_EDIT, EM_SETSEL, 0, -1
                End If
                
                DlgProc = 1
                Exit Function
            
            Case WM_COMMAND
                NotifyCode = wParam \ 65536
                ItemID = wParam And 65535
                
                If ItemID = IDOK Then
                    TextLen = SendDlgItemMessage(hwndDlg, ID_EDIT, WM_GETTEXTLENGTH, 0, 0)
                    sInputText = Space$(TextLen)
                    GetDlgItemText hwndDlg, ID_EDIT, StrPtr(sInputText), TextLen + 1
                    
                    EndDialog hwndDlg, 0
                    DlgProc = 1
                    Exit Function
                End If
                
                If ItemID = IDCANCEL Then
                    EndDialog hwndDlg, 0
                    DlgProc = 1
                    Exit Function
                End If
                
                If ItemID = ID_HELP Then
                    RunHelp hwndDlg
                    DlgProc = 1
                    Exit Function
                End If
            
            Case WM_HELP
                RunHelp hwndDlg
                DlgProc = 1
                Exit Function
            
            Case WM_DESTROY
                If IsWinHelpRunning = True Then
                    WinHelp hwndDlg, 0, HELP_QUIT, 0 ' Close the HLP window
                End If
                
                DlgProc = 1
                Exit Function
        End Select
        
        DlgProc = 0
    End Function
    
    Private Sub RunHelp(ByVal hwnd As Long)
        If Len(sHelpFile) > 0 Then
            If Right$(sHelpFile, 4) = ".hlp" Then
                If lContext = 0 Then
                    WinHelp hwnd, StrPtr(sHelpFile), HELP_INDEX, 0
                Else
                    WinHelp hwnd, StrPtr(sHelpFile), HELP_CONTEXT, lContext
                End If
                IsWinHelpRunning = True
            Else ' CHM
                If lContext = 0 Then
                    HtmlHelp hwnd, StrPtr(sHelpFile), HH_DISPLAY_TOPIC, 0
                Else
                    HtmlHelp hwnd, StrPtr(sHelpFile), HH_HELP_CONTEXT, lContext
                End If
            End If
        End If
    End Sub
    v. 2.55 (MultiLine Input)

    Code:
    Option Explicit
    '////////////////////////////////////////////
    '// Module for calling Unicode InputBox    //
    '// Copyright (c) 2024-02-03 by HackerVlad //
    '// e-mail: vladislavpeshkov@yandex.ru     //
    '// Version 2.55 (MultiLine Input)         //
    '////////////////////////////////////////////
    
    Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamW" (ByVal hInstance As Long, ByVal lpTemplate As Long, ByVal hWndParent As Long, ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Long
    Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryW" (ByVal lpLibFileName As Long) As Long
    Private Declare Function EndDialog Lib "user32" (ByVal hDlg As Long, ByVal nResult As Long) As Long
    Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function SetDlgItemText Lib "user32" Alias "SetDlgItemTextW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As Long) As Long
    Private Declare Function GetDlgItemText Lib "user32" Alias "GetDlgItemTextW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As Long, ByVal nMaxCount As Long) As Long
    Private Declare Function GetDlgItem Lib "user32" (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextW" (ByVal hwnd As Long, ByVal lpString As Long) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal CX As Long, ByVal CY As Long, ByVal wFlags As Long) As Long
    Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
    Private Declare Function WinHelp Lib "user32" Alias "WinHelpW" (ByVal hwnd As Long, ByVal lpHelpFile As Long, ByVal wCommand As Long, ByVal dwData As Long) As Long
    Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpW" (ByVal hwndCaller As Long, ByVal pszFile As Long, ByVal uCommand As Long, ByVal dwData As Long) As Long
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongW" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongW" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExW" (ByVal dwExStyle As Long, ByVal lpClassName As Long, ByVal lpWindowName As Long, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Long) As Long
    
    Private Const IDOK = 1
    Private Const IDCANCEL = 2
    Private Const ID_EDIT = 4900
    Private Const ID_STATIC = 4901
    Private Const ID_HELP = 4902
    Private Const WM_COMMAND = &H111
    Private Const WM_INITDIALOG = &H110
    Private Const WM_HELP = &H53
    Private Const WM_DESTROY = &H2
    
    Private Const GWL_STYLE = (-16)
    Private Const GWL_EXSTYLE = (-20)
    Private Const WM_USER = &H400
    Private Const EM_SETWORDWRAPMODE As Long = (WM_USER + 102)
    Private Const ES_MULTILINE = &H4&
    Private Const ES_WANTRETURN = &H1000&
    Private Const WS_VSCROLL = &H200000
    Private Const ES_UPPERCASE = &H8&
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_FRAMECHANGED = &H20        '  The frame changed: send WM_NCCALCSIZE
    Private Const ES_AUTOVSCROLL = &H40&
    Private Const WS_VISIBLE        As Long = &H10000000
    Private Const WS_EX_CLIENTEDGE  As Long = &H200&
    Private Const WS_CHILD          As Long = &H40000000
    Private Const ES_AUTOHSCROLL = &H80&
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const WM_SETFONT = &H30
    Private Const WM_GETFONT = &H31
    Private Const WS_TABSTOP = &H10000
    
    Private Const SW_HIDE = 0
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const WM_GETTEXTLENGTH As Long = &HE
    Private Const EM_SETSEL = &HB1
    Private Const SPI_GETWORKAREA = 48
    Private Const HH_DISPLAY_TOPIC = &H0
    Private Const HH_HELP_CONTEXT = &HF
    Private Const HELP_CONTEXT = &H1
    Private Const HELP_INDEX = &H3
    Private Const HELP_QUIT = &H2
    
    Private Type RECT
        iLeft As Long
        iTop As Long
        iRight As Long
        iBottom As Long
    End Type
    
    Dim sInputText As String
    Dim sTitleText As String
    Dim sDefaultText As String
    Dim CenterOnWorkspace As Boolean ' Analog of DS_CENTER
    Dim iXPos As Integer
    Dim iYPos As Integer
    Dim sHelpFile As String
    Dim lContext As Long
    Dim IsWinHelpRunning As Boolean
    
    ' Call InputBox from msvbvm60.dll with unicode support
    Public Function InputBoxW(ByVal hParent As Long, ByVal strPrompt As String, Optional ByVal strTitle As String, Optional ByVal strDefault As String, Optional intXPos As Integer, Optional intYPos As Integer, Optional strHelpFile As String, Optional intContext As Long, Optional CenterOnMonitorWorkspace As Boolean) As String
        Dim msvbvm60 As Long
        
        msvbvm60 = LoadLibrary(StrPtr("msvbvm60.dll"))
        
        If msvbvm60 <> 0 Then
            sTitleText = strTitle
            sDefaultText = strDefault
            CenterOnWorkspace = CenterOnMonitorWorkspace
            iXPos = intXPos
            iYPos = intYPos
            sHelpFile = strHelpFile
            lContext = intContext
            IsWinHelpRunning = False
            
            DialogBoxParam msvbvm60, 4031, hParent, AddressOf DlgProc, StrPtr(strPrompt) ' The very cherished code that calls InputBox
        End If
        
        InputBoxW = sInputText
        sInputText = vbNullString
        sTitleText = vbNullString
        sDefaultText = vbNullString
        sHelpFile = vbNullString
    End Function
    
    ' Dialog box message processing function
    Private Function DlgProc(ByVal hwndDlg As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim NotifyCode As Long
        Dim ItemID As Long
        Dim wndRect As RECT
        Dim rcWork As RECT
        Dim rcEdit As RECT
        Dim TextLen As Long
        Dim lLeft As Long
        Dim lTop As Long
        Dim hEdit As Long
        Dim hFont As Long
        
        Select Case uMsg
            Case WM_INITDIALOG
                If Len(sTitleText) = 0 Then sTitleText = App.Title
                SetWindowText hwndDlg, StrPtr(sTitleText)
                
                If Len(sHelpFile) = 0 Then
                    ShowWindow GetDlgItem(hwndDlg, ID_HELP), SW_HIDE
                End If
                
                SetDlgItemText hwndDlg, ID_STATIC, lParam
                
                ' Determining the size of the window
                GetWindowRect hwndDlg, wndRect
                
                ' Determine the size of the working area of the screen
                SystemParametersInfo SPI_GETWORKAREA, 0, rcWork, 0
                
                If CenterOnWorkspace = False Then ' Standard alignment
                    If (iXPos Or iYPos) = 0 Then
                        ' Absolutely perfect dialog box alignment code, exactly like the original InputBox function does
                        lLeft = rcWork.iLeft + (rcWork.iRight - rcWork.iLeft - (wndRect.iRight - wndRect.iLeft)) \ 2
                        lTop = rcWork.iTop + (rcWork.iBottom - rcWork.iTop - (wndRect.iBottom - wndRect.iTop)) \ 3
                    Else
                        lLeft = iXPos
                        lTop = iYPos
                    End If
                Else ' Centering on the working area of the screen (analogous to the DS_CENTER style)
                    lLeft = ((rcWork.iRight - rcWork.iLeft) - (wndRect.iRight - wndRect.iLeft)) / 2
                    lTop = ((rcWork.iBottom - rcWork.iTop) - (wndRect.iBottom - wndRect.iTop)) / 2
                End If
                
                SetWindowPos hwndDlg, 0, lLeft, lTop, 0, 0, SWP_NOSIZE Or SWP_NOZORDER ' Alignment of the dialog box
                
                ' Gets a handle to ID_EDIT
                hEdit = GetDlgItem(hwndDlg, ID_EDIT)
                
                ' Set ID_EDIT to be displayed in multiple lines with a vertical scroll bar
                'SetWindowLong hEdit, GWL_STYLE, GetWindowLong(hEdit, GWL_STYLE) - ES_AUTOHSCROLL - WS_MAXIMIZEBOX
                'SetWindowLong hEdit, GWL_STYLE, GetWindowLong(hEdit, GWL_STYLE) Or ES_MULTILINE Or WS_VSCROLL Or ES_AUTOVSCROLL Or ES_WANTRETURN
                
                'SetWindowLong hEdit, GWL_STYLE, 1342181444
                'SetWindowLong hEdit, GWL_EXSTYLE, 512
                
                'SetWindowPos hEdit, 0, 0, 0, 350, 50, SWP_NOZORDER Or SWP_NOMOVE Or SWP_FRAMECHANGED
                
                ' Sets the WordWrap property to True
                'SendMessage hEdit, EM_SETWORDWRAPMODE, 1, 0
                
                ' SetWindowLong does not help, so we will recreate the window
                ' using the DestroyWindow and CreateWindowEx functions
                
                ' Note:
                ' If you remove ES_WANTRETURN, the line break will be only through the Ctrl+Enter keys
                
                GetWindowRect hEdit, rcEdit
                hFont = SendMessage(hEdit, WM_GETFONT, 0, 0)
                
                DestroyWindow hEdit
                hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, StrPtr("Edit"), ByVal 0&, WS_CHILD Or WS_VISIBLE Or ES_MULTILINE Or WS_TABSTOP Or _
                ES_AUTOVSCROLL Or ES_WANTRETURN, 10, 75, rcEdit.iRight - rcEdit.iLeft, (rcEdit.iBottom - rcEdit.iTop) * 2, hwndDlg, ID_EDIT, 0&, ByVal 0&)
                
                SendMessage hEdit, WM_SETFONT, hFont, ByVal 0&
                
                If Len(sDefaultText) > 0 Then
                    SetDlgItemText hwndDlg, ID_EDIT, StrPtr(sDefaultText)
                    SendDlgItemMessage hwndDlg, ID_EDIT, EM_SETSEL, 0, -1
                End If
                
                DlgProc = 1
                Exit Function
            
            Case WM_COMMAND
                NotifyCode = wParam \ 65536
                ItemID = wParam And 65535
                
                If ItemID = IDOK Then
                    TextLen = SendDlgItemMessage(hwndDlg, ID_EDIT, WM_GETTEXTLENGTH, 0, 0)
                    sInputText = Space$(TextLen)
                    GetDlgItemText hwndDlg, ID_EDIT, StrPtr(sInputText), TextLen + 1
                    
                    EndDialog hwndDlg, 0
                    DlgProc = 1
                    Exit Function
                End If
                
                If ItemID = IDCANCEL Then
                    EndDialog hwndDlg, 0
                    DlgProc = 1
                    Exit Function
                End If
                
                If ItemID = ID_HELP Then
                    RunHelp hwndDlg
                    DlgProc = 1
                    Exit Function
                End If
            
            Case WM_HELP
                RunHelp hwndDlg
                DlgProc = 1
                Exit Function
            
            Case WM_DESTROY
                If IsWinHelpRunning = True Then
                    WinHelp hwndDlg, 0, HELP_QUIT, 0 ' Close the HLP window
                End If
                
                DlgProc = 1
                Exit Function
        End Select
        
        DlgProc = 0
    End Function
    
    Private Sub RunHelp(ByVal hwnd As Long)
        If Len(sHelpFile) > 0 Then
            If Right$(sHelpFile, 4) = ".hlp" Then
                If lContext = 0 Then
                    WinHelp hwnd, StrPtr(sHelpFile), HELP_INDEX, 0
                Else
                    WinHelp hwnd, StrPtr(sHelpFile), HELP_CONTEXT, lContext
                End If
                IsWinHelpRunning = True
            Else ' CHM
                If lContext = 0 Then
                    HtmlHelp hwnd, StrPtr(sHelpFile), HH_DISPLAY_TOPIC, 0
                Else
                    HtmlHelp hwnd, StrPtr(sHelpFile), HH_HELP_CONTEXT, lContext
                End If
            End If
        End If
    End Sub

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Note:
    If you remove ES_WANTRETURN, the line break will be only through the Ctrl+Enter keys. Enter will then act to enter in the dialog box.

    Code:
    hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, StrPtr("Edit"), ByVal 0&, WS_CHILD Or WS_VISIBLE Or ES_MULTILINE Or WS_TABSTOP Or _
                ES_AUTOVSCROLL, 10, 75, rcEdit.iRight - rcEdit.iLeft, (rcEdit.iBottom - rcEdit.iTop) * 2, hwndDlg, ID_EDIT, 0&, ByVal 0&)
    Attached Files Attached Files

  3. #3
    Fanatic Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    522

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Good job hackervlad
    great contribution

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by yokesee View Post
    Good job hackervlad
    great contribution
    I'm trying to help people.

  5. #5
    Hyperactive Member
    Join Date
    Jun 2022
    Posts
    263

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Thanks for the code.

    I have been wanting to do this in VBA for a long time so I wouldn't need to rely on the msvbvm60.dll. Unfortunately, I can't seem to find the resource template for the inputbox dialog anywhere in any of the VBE6/VBE7 related dlls .

    Using the Resource Hacker, I have found many templates but the one for the InputBox is missing !

    I wonder where I could find it.

    Last edited by AngelV; Feb 4th, 2024 at 03:07 AM.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Feel free to use it msvbvm60.dll it is available in all versions of Windows.

  7. #7
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,763

    Talking Re: InputBox with full unicode support v. 2.5 and v. 2.55

    I used to think the same but unfortunately, "msvbvm60.dll" is a 32-bit DLL so it won't work with the 64-bit versions of Office that everyone are using nowadays...

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Doesn't the InputBox function support unicode by default in a 64-bit office??? Then there is a simpler code for you:

    Code:
    Public Function InputBoxW(Prompt, title, Optional Default = "") As String
    Dim sc
    Dim s
    Dim p As String
    Dim v As String
    Set sc = CreateObject("MSScriptControl.ScriptControl")
    sc.Language = "VBScript"
    p = Prompt: GoSub jConcat
    p = title: GoSub jConcat
    p = Default: GoSub jConcat
    If ObjPtr(Screen.ActiveForm) Then sc.SitehWnd = Screen.ActiveForm.hWnd
    s = sc.Eval("InputBox(" & v & ")")
    If IsEmpty(s) Then s = vbNullString Else If Len(s) = 0 Then s = ""
     
    InputBoxW = s
    Exit Function
     
    jConcat:
    If v <> "" Then v = v & ","
    If InStr(1, p, """") Then p = Replace(p, """", """""")
    If InStr(1, p, vbCrLf) Then p = Replace(p, vbCrLf, """ & vbNewLine & """)
    If InStr(1, p, vbLf) Then p = Replace(p, vbLf, """ & vbNewLine & """)
    v = v & ("""" & p & """")
    Return
    End Function

  9. #9
    Hyperactive Member
    Join Date
    Jun 2022
    Posts
    263

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    I am not so much interested in the actual unicode text as to how to find the corresponding resource template for the inputbox dialog as an example.
    Seems that the developpers of vba are experts at making things difficult on purpose.

  10. #10
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,456

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by AngelV View Post
    I am not so much interested in the actual unicode text as to how to find the corresponding resource template for the inputbox dialog as an example.
    Seems that the developpers of vba are experts at making things difficult on purpose.
    Why not use DialogBoxIndirectParamW and have the template resource persisted in the code directly? (In-memory; copy of vb6 template)
    This would make it independent. Or do I miss something?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by Krool View Post
    Why not use DialogBoxIndirectParamW and have the template resource persisted in the code directly? (In-memory; copy of vb6 template)
    This would make it independent. Or do I miss something?
    Krool, you're completely right. You can fully describe the dialog box in your own code and do not need to call the resources of any DLL. I'm calling a dialog box from resources just to simplify the code, in fact, you can describe exactly the same coordinates of the window yourself. However, you will have to tinker a little for this, of course.

  12. #12
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,070

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by HackerVlad View Post
    Feel free to use it msvbvm60.dll it is available in all versions of Windows.
    can't support x64 office

  13. #13
    Hyperactive Member
    Join Date
    Jun 2022
    Posts
    263

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Thanks Krool and HackerVlad,

    Yes, I guess could achieve the same with DialogBoxIndirectParamW, CreateWindowExW or even simply by using a simple vba UserForm but I am intrigued as to why the InputBox dlg template is nowhere to be found except in the msvbvm60.dll yet, all office applications do use the InputBox function... so i wonder where on earth do excel, word, access etc retrieve the InputBox dlg!!!

    Edit.
    Btw, same happens with the standard vba MsgBox function. I can't find it anywhere in the VBE6/VBE7 related dlls either .
    I am beginning to think that maybe those missing dlg templates are to be found in core windows dlls.
    Last edited by AngelV; Feb 4th, 2024 at 04:36 PM.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by AngelV View Post
    Thanks Krool and HackerVlad,

    Yes, I guess could achieve the same with DialogBoxIndirectParamW, CreateWindowExW or even simply by using a simple vba UserForm but I am intrigued as to why the InputBox dlg template is nowhere to be found except in the msvbvm60.dll yet, all office applications do use the InputBox function... so i wonder where on earth do excel, word, access etc retrieve the InputBox dlg!!!

    Edit.
    Btw, same happens with the standard vba MsgBox function. I can't find it anywhere in the VBE6/VBE7 related dlls either .
    I am beginning to think that maybe those missing dlg templates are to be found in core windows dlls.
    I have no idea in which files the Office stores the dialog box and where to look for this DLL. And why know that? I think it extracts from the operating system, bypassing the Microsoft Office package files. MsgBox is called by the MessageBox API function, this is much easier.

  15. #15
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,763

    Question Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by Krool View Post
    Why not use DialogBoxIndirectParamW and have the template resource persisted in the code directly? (In-memory; copy of vb6 template)
    This would make it independent. Or do I miss something?
    So if you saved a copy of the VB6 template would it work for the "DialogBoxIndirectParamW" function in x64 provided the 64-bit structures have different byte alignment? I don't have Office installed to test this...

  16. #16
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,070

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    hook DialogBoxIndirectParam,try?for get dialog window res

  17. #17
    Hyperactive Member
    Join Date
    May 2018
    Location
    Russia
    Posts
    343

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Thank you, HackerVlad.

    It would be great if you somehow set focus to the TextBox when the InputBox is appeared.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Please wrote for you, enjoy the focus of the input on the default text field.

    Code:
    Option Explicit
    '////////////////////////////////////////////
    '// Module for calling Unicode InputBox    //
    '// Copyright (c) 2024-02-12 by HackerVlad //
    '// e-mail: vladislavpeshkov@yandex.ru     //
    '// Version 2.6 (MultiLine Input)          //
    '////////////////////////////////////////////
    
    Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamW" (ByVal hInstance As Long, ByVal lpTemplate As Long, ByVal hWndParent As Long, ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Long
    Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryW" (ByVal lpLibFileName As Long) As Long
    Private Declare Function EndDialog Lib "user32" (ByVal hDlg As Long, ByVal nResult As Long) As Long
    Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function SetDlgItemText Lib "user32" Alias "SetDlgItemTextW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As Long) As Long
    Private Declare Function GetDlgItemText Lib "user32" Alias "GetDlgItemTextW" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As Long, ByVal nMaxCount As Long) As Long
    Private Declare Function GetDlgItem Lib "user32" (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextW" (ByVal hwnd As Long, ByVal lpString As Long) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal CX As Long, ByVal CY As Long, ByVal wFlags As Long) As Long
    Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
    Private Declare Function WinHelp Lib "user32" Alias "WinHelpW" (ByVal hwnd As Long, ByVal lpHelpFile As Long, ByVal wCommand As Long, ByVal dwData As Long) As Long
    Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpW" (ByVal hwndCaller As Long, ByVal pszFile As Long, ByVal uCommand As Long, ByVal dwData As Long) As Long
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongW" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongW" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExW" (ByVal dwExStyle As Long, ByVal lpClassName As Long, ByVal lpWindowName As Long, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Long) As Long
    Private Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    
    Private Const IDOK = 1
    Private Const IDCANCEL = 2
    Private Const ID_EDIT = 4900
    Private Const ID_STATIC = 4901
    Private Const ID_HELP = 4902
    Private Const WM_COMMAND = &H111
    Private Const WM_INITDIALOG = &H110
    Private Const WM_HELP = &H53
    Private Const WM_DESTROY = &H2
    
    Private Const GWL_STYLE = (-16)
    Private Const GWL_EXSTYLE = (-20)
    Private Const WM_USER = &H400
    Private Const EM_SETWORDWRAPMODE As Long = (WM_USER + 102)
    Private Const ES_MULTILINE = &H4&
    Private Const ES_WANTRETURN = &H1000&
    Private Const WS_VSCROLL = &H200000
    Private Const ES_UPPERCASE = &H8&
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_FRAMECHANGED = &H20        '  The frame changed: send WM_NCCALCSIZE
    Private Const ES_AUTOVSCROLL = &H40&
    Private Const WS_VISIBLE        As Long = &H10000000
    Private Const WS_EX_CLIENTEDGE  As Long = &H200&
    Private Const WS_CHILD          As Long = &H40000000
    Private Const ES_AUTOHSCROLL = &H80&
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const WM_SETFONT = &H30
    Private Const WM_GETFONT = &H31
    Private Const WS_TABSTOP = &H10000
    
    Private Const SW_HIDE = 0
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const WM_GETTEXTLENGTH As Long = &HE
    Private Const EM_SETSEL = &HB1
    Private Const SPI_GETWORKAREA = 48
    Private Const HH_DISPLAY_TOPIC = &H0
    Private Const HH_HELP_CONTEXT = &HF
    Private Const HELP_CONTEXT = &H1
    Private Const HELP_INDEX = &H3
    Private Const HELP_QUIT = &H2
    
    Private Type RECT
        iLeft As Long
        iTop As Long
        iRight As Long
        iBottom As Long
    End Type
    
    Dim sInputText As String
    Dim sTitleText As String
    Dim sDefaultText As String
    Dim CenterOnWorkspace As Boolean ' Analog of DS_CENTER
    Dim iXPos As Integer
    Dim iYPos As Integer
    Dim sHelpFile As String
    Dim lContext As Long
    Dim IsWinHelpRunning As Boolean
    Dim hEdit As Long
    
    ' Call InputBox from msvbvm60.dll with unicode support
    Public Function InputBoxW(ByVal hParent As Long, ByVal strPrompt As String, Optional ByVal strTitle As String, Optional ByVal strDefault As String, Optional intXPos As Integer, Optional intYPos As Integer, Optional strHelpFile As String, Optional intContext As Long, Optional CenterOnMonitorWorkspace As Boolean) As String
        Dim msvbvm60 As Long
        
        msvbvm60 = LoadLibrary(StrPtr("msvbvm60.dll"))
        
        If msvbvm60 <> 0 Then
            sTitleText = strTitle
            sDefaultText = strDefault
            CenterOnWorkspace = CenterOnMonitorWorkspace
            iXPos = intXPos
            iYPos = intYPos
            sHelpFile = strHelpFile
            lContext = intContext
            IsWinHelpRunning = False
            
            DialogBoxParam msvbvm60, 4031, hParent, AddressOf DlgProc, StrPtr(strPrompt) ' The very cherished code that calls InputBox
        End If
        
        InputBoxW = sInputText
        sInputText = vbNullString
        sTitleText = vbNullString
        sDefaultText = vbNullString
        sHelpFile = vbNullString
    End Function
    
    ' Dialog box message processing function
    Private Function DlgProc(ByVal hwndDlg As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim NotifyCode As Long
        Dim ItemID As Long
        Dim wndRect As RECT
        Dim rcWork As RECT
        Dim rcEdit As RECT
        Dim TextLen As Long
        Dim lLeft As Long
        Dim lTop As Long
        Dim hFont As Long
        
        Select Case uMsg
            Case WM_INITDIALOG
                If Len(sTitleText) = 0 Then sTitleText = App.Title
                SetWindowText hwndDlg, StrPtr(sTitleText)
                
                If Len(sHelpFile) = 0 Then
                    ShowWindow GetDlgItem(hwndDlg, ID_HELP), SW_HIDE
                End If
                
                SetDlgItemText hwndDlg, ID_STATIC, lParam
                
                ' Determining the size of the window
                GetWindowRect hwndDlg, wndRect
                
                ' Determine the size of the working area of the screen
                SystemParametersInfo SPI_GETWORKAREA, 0, rcWork, 0
                
                If CenterOnWorkspace = False Then ' Standard alignment
                    If (iXPos Or iYPos) = 0 Then
                        ' Absolutely perfect dialog box alignment code, exactly like the original InputBox function does
                        lLeft = rcWork.iLeft + (rcWork.iRight - rcWork.iLeft - (wndRect.iRight - wndRect.iLeft)) \ 2
                        lTop = rcWork.iTop + (rcWork.iBottom - rcWork.iTop - (wndRect.iBottom - wndRect.iTop)) \ 3
                    Else
                        lLeft = iXPos
                        lTop = iYPos
                    End If
                Else ' Centering on the working area of the screen (analogous to the DS_CENTER style)
                    lLeft = ((rcWork.iRight - rcWork.iLeft) - (wndRect.iRight - wndRect.iLeft)) / 2
                    lTop = ((rcWork.iBottom - rcWork.iTop) - (wndRect.iBottom - wndRect.iTop)) / 2
                End If
                
                SetWindowPos hwndDlg, 0, lLeft, lTop, 0, 0, SWP_NOSIZE Or SWP_NOZORDER ' Alignment of the dialog box
                
                ' Gets a handle to ID_EDIT
                hEdit = GetDlgItem(hwndDlg, ID_EDIT)
                
                ' Set ID_EDIT to be displayed in multiple lines with a vertical scroll bar
                'SetWindowLong hEdit, GWL_STYLE, GetWindowLong(hEdit, GWL_STYLE) - ES_AUTOHSCROLL - WS_MAXIMIZEBOX
                'SetWindowLong hEdit, GWL_STYLE, GetWindowLong(hEdit, GWL_STYLE) Or ES_MULTILINE Or WS_VSCROLL Or ES_AUTOVSCROLL Or ES_WANTRETURN
                
                'SetWindowLong hEdit, GWL_STYLE, 1342181444
                'SetWindowLong hEdit, GWL_EXSTYLE, 512
                
                'SetWindowPos hEdit, 0, 0, 0, 350, 50, SWP_NOZORDER Or SWP_NOMOVE Or SWP_FRAMECHANGED
                
                ' Sets the WordWrap property to True
                'SendMessage hEdit, EM_SETWORDWRAPMODE, 1, 0
                
                ' SetWindowLong does not help, so we will recreate the window
                ' using the DestroyWindow and CreateWindowEx functions
                
                ' Note:
                ' If you remove ES_WANTRETURN, the line break will be only through the Ctrl+Enter keys
                
                GetWindowRect hEdit, rcEdit
                hFont = SendMessage(hEdit, WM_GETFONT, 0, 0)
                
                DestroyWindow hEdit
                hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, StrPtr("Edit"), ByVal 0&, WS_CHILD Or WS_VISIBLE Or ES_MULTILINE Or WS_TABSTOP Or _
                ES_AUTOVSCROLL, 10, 75, rcEdit.iRight - rcEdit.iLeft, (rcEdit.iBottom - rcEdit.iTop) * 2, hwndDlg, ID_EDIT, 0&, ByVal 0&)
                
                SendMessage hEdit, WM_SETFONT, hFont, ByVal 0&
                
                If Len(sDefaultText) > 0 Then
                    SetDlgItemText hwndDlg, ID_EDIT, StrPtr(sDefaultText)
                    SendDlgItemMessage hwndDlg, ID_EDIT, EM_SETSEL, 0, -1
                End If
                
                SetFocusAPI hEdit ' SetFocus NEW Text Field
                
                DlgProc = 0
                Exit Function
            
            Case WM_COMMAND
                NotifyCode = wParam \ 65536
                ItemID = wParam And 65535
                
                If ItemID = IDOK Then
                    TextLen = SendDlgItemMessage(hwndDlg, ID_EDIT, WM_GETTEXTLENGTH, 0, 0)
                    sInputText = Space$(TextLen)
                    GetDlgItemText hwndDlg, ID_EDIT, StrPtr(sInputText), TextLen + 1
                    
                    EndDialog hwndDlg, 0
                    DlgProc = 1
                    Exit Function
                End If
                
                If ItemID = IDCANCEL Then
                    EndDialog hwndDlg, 0
                    DlgProc = 1
                    Exit Function
                End If
                
                If ItemID = ID_HELP Then
                    RunHelp hwndDlg
                    DlgProc = 1
                    Exit Function
                End If
            
            Case WM_HELP
                RunHelp hwndDlg
                DlgProc = 1
                Exit Function
            
            Case WM_DESTROY
                If IsWinHelpRunning = True Then
                    WinHelp hwndDlg, 0, HELP_QUIT, 0 ' Close the HLP window
                End If
                
                DlgProc = 1
                Exit Function
        End Select
        
        DlgProc = 0
    End Function
    
    Private Sub RunHelp(ByVal hwnd As Long)
        If Len(sHelpFile) > 0 Then
            If Right$(sHelpFile, 4) = ".hlp" Then
                If lContext = 0 Then
                    WinHelp hwnd, StrPtr(sHelpFile), HELP_INDEX, 0
                Else
                    WinHelp hwnd, StrPtr(sHelpFile), HELP_CONTEXT, lContext
                End If
                IsWinHelpRunning = True
            Else ' CHM
                If lContext = 0 Then
                    HtmlHelp hwnd, StrPtr(sHelpFile), HH_DISPLAY_TOPIC, 0
                Else
                    HtmlHelp hwnd, StrPtr(sHelpFile), HH_HELP_CONTEXT, lContext
                End If
            End If
        End If
    End Sub

  19. #19
    Hyperactive Member
    Join Date
    May 2018
    Location
    Russia
    Posts
    343

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by HackerVlad View Post
    Please wrote for you, enjoy the focus of the input on the default text field.
    Just works!

  20. #20
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,352

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    JFYI, here are the results from MZ-Tools linter

    Code:
    The declaration Declare 'GetWindowLong' is not used (it is used only inside commented block)
    The declaration Declare 'SetWindowLong' is not used (it is used only inside commented block)
    The constant 'GWL_STYLE' is not used (it is used only inside commented block)
    The constant 'GWL_EXSTYLE' is not used (it is used only inside commented block)
    The constant 'EM_SETWORDWRAPMODE' is not used (it is used only inside commented block)
    The constant 'ES_WANTRETURN' is not used (it is used only inside commented block)
    The constant 'WS_VSCROLL' is not used (it is used only inside commented block)
    The constant 'ES_UPPERCASE' is not used
    The constant 'SWP_NOMOVE' is not used (it is used only inside commented block)
    The constant 'SWP_FRAMECHANGED' is not used (it is used only inside commented block)
    The constant 'ES_AUTOHSCROLL' is not used (it is used only inside commented block)
    The constant 'WS_MAXIMIZEBOX' is not used (it is used only inside commented block)
    cheers,
    </wqW>

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by wqweto View Post
    JFYI, here are the results from MZ-Tools linter

    Code:
    The declaration Declare 'GetWindowLong' is not used (it is used only inside commented block)
    The declaration Declare 'SetWindowLong' is not used (it is used only inside commented block)
    The constant 'GWL_STYLE' is not used (it is used only inside commented block)
    The constant 'GWL_EXSTYLE' is not used (it is used only inside commented block)
    The constant 'EM_SETWORDWRAPMODE' is not used (it is used only inside commented block)
    The constant 'ES_WANTRETURN' is not used (it is used only inside commented block)
    The constant 'WS_VSCROLL' is not used (it is used only inside commented block)
    The constant 'ES_UPPERCASE' is not used
    The constant 'SWP_NOMOVE' is not used (it is used only inside commented block)
    The constant 'SWP_FRAMECHANGED' is not used (it is used only inside commented block)
    The constant 'ES_AUTOHSCROLL' is not used (it is used only inside commented block)
    The constant 'WS_MAXIMIZEBOX' is not used (it is used only inside commented block)
    cheers,
    </wqW>
    Well, delete what you don't need, I wrote it in a hurry at all only at the request of those who wish. You look at version 2.5 there is nothing superfluous.

  22. #22
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,352

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by HackerVlad View Post
    Well, delete what you don't need, I wrote it in a hurry at all only at the request of those who wish. You look at version 2.5 there is nothing superfluous.
    I noticed that you take great pride in your creative solution so thought you might want to comb out any redundancies/imperfections it might have.

    Of course leaving it being good enough is always an option. I personally edit my old submissions here (years old) all the time when something more optimal is revealed on my path of knowledge.

    cheers,
    </wqw>

  23. #23
    Fanatic Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    588

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Nice work HV but I have a problem which I thought you might want to know about.

    Earlier versions worked well for me but version 2.55 has a display issue. (I'm at DPI = 150%, if that matters)

    This is what I see when I run the EXE in your zip file:

    Name:  unicode input box v255 multiline issue.png
Views: 127
Size:  16.6 KB

    And this is what I see when I run it in the IDE and click on the Main button in the demo:

    Name:  unicode input box v255 multiline issue 2.png
Views: 121
Size:  7.1 KB

    The multiline text box is displaying over the buttons in both cases - though differently in each case for some reason.
    Last edited by AAraya; Jun 20th, 2024 at 03:52 PM.

  24. #24

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Thanks for that comment. At DPI = 150%, I really haven't tested this code. As for the Russian language, it was most likely not encoded in unicode. This is just an example. Why do you need Russian words if you are from English-speaking countries or from Asia.

  25. #25
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,070

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    You can specify the text box style and change its display position.
    The background color of the text box can be displayed, and the background of the picture can be changed. Or add a photo frame to the white text box.
    Word wrap adds a scroll bar.

  26. #26

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    Quote Originally Posted by AAraya View Post
    Nice work HV but I have a problem which I thought you might want to know about.

    Earlier versions worked well for me but version 2.55 has a display issue. (I'm at DPI = 150%, if that matters)

    This is what I see when I run the EXE in your zip file:

    Name:  unicode input box v255 multiline issue.png
Views: 127
Size:  16.6 KB

    And this is what I see when I run it in the IDE and click on the Main button in the demo:

    Name:  unicode input box v255 multiline issue 2.png
Views: 121
Size:  7.1 KB

    The multiline text box is displaying over the buttons in both cases - though differently in each case for some reason.
    I have checked on my screen now, it is displayed normally at both 125% and 150%. Unfortunately, I couldn't reproduce your problem to try to solve it. But I think you can do it yourself.

  27. #27

    Thread Starter
    Lively Member
    Join Date
    Nov 2023
    Posts
    106

    Re: InputBox with full unicode support v. 2.5 and v. 2.55

    You can do it if you want. If that's what you need. But I must warn you that changing the background color of the text field will be quite a difficult task for you. Since you will have to describe this behavior for two versions of the window at once, a stylized theme and a non-stylized one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width