The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RuiLoureiro on April 08, 2012, 05:35:03 PM

Title: EDIT box control
Post by: RuiLoureiro on April 08, 2012, 05:35:03 PM
        How to create an edit box to
        input several lines, one after another ?
        Thanks
Title: Re: EDIT box control
Post by: dedndave on April 08, 2012, 05:38:05 PM
ES_MULTILINE style

you might consider ComboBox's, too   :P

(http://bytescout.com/files/images/examples/bytescoutpdf/combobox.png)
Title: Re: EDIT box control
Post by: RuiLoureiro on April 08, 2012, 05:49:39 PM
Thank you Dave
Title: Re: EDIT box control
Post by: RuiLoureiro on April 08, 2012, 08:30:04 PM
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 ?
Title: Re: EDIT box control
Post by: dedndave on April 08, 2012, 09:44:03 PM
try this, Rui
  EDITTEXT IDC_Text,40,180,200,10,ES_WANTRETURN|ES_MULTILINE,,0

(ES_LEFT is default)
Title: Re: EDIT box control
Post by: MichaelW on April 08, 2012, 10:19:50 PM
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.

Title: Re: EDIT box control
Post by: RuiLoureiro on April 09, 2012, 01:59:06 PM
Dave and MichaelW,
                  Thanks for your help

                i decided to use ES_AUTOHSCROLL|ES_AUTOVSCROLL
                and this solves  the problem
Title: Re: EDIT box control
Post by: dedndave on April 09, 2012, 05:27:04 PM
 :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
Title: Re: EDIT box control
Post by: MichaelW on April 09, 2012, 06:44:07 PM
Dave,

Now that you point it out, it makes no sense to me either :bg
Title: Re: EDIT box control
Post by: jj2007 on April 09, 2012, 07:07:49 PM
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