The MASM Forum

General => The Campus => Topic started by: six_L on March 27, 2014, 06:10:33 PM

Title: tow RichEdits
Post by: six_L on March 27, 2014, 06:10:33 PM
can't create tow RichEdits.
include \masm32\include\masm32rt.inc
;==============================================================================
IDC_RE1 equ 100
IDC_RE2 equ 101
;==============================================================================

  ;----------------------------------------------------------------------
  ; This is a general-purpose control definition macro that adds support
  ; for controls of any type to the MASM32 In-Memory Dialogs. For this
  ; macro the control class is specified as a quoted string, instead of
  ; being hard coded.
  ;----------------------------------------------------------------------

    DlgControl MACRO quoted_caption,quoted_class,dstyle,tx,ty,wd,ht,ctlID
      align_4 edi
      mov DWORD PTR [edi+0],  WS_VISIBLE or WS_CHILD or dstyle
      mov WORD  PTR [edi+8],  tx
      mov WORD  PTR [edi+10], ty
      mov WORD  PTR [edi+12], wd
      mov WORD  PTR [edi+14], ht
      mov WORD  PTR [edi+16], ctlID
      add edi, 18
      ustring quoted_class
      ustring quoted_caption
      ;-------------------------------------------
      ; Advance edi past the creation data array.
      ;-------------------------------------------
      add edi, 2
    ENDM

;==============================================================================
    .data
      hInst   dd 0
      hwndRE1  dd 0
      hwndRE2  dd 0
      chrg    CHARRANGE <>
    .code
;==============================================================================

DlgProc proc hwndDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

    LOCAL rc:RECT

    SWITCH uMsg

        CASE WM_INITDIALOG

            invoke GetClientRect, hwndDlg, ADDR rc
            invoke GetDlgItem, hwndDlg, IDC_RE1
            mov hwndRE1, eax
           
    invoke GetDlgItem, hwndDlg, IDC_RE2
            mov hwndRE2, eax

            invoke SendMessage, hwndRE1, EM_EXLIMITTEXT, 1000000, 0
            invoke SendMessage, hwndRE2, EM_EXLIMITTEXT, 1000000, 0
        CASE WM_SYSCOMMAND

            ;-----------------------------------------------------------------
            ; Clicking the title bar will send WM_SYSCOMMAND every 2nd click.
            ;-----------------------------------------------------------------

            invoke SendMessage, hwndRE1, WM_GETTEXTLENGTH, 0, 0

             mov chrg.cpMax, eax
             dec eax
             mov chrg.cpMin, eax

            invoke SendMessage, hwndRE1, EM_EXSETSEL, 0, ADDR chrg
            invoke SendMessage, hwndRE1, EM_REPLACESEL, FALSE, 0

        ;CASE WM_SIZE

          ;  invoke GetClientRect, hwndDlg, ADDR rc
           ; invoke MoveWindow, hwndRE, 0, 0, rc.right, rc.bottom, TRUE

        CASE WM_COMMAND

            SWITCH wParam
                Case IDCANCEL
                    invoke EndDialog, hwndDlg, NULL
            ENDSW

        CASE WM_CLOSE

            invoke EndDialog, hwndDlg, NULL

    EndSw

    return 0

DlgProc endp

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

    invoke LoadLibrary, chr$("RICHED20.DLL")

    invoke GetModuleHandle, NULL
    mov hInst, eax

    Dialog  0, \
            "Courier New",8, \
            WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
            1, \
            0,0,200,180, \
            1024

    DlgControl "Send", \
               "RichEdit20A", \
               WS_VSCROLL or \
               WS_HSCROLL or \
               ES_SUNKEN or \
               ES_MULTILINE or \
               ES_AUTOVSCROLL or \
               ES_AUTOHSCROLL or \
               ES_NOHIDESEL or \
               ES_WANTRETURN, \
               0,0,197,70,IDC_RE1
    DlgControl "Recv", \
               "RichEdit20A", \
               WS_VSCROLL or \
               WS_HSCROLL or \
               ES_SUNKEN or \
               ES_MULTILINE or \
               ES_AUTOVSCROLL or \
               ES_AUTOHSCROLL or \
               ES_NOHIDESEL or \
               ES_WANTRETURN, \
               0,72,197,70,IDC_RE2

    CallModalDialog hInst, 0, DlgProc, NULL
    exit
Title: Re: tow RichEdits
Post by: qWord on March 27, 2014, 06:29:55 PM
You forgot to update the control count in the call of the Dialog-macro:

    Dialog  0, \
            "Courier New",8, \
            WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
            2, \
            0,0,200,180, \
            1024
Title: Re: tow RichEdits
Post by: six_L on March 27, 2014, 07:33:36 PM
ok, :biggrin:
thank you very much.