• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Help with scrolling & scrollbars in RichEdit 2.0

I'm Creating a MDI program, the main window and child windows are VB forms.  I'm tryng to create the RichTextBox on the child form dynamicaly, because I want version 2 of the RichEdit.

I can't seem to get the scrollbars to appear and autoscolling doesn't work either.
I'd also like to know how to set the focus to the created form automatically when the
parent form is at the top.  Thanks in advance.

Public Sub CreateRichEdit(frm As frmEdit) 'frmEdit is the VB created child form
  Dim style As Long           'window style
  Dim m_hWnd As Long          'Handle to created window
  Dim lib As Long             'Handle to RichEdit20.dll
  Dim retVal As Long          'Return value for SendMessage function
 
    style = ES_MULTILINE Or ES_LEFT Or ES_SUNKEN Or _
            WS_VISIBLE Or WS_CHILD
           
    lib = LoadLibrary("RichEd20.dll")
   
    m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE Or _
                            WS_HSCROLL Or _
                            WS_VSCROLL, _
                            RICHEDIT_CLASSA, _
                            vbNullString, _
                            style, _
                            0, _
                            0, _
                            frm.ScaleWidth, _
                            frm.ScaleHeight, _
                            frm.hWnd, _
                            0&, _
                            App.hInstance, _
                            ByVal 0&)
                           

    'Initialize data members
    hWnd = m_hWnd
    Owner = frm
    CEnum = childWindowNum
   
    'Set event mask
    retVal = SendMessageLong(hWnd, EM_SETEVENTMASK, 0&, ENM_CHANGE)
   
    'Set edit style
    retVal = SendMessageLong(hWnd, EM_SETEDITSTYLE, _
                             SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR)
   
    'Set RichEdit options
    retVal = SendMessageLong(hWnd, _
                             EM_SETOPTIONS, _
                             ECOOP_OR, _
                             ECO_AUTOHSCROLL Or _
                             ECO_AUTOVSCROLL Or _
                             ECO_AUTOWORDSELECTION Or _
                             ES_WANTRETURN)
   
    'Increment the child window counter
    Inc childWindowNum
   
    'Start subclassing
    Set formHook = New MsgHook
    formHook.StartSubclass Me.hWnd
   
End Sub

0
pwilden
Asked:
pwilden
1 Solution
 
pwildenAuthor Commented:
The problem turned out to be the scale.  The Parent window coordinates were in twips, while the CreateWindowEx uses pixels.  I had the scrollbars, they were just out of view.
0
 
CleanupPingCommented:
Hi pwilden,
This old question (QID 20554429) needs to be finalized -- no Experts commented, so delete it and get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now