News:

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

How can I use <DlgRichEdit>Control ?

Started by vega, January 06, 2009, 12:39:48 PM

Previous topic - Next topic

vega

I want to display the content of a specified file in this <DlgRichEdit> control.
Please, show me a example code.

donkey

Hi Vega, not sure what you mean by <DlgRichEdit> but I assume that you want to use a RichEdit control on a dialog. In your RES file...

#define IDC_RICHEDIT 1001

CONTROL "RICHED",IDC_RICHEDIT,"RichEdit20A",WS_CHILD+WS_VISIBLE+WS_TABSTOP,30,127,186,152,WS_EX_CLIENTEDGE

Load the appropriate rich edit DLL using LoadLibrary then process the messages for it in your DlgProc, search for RichEdit in the forum, there are over 100 examples and questions.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

MichaelW

 vega,

I'm guessing that you are having problems trying to use the DlgRichEdit macro either because you have not loaded the required DLL, or have loaded the DLL for the wrong rich edit version. This is a bare-bones example that can use rich edit version 1 or version 2/3.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

IDC_RE equ 100

;------------------------------------------------------------------
; This equate controls which rich edit version this code will use.
; If RICHEDIT1 is defined then version 1 will be used, otherwise
; version 2/3 will be used. In other words, to use version 2/3 the
; following line must be commented out.
;------------------------------------------------------------------

RICHEDIT1 equ 1

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .data
      hInstance dd 0
      hwndRE    dd 0
    .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

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

    LOCAL rc:RECT

    SWITCH uMsg

      CASE WM_INITDIALOG

        invoke GetDlgItem, hwndDlg, IDC_RE
        mov hwndRE, eax

      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, 0

        ENDSW

      CASE WM_CLOSE

       invoke EndDialog, hwndDlg, 0

    ENDSW
    return 0

DlgProc endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

start:

    ; ------------------------------------------------------
    ; Use conditional assembly to load the appropriate DLL.
    ; ------------------------------------------------------

    IFDEF RICHEDIT1
      invoke LoadLibrary, chr$("RICHED32.DLL")
    ELSE
      invoke LoadLibrary, chr$("RICHED20.DLL")
    ENDIF

    ;------------------------------------------------------------
    ; Define the dialog. The WS_CLIPCHILDREN style is essential
    ; to prevent the rich edit control from flashing excessively
    ; when the dialog window is resized.
    ;------------------------------------------------------------

    invoke GetModuleHandle, NULL
    mov hInstance, eax

    Dialog "Test", \                    ; dialog title
           "MS Sans Serif",10, \        ; font name & point size
           WS_OVERLAPPEDWINDOW or \
           WS_CLIPCHILDREN or \
           DS_CENTER, \                 ; window style
           1, \                         ; control count
           50,50, \                     ; top X Y coordinates
           150,80, \                    ; width and height
           1024                         ; buffer size to allocate

    ;----------------------------------------------------------
    ; Define the rich edit control style as a numeric equate.
    ; Note that the control macros specify the default style
    ; as WS_VISIBLE or WS_CHILD, so these styles are combined
    ; with any other styles specified. The WS_CLIPSIBLINGS
    ; style has no apparent effect here, but was included
    ; because in a dialog with a menu and/or status bar it can
    ; improve the appearance of the rich edit control when the
    ; dialog window is resized.
    ;----------------------------------------------------------

    style = ES_MULTILINE or \
            WS_HSCROLL or \
            WS_VSCROLL or \
            ES_AUTOHSCROLL or \
            ES_AUTOVSCROLL or \
            ES_DISABLENOSCROLL or \
            ES_WANTRETURN or \
            ES_SUNKEN or \
            ES_NOHIDESEL or \
            WS_CLIPSIBLINGS

    ;------------------------------------------------------------
    ; Use conditional assembly to define the rich edit control.
    ; The DlgRichEdit macro is coded for rich edit version 1.
    ; For rich ddit version 2/3 use the general purpose common
    ; control macro and specify the correct class name.
    ;
    ; The control will be sized to fit the client area of the
    ; dialog window in the WM_SIZE handler, so specifying zero
    ; for the position, height, and width parameters would work,
    ; except with a width of zero the ES_DISABLENOSCROLL style
    ; will not make the horizontal scroll bar visible initially.
    ;------------------------------------------------------------

    IFDEF RICHEDIT1
      DlgRichEdit style,0,0,1,0,IDC_RE
    ELSE
      DlgComCtl "RichEdit20A",style,0,0,1,0,IDC_RE
    ENDIF

    CallModalDialog hInstance,0,DlgProc,NULL

    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


And donkey, before you protest the example is assembly code because it directly specifies not just one, but two actual instructions :lol


eschew obfuscation

vega

Thank you very much, MichaelW & Donkey.
my problems solved by your good & kindly Helps.
thank you!  :U