views:

273

answers:

1

I want my program to work sort of like Team Player. Multi mice, multi cursor but only one focus. But the problem is I can't hide the default cursor. I only want it to be invisible. So far this works inside my application only.

ShowCursor(false);

and

Screen.Cursor:=crNone;

Is there a way to hide the cursor for the entire system (just until I close my application)?


EDIT: This doesn't work:

procedure myShowCursor(Show :boolean);
var cursor1, cursor2: HCursor;
begin
 cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('blank\blank.cur');
 if Show then
  SetSystemCursor(cursor1, OCR_NORMAL)
 else
 SetSystemCursor(cursor2, OCR_NORMAL);
end;

This works: (but I can't exactly use this)

procedure myShowCursor;
var cursor1, cursor2: HCursor;
begin
 cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('blank\blank.cur');

 SetSystemCursor(cursor2, OCR_NORMAL);
 SetSystemCursor(cursor1, OCR_NORMAL)
end;

SOLVED: restored system cursors by SystemParametersInfo

procedure TForm1.myShowCursor(Show :boolean);
var cursor1: HCursor;
begin
 cursor1 := LoadCursorFromFile('blank\blank.cur');
 if Show then
  SystemParametersInfo(SPI_SETCURSORS,0,0,WM_SETTINGCHANGE or SPIF_UPDATEINIFILE )
 else
 SetSystemCursor(cursor1, OCR_NORMAL);
end;
+2  A: 

first download a blank cursor, you can get it from many places,i downloaded it from http://pc.autons.net/stuff/blanks/blank.zip ,extact blank.zip then copy and paste blank.cur to a desired location(i am saving it to 'c:\blank.cur' for this example) then try this code:

var cursor1, cursor2: HCursor;
begin
 cursor1 := CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('c:\blank.cur');
 SetSystemCursor(cursor2, OCR_NORMAL);//to hide cursor
 Sleep(2000);
 SetSystemCursor(cursor1, OCR_NORMAL);//to show cursor again
end;

hope this helps

Omair Iqbal
Thanks heaps...! just one more thing. I can't show the default cursor again. I tried that last part but it didn't work.
Dian
its working on my computer,maybe you are using cursor variables outside their scope(in other event handlers i.e you have declared them in this eventhandlers but you are redeclaring and calling them and the last part from say applicationOnClose event), try declaring 'cursor1, cursor2' in the units implementation section and see if the last part work now?
Omair Iqbal
tip: use GetCursor() instead CopyIcon
histrio
@omair: See my edits. Nope, not using them outside the scope.@histrio: okay, I will try. Thanks.
Dian
No luck with GetCursor() though LoadCursor(0, IDC_UPARROW) did well for everything except IDC_ARROW. :C
Dian
Solved it. Thanks for your help. :D
Dian