Page 1 of 1
How to not show the caret?
Posted: Mon Mar 03, 2008 2:58 am
by hua
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
Posted: Tue Mar 04, 2008 8:41 am
by Antonio Linares
Hua,
HideCaret() should be enough.
Could you please provide a small example showing how you are doing it ? thanks,
Posted: Thu Mar 06, 2008 3:04 am
by hua
Thanks for the reply Antonio. Here's the code.
Code: Select all
// 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
// 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