FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to not show the caret?
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

How to not show the caret?

Posted: Mon Mar 03, 2008 02: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

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

How to not show the caret?

Posted: Tue Mar 04, 2008 08: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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

How to not show the caret?

Posted: Thu Mar 06, 2008 03:04 AM
Thanks for the reply Antonio. Here's the code.
// 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,
// 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
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion