How to hide the cursor

Dear Experts,

I have made a little example of a telnet-programm
it contains only a main menu and my component.
When you execute it you see only the mainmenu
and a black canvas with a white cursor on it.

But I want to hide the cursor and lock the canvas
when the programm startup or when I choose menu-
item Clear screen.

And show the cursor and unlock the canvas
when I choose menu-item Fill Buffer.

Who can help me? PLEASE.

The example is on my site:
http://members.home.nl/peterkiers/
(Beneath the Under Construction bar you see a floppy-disk)

Greetings,

Peter Kiers
LVL 1
peterkiersAsked:
Who is Participating?
 
diniludCommented:
procedure TMainForm.Clearscreen1Click(Sender: TObject);
begin
  MyDrawingPanelX1.CursorVisible:=not MyDrawingPanelX1.CursorVisible;
end;
0
 
ziolkoCommented:
try this:
ShowCursor(False)

ziolko.
0
 
ziolkoCommented:
note that if you call ShowCursor(False) twice and you want cursor visible again you have to call ShowCursor(True) also twice.
to ensure that cursor will be visible use this:

procedure TForm1.Button3Click(Sender: TObject);
var ref: Integer;
begin
  ref := ShowCursor(True);
  while Abs(ref) <> 0 do
    ref := ShowCursor(ref < 0);
end;


ziolko.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Russell LibbySoftware Engineer, Advisory Commented:
Peter,
You might want to only clear the cursor when its over you console like component. If you hide the cursor, then it does it for the whole app (menu items, etc) which may not be desireable.

eg:

procedure TMainForm.Clearscreen1Click(Sender: TObject);
begin

  // Check current cursor
  if (MyDrawingPanelX1.Cursor = crDefault) then
     // Clear cursor
     MyDrawingPanelX1.Cursor:=crNone
  else
     // Reset cursor back to default
     MyDrawingPanelX1.Cursor:=crDefault;

end;

---

Regards,
Russell
0
 
peterkiersAuthor Commented:
Hi,

procedure TMainForm.Clearscreen1Click(Sender: TObject);
begin
  // Check current cursor
  if (MyDrawingPanelX1.Cursor = crDefault) then
     // Clear cursor
     MyDrawingPanelX1.Cursor:=crNone
  else
     // Reset cursor back to default
     MyDrawingPanelX1.Cursor:=crDefault;
end;

When I test this the cursor doesn't dissapear.

P.
0
 
Russell LibbySoftware Engineer, Advisory Commented:
Did you bind the OnClick event of the menu item (Clearscreen1) to this procedure? I have tested this, and its the only explanation I can come up with. (place a debug break on the first code line and make sure it gets hit).

Russell
0
 
peterkiersAuthor Commented:
Yes.
0
 
diniludCommented:
Which cursor you want to hide
0
 
TNameCommented:
Peter, do you mean the application's cursor or the little white line/undescore -  the command-window-like cursor you set with DrawCursor() ?
0
 
peterkiersAuthor Commented:
The one on my component.

I may have found a solution to hide it
but how can I make it appear again?

To hide it :

procedure TMainForm.Clearscreen1Click(Sender: TObject);
 begin
 MyDrawingPanelx1.ClearCursor;
end;

procedure TMyDrawingPanelX.ClearCursor;
var
  xpos, ypos: integer;
begin
  if (Lastcursorx = -1) or (Lastcursory = -1) then exit;
  xpos := (Lastcursorx * FontWidthPix) - FontWidthPix;
  ypos := (Lastcursory * FontHeightPix) - 1;
  with Canvas do
  begin
    if csrShape = csrUnderLine then
    begin
      Pen.Mode := pmBlack;
      Pen.Color := ColorBlack;
      Brush.Style := bsSolid;
      Brush.Color := ColorBlack;
      MoveTo(xpos, ypos);
      LineTo(xpos + FontWidthPix, ypos);
    end
    else
    begin
      Pen.Mode := pmXor;
      Pen.Color := ColorBlack;
      Brush.Style := bsSolid;
      Brush.Color := ColorBlack;
      Rectangle(xpos, ypos - FontHeightPix + 1, xpos + FontWidthPix, ypos);
    end;
  end;
end;


P.
0
 
TNameCommented:
>Which cursor you want to hide
Oh I see dinilud noticed the same possible misunderstanding ;)
0
 
Russell LibbySoftware Engineer, Advisory Commented:
It would have helped if "cursor" was better defined in this q.
0
 
peterkiersAuthor Commented:
Sorry, my mistake.
0
 
diniludCommented:
change DrawCursor;

procedure TMyDrawingPanelX.DrawCursor(x, y: integer);
var
  xpos, ypos: integer;
begin

 if fCursorVisible then
 begin
  xpos := (CsrCol * FontWidthPix) - FontWidthPix;
  ypos := (CsrRow * FontHeightPix) - 1;
  with Canvas do
  begin
      if csrShape = csrUnderLine then
      begin
        Pen.Mode := pmWhite;
        Pen.Color := ColorWhite;
        Brush.Style := bsSolid;
        Brush.Color := ColorWhite;
        MoveTo(xpos, ypos);
        LineTo(xpos + FontWidthPix, ypos);
      end
      else
      begin
        Pen.Mode := pmXor;
        Pen.Color := ColorWhite;
        Brush.Style := bsSolid;
        Brush.Color := ColorWhite;
        Rectangle(xpos, ypos - FontHeightPix + 1, xpos + FontWidthPix, ypos);
      end;
  end;
 end;
 LastcursorX := CsrCol;
 LastcursorY := CsrRow;

end;
0
 
diniludCommented:
Change this also

procedure TMyDrawingPanelX.SetCursorVisible(const Value: boolean);
var
  oldvalue: boolean;
begin
  oldvalue := fCursorVisible;
  if value <> oldvalue then
  begin
    fCursorVisible := Value;
    if value then
      DrawCursor(CsrCol, CsrRow)
    else
      ClearCursor;
  end;
end;
0
 
peterkiersAuthor Commented:
WAUW, what help i am getting here.

I have test the application:

The showing and hiding cursor works fine.
But when I choose Connect a Connect-Dialog
screen appears, when i check Blinking cursor
and Cursor type Box I get exactly that after
pressing on the connectbutton, but then when
i choose Clearscreen, the cursor doesn't disappear
this time.

P.
0
 
peterkiersAuthor Commented:
Sorry, ignore my last comment.

It works fine...

Greetings,

Peter Kiers
0
 
diniludCommented:
procedure TMainForm.Clearscreen1Click(Sender: TObject);
begin
   MainForm.MyDrawingPanelx1.CursorFlashTimer.Enabled:=  not MyDrawingPanelX1.CursorVisible;
   MyDrawingPanelX1.CursorVisible:=not MyDrawingPanelX1.CursorVisible;
end;
0
 
peterkiersAuthor Commented:
Thank you for all the help.

Peter
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.