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

EM_AUTOURLDETECT doesn't work with RichTextBox?

Hi Experts
plz, tell why the following code doesn't work
(i am working in windows 2000)
sLib = "RICHED20.DLL"
    sClass = RICHEDIT_CLASSA
    m_hLib = LoadLibrary(sLib)
    If m_hLib = 0 Then
        sLib = "RICHED32.DLL"
        sClass = RICHEDIT_CLASS10A
        m_hLib = LoadLibrary(sLib)
    End If
     
      If m_hLib <> 0 Then
         dwStyle = WS_CHILD Or WS_CLIPCHILDREN Or _
         WS_CLIPSIBLINGS Or WS_HSCROLL Or WS_VSCROLL Or WS_TABSTOP Or _
         ES_MULTILINE Or ES_AUTOVSCROLL Or ES_AUTOHSCROLL Or _
         ES_SUNKEN Or ES_CENTER
         
         m_hWndParent = Me.hwnd
         m_hWnd = CreateWindowEx(dwExStyle, sClass, "", dwStyle, _
            0, 0, Me.ScaleWidth \ Screen.TwipsPerPixelX, Me.ScaleHeight \ Screen.TwipsPerPixelY, _
            m_hWndParent, 0, App.hInstance, 0)
        If (m_hWnd <> 0) Then
            ShowWindow m_hWnd, 1
            EnableWindow m_hWnd, 1
            Dim a As Long
            a = SendMessage(m_hWnd, EM_GETEVENTMASK, 0, 0)
            a = SendMessage(m_hWnd, EM_SETEVENTMASK, 0, ByVal ENM_LINK Or a)
            a = SendMessage(m_hWnd, EM_AUTOURLDETECT, Abs(1), 0)
           
        End If
    End If
0
pramod_kumar_tk
Asked:
pramod_kumar_tk
  • 2
1 Solution
 
zzzzzoocCommented:
What didn't work? It works for me but I may have used a different class-name because you didn't include ANY declarations.

There are mainly 2 possibilities for it not to auto-detect the URLs (if that's what your problem was)..

1.) Use "RICHEDIT20A" for the RichEdit class-name (newer class that supports the auto-detect).
2.) Pass the last parameter of SendMessage() ByVal:

a = SendMessage(m_hWnd, EM_AUTOURLDETECT, Abs(1), ByVal 0)


Also, you need to subclass the form's (parent window) WindowProc to receive a WM_NOTIFY message where the notification will be EN_LINK.


Here's a quick article on the subclassing portion. It's not for VB but you only need to know the API required anyways.
http://delphi.about.com/od/vclusing/l/aa111803a.htm
0
 
pramod_kumar_tkAuthor Commented:
Ok, Let my try
0
 
pramod_kumar_tkAuthor Commented:
u r right the Byval makes the problem
thanx a lot
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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