LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

text box

Hi all,
How can I get select text in text box? there is only ATTR_TEXT_SELECTION_START and ATTR_TEXT_SELECTION_LENGTH attribute.
Can everyone give a way how to get seltext buffer?
thanks.

By the way,how to clean clipboardtext after use ClipboardGetText()?

帖子被Denny.sh在08-25-2006 07:29 PM时编辑过了

0 Kudos
Message 1 of 6
(4,318 Views)
There are three different modes in which you can select text in CVI:
  1. Character Select Mode
  2. Line Select Mode
  3. Column Select Mode

The first of these modes is the most common and it allows the user to select characters; the second mode allows the user to select lines and the last mode allows the user to select rectangular block of text. You can toggle between the different modes by pressing Ctrl + Insert keys. The selection mode change often confuses people who press the keys by mistake. For more information about these modes, please refer to the CVI help documents.


 

The CVI textbox will show the selected text only when it has focus. So after you set the selection start and set the selection lenght you have to make sure that the texbox control has focus. Just call the function SetActiveCtrl(,,) after you set the selection, this should make the text box active and show the selected text.

0 Kudos
Message 2 of 6
(4,294 Views)
Hmm, I think elly.fan has misunderstood.

As far as I am aware you can only get the complete text, then extract the currently-selected part out of that.
--
Martin
Certified CVI Developer
0 Kudos
Message 3 of 6
(4,278 Views)
It's strange that ClipboardPutText(""); doesn't clear the text,: it just leaves the previous text unchanged.
 
You can get the selected text something like this using the ANSI C strncpy function:
 
    char selText[1024];
    char allText[1024];
    GetCtrlAttribute (panelHandle, PANEL_TEXTBOX,
         ATTR_TEXT_SELECTION_START, &selStart);
   GetCtrlAttribute (panelHandle, PANEL_TEXTBOX,
         ATTR_TEXT_SELECTION_LENGTH, &selLength);
   if (selLength>0)
   {
    
    GetCtrlVal (panelHandle, PANEL_TEXTBOX, allText);
    
    strncpy (selText, allText+selStart, selLength);
    selText[selLength] = '\0';
}
  else
    selText[0] = '\0';
Message 4 of 6
(4,269 Views)
Thanks.It can work now.
0 Kudos
Message 5 of 6
(4,252 Views)

wow, it's cool!

Haha, thank you for your gracious help!

0 Kudos
Message 6 of 6
(4,245 Views)