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
How to not show the caret?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Thanks for the reply Antonio. Here's the code.
The rc file,
As you can see, everytime the mouse is clicked in oGet, irregardless of cStat, the caret will appear.
TIA
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
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
}
TIA