Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Losing Link state with CHARFORMAT2 definition ;Closed

Losing Link state with CHARFORMAT2 definition ;Closed

Scheduled Pinned Locked Moved Visual Basic
c++debuggingperformancehelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mo1492
    wrote on last edited by
    #1

    The below code sets the selected text in the RichTextBox to a protected link. This works but I have an issue when entering text before the link; particularly a space char. When I enter a space character before the link, the link loses it's link state; 1. The color changes to normal text color. 2. The underline disappears. 3. I no longer receive the link click message. 4. It remains protected. I can type other characters and do not lose the link state except when the caret is on the space immediately preceding the link. Test case with this text where link is the formatted link: " abc link" Hitting the spacebar anywhere between the 'c' and the 'l' causes the link to lose its state Hitting any other char does not affect the state except when the char is next to the 'l' and then it loses its state. Anyone have an idea of why the link is losing it's attribute? Thank you Public Function SetSelectionCharFormat(ByVal hEdit As IntPtr, ByVal cf As CHARFORMAT2, _ Optional ByVal fmt As EMFormatMasks = EMFormatMasks.SCF_SELECTION Or EMFormatMasks.SCF_WORD) As Boolean Dim bReturn As Boolean = False ' This is test code which overrides the input cf.dwMask = (CFMMask.CFM_LINK Or CFMMask.CFM_PROTECTED) ' &h20 or &h10 cf.dwEffects = (CFEEffects.CFE_LINK Or CFEEffects.CFE_PROTECTED) ' &h20 or &h10 Try Dim structPtr As IntPtr ' Allocate the memory for structure data structPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cf)) ' Copy structure data to memory ptr Marshal.StructureToPtr(cf, structPtr, False) ' Return non-zero if passes; code from winctrl4.cpp ' fmt = the default (EMFormatMasks.SCF_SELECTION Or EMFormatMasks.SCF_WORD) bReturn = (MyUtilsLib.WindowsAPI.SendMessage(hEdit, EMMessages.EM_SETCHARFORMAT, fmt, structPtr) <> 0) ' Free memory Marshal.FreeHGlobal(structPtr) #If DEBUG Then If bReturn = False Then Debug.WriteLine("SetSelectionCharFormat() failed") End If #End If Catch ex As Exception MsgBox(ex.Message()) End Try Return bReturn End Function

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups