Re: ShowCursor(FALSE) should hide cursor!
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Wed, 28 Dec 2005 10:52:07 -0600
On Tue, 27 Dec 2005 22:26:02 -0800, "Robby"
<Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>Although, I fully appreciate your post and I would like to confirm to myself
>that I am not absorbing this in a misleading way.
>
>The way I am understanding this, is that LoadCursor loads the specified
>cursor resource from the executable (.EXE) file associated with an
>application instance.
If it's a predefined cursor, e.g. IDC_ARROW, then it comes from the OS.
>(In plain english, it loads a cursor type for the
>current window!) Right!
The function LoadCursor does not have an HWND parameter, so that tells you
the cursor it loads is not associated with a window. The same can be said
for SetCursor. So, in what sense is a cursor associated with a window? A
window sets the cursor for the process that created it in response to
WM_SETCURSOR, and the cursor remains in effect for the process until
another window belonging to the process changes it.
>SetCursor, sets the cursor shape. The cursor must have been created by the
>CreateCursor function or loaded by the LoadCursor or LoadImage function.
>
>So, so far, load the cursor with LoadCursor and then set its shape! Right!
>
>ShowCursor, shows the cursor. If I say, ShowCursor(True) the internal
>display counter increments. If I say, ShowCursor(FALSE) the internal display
>counter decrements. And any time the counter is negative, the cursor is
>hidden.(I have experimented with this and I am surprised in that why Windows
>chose this mechanism. (Why not simply say, ShowCursor(True) shows the cursor
>and ShowCursor(FALSE) hides the cursor. Why must we add this "internal
>counter and hide if negative stuff!")
>
>Anyways, I am sure there is a reason, but right now it is beyond me!
It was really important back in the day when video cards didn't support the
cursor in hardware. A software cursor must be hidden before drawing over
the area where it resides, else you can get an effect known as "mouse
droppings":
http://catb.org/~esr/jargon/html/M/mouse-droppings.html
Suppose you had two drawing functions, one which renders the background and
the other the foreground. For safety reasons, each hides the cursor and
restores it when done. Now suppose you wrote this function:
void draw_everything()
{
draw_bk();
draw_fg();
}
This would cause the cursor to flicker. You could fix it by bracketing the
contents with hide/show cursor calls, but for that to work, the visibility
state needs to be reference-counted. (I believe Windows always did the
hiding/showing for you in BeginPaint/EndPaint, but other OS's did not.)
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: ShowCursor(FALSE) should hide cursor!
- From: Robby
- Re: ShowCursor(FALSE) should hide cursor!
- From: Alexander Grigoriev
- Re: ShowCursor(FALSE) should hide cursor!
- References:
- ShowCursor(FALSE) should hide cursor!
- From: Robby
- Re: ShowCursor(FALSE) should hide cursor!
- From: Doug Harrison [MVP]
- Re: ShowCursor(FALSE) should hide cursor!
- From: Robby
- ShowCursor(FALSE) should hide cursor!
- Prev by Date: Re: where is a copy of atlstr.h ??
- Next by Date: Re: Reading from Audio Buffer
- Previous by thread: Re: ShowCursor(FALSE) should hide cursor!
- Next by thread: Re: ShowCursor(FALSE) should hide cursor!
- Index(es):
Relevant Pages
- Re: convert hyperlink to email address
... If the Project Explorer is not showing, ... A blank window should open
up to the right. ... then you can close the VBE. ... won't be any changes (except
the flashing cursor moving down to the next ... (microsoft.public.excel.programming) - Re: Customising Word for Visually-Impaired
... the application will grab hold of the cursor and do its own thing with it. ...
perhaps a black-bordered window around the insertion point to draw attention ... But I've
found it impossible to get the handle of the Word window ... Control Panel> Accessibility
Options> Display> Cursor Width ... (microsoft.public.windowsxp.accessibility) - RE: hide cursor for kiosk application (powerpoint)
... you use a WebBrowser control to display ... PowerPoint document and you'd like
to hide the cursor on the WebBrowser. ... I watch the messages of the paneClassDC "Slide
Show" window. ... Microsoft Online Community Support ... (microsoft.public.dotnet.framework.windowsforms) - Re: Detecting button push
... David Olsson wrote: ... > I have a window with a number of buttons
(created using CreateWindow ... mouse button while the cursor is in the client area of
a window. ... Value of the high-order word of lParam. ... (microsoft.public.win32.programmer.ui) - Re: MFC: Drag & Drop ohne die Maus zu verwenden?
... >> system will direct mouse input to the specified window only if a mouse ...
> Prozess bekommt IMHO keine Nachricht das der Cursor über seinem Fenster ... Ich bin
da auf einen Artikel gestossen mit mouse_event, ... (microsoft.public.de.vc)