How to not show the caret?

How to not show the caret?

Postby hua » Mon Mar 03, 2008 2:58 am

In a Get control where it's defined as Readonly, I don't want the caret to be shown at all. User should still be able to select and copy text within the control if they want to though. Experiments with ShowCaret()/HideCaret() yields negative result so far. Anyone has any suggestions?

TIA
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Postby Antonio Linares » Tue Mar 04, 2008 8:41 am

Hua,

HideCaret() should be enough.

Could you please provide a small example showing how you are doing it ? thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby hua » Thu Mar 06, 2008 3:04 am

Thanks for the reply Antonio. Here's the code.
Code: Select all  Expand view  RUN
// testmemh.prg

#include "FiveWin.ch"

#define STAT_DISP  "D"
#define STAT_EDIT  "E"

static cStat

function Main()

   local oDlg, oGet
   local cText := MemoRead( "testmemh.prg" )

   cStat := STAT_DISP

   define dialog oDlg resource "MemoEdit"

   redefine get oGet var cText memo id 104 of oDlg readonly

   redefine button id 101 of oDlg update  ;
     ACTION ( cStat := STAT_EDIT,         ;
              oGet:lReadOnly := .f.,      ;
              ShowHideCaret(oGet),        ;
              oGet:SetFocus()      )

   redefine button id 102 of oDlg update  ;
     ACTION ( cStat := STAT_DISP,         ;
              oGet:lReadOnly := .t.,      ;
              ShowHideCaret(oGet) )

   redefine button id 103 of oDlg update cancel ;
     ACTION oDlg:end()


   activate dialog oDlg centered ;
     on init ShowHideCaret(oGet)


return nil
//----------------------------------------------------------------------------//
function ShowHideCaret(oGet)

   if cStat == STAT_DISP
      HideCaret(oGet:hWnd)
   else
      ShowCaret(oGet:hWnd)
   endif

return nil


The rc file,
Code: Select all  Expand view  RUN
// testmemh.rc
MemoEdit DIALOG 18, 18, 231, 112
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MemoEditing"
FONT 8, "Arial"
{
EDITTEXT 104, 4, 6, 180, 85, ES_MULTILINE | ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Edit", 101, 191, 7, 36, 14
PUSHBUTTON "Save", 102, 191, 25, 36, 14
PUSHBUTTON "Cancel", 103, 191, 43, 36, 14
}


As you can see, everytime the mouse is clicked in oGet, irregardless of cStat, the caret will appear.

TIA
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 39 guests