怎样不显示光标(100分)

  • 主题发起人 主题发起人 dialog
  • 开始时间 开始时间
D

dialog

Unregistered / Unconfirmed
GUEST, unregistred user!
在RICHEDIT中怎样不显示光标。(是光标而非鼠标)
 
重启再试。
 
理解错误,

你想达到什么目地?
 
richedit.setfocus;
 
呵呵, 这个我以前做过, 用api,
BOOL HideCaret(
HWND hWnd // handle to the window with the caret
);
procedure hideit;
begin
if hidecaret(richedit1.handle) then
showmessage('success');
end;
BOOL ShowCaret(

HWND hWnd // handle of window with caret
);
procedure showit;
begin
if showcaret(richedit1.handle) then
showmessage('success');
end;

要注意, 用几次hidecaret, 就要用几次showcaret.
 
cytown:
我也试过了,VB中可以,Delphi中没反应。

CreateCaret......
setCaretpos......
showCaret.......
也不行!
 
cytown的方法是对的。
不过要注意:
Whenever your application redraws a screen while processing a message
other than WM_PAINT, it must make the caret invisible by using the
HideCaret function. When your application is finished drawing,
redisplay the caret by using the ShowCaret function. If your
application processes the WM_PAINT message, it is not necessary to
hide and redisplay the caret, because this function does this
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
automatically.
~~~~~~~~~~~~~~

The following code sample shows how to have your application hide the
caret while drawing a character on the screen and while processing
the WM_CHAR message.

HWND hwnd, // window handle
HDC hdc; // device context

case WM_CHAR:
switch (wParam)
{
case 0x08:
.
. // Process a backspace.
.
break;

case 0x09:
.
. // Process a tab.
.
break;

case 0x0D:
.
. // Process a carriage return.
.

break;

case 0x1B:
.
. // Process an escape.
.
break;

case 0x0A:
.
. // Process a linefeed.
.
break;

default:
// Hide the caret.

HideCaret(hwnd);

// Draw the character on the screen.

hdc = GetDC(hwnd);
SelectObject(hdc,

GetStockObject(SYSTEM_FIXED_FONT));

TextOut(hdc, x, y, lpszChar, 1);

ReleaseDC(hwnd, hdc);

// Display the caret.

ShowCaret(hwnd);

}


If your application calls the HideCaret function several times
without calling ShowCaret, the caret will not be displayed until the
application also calls ShowCaret the same number of times.
 
通常一得到焦点就会有光标的,以前有过这问题,不过也没有圆满解决。要在多处放
置hidecaret.
 
procedure TForm1.RichEdit1Enter(Sender: TObject);
begin
if richedit1.focused then hidecaret(nil);
end;
 
后退
顶部