News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

EDIT box control

Started by RuiLoureiro, April 08, 2012, 05:35:03 PM

Previous topic - Next topic

RuiLoureiro

        How to create an edit box to
        input several lines, one after another ?
        Thanks

dedndave

ES_MULTILINE style

you might consider ComboBox's, too   :P


RuiLoureiro


RuiLoureiro

This  line

  EDITTEXT       IDC_Text,               40,180, 200,10, ES_LEFT | ES_MULTILINE

doesnt work ! I cannot type one char ! Why ?
If i remove ES_MULTILINE it works but i want more than one line
a text written in more than one line, ok ?

dedndave

try this, Rui
  EDITTEXT IDC_Text,40,180,200,10,ES_WANTRETURN|ES_MULTILINE,,0

(ES_LEFT is default)

MichaelW

Experimenting with this source:

;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
      hInstance dd 0
      hwndEdit  dd 0
    .code
;==============================================================================
IDC_EDIT    equ 101
IDC_BUTTON  equ 102
;==============================================================================

DlgProc proc hwndDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

    SWITCH uMsg

        CASE WM_INITDIALOG

          invoke GetDlgItem, hwndDlg, IDC_EDIT
          mov hwndEdit, eax

        CASE WM_COMMAND

            SWITCH wParam

                CASE IDC_BUTTON, IDCANCEL

                    invoke EndDialog, hwndDlg, 0

            ENDSW

        CASE WM_CLOSE

            invoke EndDialog, hwndDlg, 0

    ENDSW

    return 0

DlgProc endp

;==============================================================================
start:
;==============================================================================

    invoke GetModuleHandle, NULL
    mov   hInstance, eax

    Dialog "Test", \
           "MS Sans Serif",10, \
           WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
           2,0,0,200,150,1024

    ;DlgButton "OK",BS_DEFPUSHBUTTON,80,120,30,10,IDC_BUTTON

    ;----------------------------------------------------------
    ; The ES_WANTRETURN style is necessary here because of the
    ; BS_DEFPUSHBUTTON style. Without ES_WANTRETURN, pressing
    ; the Enter key when the edit control has the focus will
    ; activate the button, instead of moving the caret to the
    ; next line. You can leave off the ES_WANTRETURN style if
    ; there is no button with the BS_DEFPUSHBUTTON style.
    ;----------------------------------------------------------

    ;DlgEdit ES_LEFT or ES_MULTILINE,40,18,200,10,IDC_EDIT

    DlgEdit WS_BORDER or ES_MULTILINE or ES_WANTRETURN or \
            WS_VSCROLL or WS_HSCROLL or ES_AUTOVSCROLL or ES_AUTOHSCROLL, \
            10,10,176,100,IDC_EDIT

    DlgButton "OK",BS_DEFPUSHBUTTON,80,120,30,10,IDC_BUTTON

    CallModalDialog hInstance,0,DlgProc,NULL

    exit
;==============================================================================
end start


The only (unlikely) explanation I can see for your not being able to type characters into the edit control is that the edit control is outside the bounds of the dialog.

eschew obfuscation

RuiLoureiro

Dave and MichaelW,
                  Thanks for your help

                i decided to use ES_AUTOHSCROLL|ES_AUTOVSCROLL
                and this solves  the problem

dedndave

 :U

Michael had these together

WS_VSCROLL or WS_HSCROLL or ES_AUTOVSCROLL or ES_AUTOHSCROLL

makes no sense to me - how can scroll bars pop in if it is auto-scrolling   :P

MichaelW

Dave,

Now that you point it out, it makes no sense to me either :bg
eschew obfuscation

jj2007

Quote from: dedndave on April 09, 2012, 05:27:04 PM
makes no sense to me - how can scroll bars pop in if it is auto-scrolling   :P

WM_VSCROLL is responsible for the scrollbars
ES_AUTOVSCROLL is needed to have multilines - you can't even paste several lines if it is not set
ES_AUTOHSCROLL, if not set, wraps text but is otherwise less important