Jump to content

Wrapping an Edit Control... _GUICtrlEditGetSel, but with Data not Position


Recommended Posts

In the forums if you create a post you can modify text by using the button to insert code. For instance, if the user highlights a word and presses the bold icon the forum inserts the code for bold on each side of the word/phrase. I am trying to do this in a GUI, but I don't know how to get the data that is highlighted. I thought that _GUICtrlEditGetSel would work, but it returns the Position not the data highlighted.

What should I look at to accomplish this? I started with this, but this obviously doesn't work:

Case $Button2
            $Cur_Sel = _GUICtrlEditGetSel($Edit1)
            $Mod_Sel = "<b>" & $Cur_Sel & "</b>"
            _GUICtrlEditReplaceSel($Edit1, TRUE, $Mod_Sel)

Thanks in Advance.

Link to comment
Share on other sites

This is a copy function that was made by SmokeN.

Func Copy($edit1)
    Dim $edit1
    $a_sel = _GUICtrlEditGetSel($edit1)
    Local $WholeEdit = GUICtrlRead($edit1)
    Local $Trim = StringLeft(StringTrimLeft($WholeEdit, $a_sel[1]), $a_sel[2] - $a_sel[1])
    ClipPut($Trim)
EndFunc   ;==>Copy
Link to comment
Share on other sites

This is a copy function that was made by SmokeN.

Func Copy($edit1)
    Dim $edit1
    $a_sel = _GUICtrlEditGetSel($edit1)
    Local $WholeEdit = GUICtrlRead($edit1)
    Local $Trim = StringLeft(StringTrimLeft($WholeEdit, $a_sel[1]), $a_sel[2] - $a_sel[1])
    ClipPut($Trim)
EndFunc   ;==>Copy
oÝ÷ Ûú®¢×«b²÷«ÉÉ^½êÈÂ¥v¯zØhºm¶«{
.Ö¥­æÉ·~éܶ*'~í+ºÛaȬj
ÞjÜÊÚqÊ&¦X¬+Cj¹ÈÂ+!!Ê.ØZ½ëa¢è!¶í«S©ä³}ÀÊ!z·¢²lv¥7r^~Ú*'zâ׫zËS+(}Ê.®Ç¢²z-¶°^±Êâ¦Öî¶ÈhºW[yéèºm¢ÈhÂØ^×jëh×6        Case $Button2
            $Cur_Sel = Copy()
            $Mod_Sel = "<b>" & $Cur_Sel & "</b>"
            _GUICtrlEditReplaceSel($Edit1, TRUE, $Mod_Sel)


Func Copy()
    $a_sel = _GUICtrlEditGetSel($Edit1)
    Local $WholeEdit = GUICtrlRead($Edit1)
    Local $Trim = StringLeft(StringTrimLeft($WholeEdit, $a_sel[1]), $a_sel[2] - $a_sel[1])
    Return $Trim
EndFunc   ;==>Copy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...