Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2005

Tip: Looking for answers? Try searching our database.

hot to create cursors in c#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ve - 17 Aug 2005 18:47 GMT
Hi,

i want to create a cursor in c#. Basically i want to draw a rectangle whose
width changes dynamically. So i thought of creating a bitmap object of given
width and height and then get a graphics obejct out of it and fill the
rectangle with a specific color. So i will get an image object but i want to
create a cursor object from this one. Is there anyway to accomplish this?

thanks
vinod
Michael Phillips, Jr. - 17 Aug 2005 20:44 GMT
You must use InteropServices for the GDI32 functions.

You may use the Windows function CreateIconIndirect
to create your cursor.

You must create 2 bitmaps.  An AND bitmap and
a XOR bitmap.

Creating the AND bitmap is easy.  It is a monochrome
bitmap where you set the color for those areas
that are transparent in your source bitmap and clear
the color for those areas that are not transparent.

The XOR bitmap is more work  Once you have
drawn your source bitmap and decided what color
you want to be transparent, you create a bitmap
to represent the XOR mask.  Copy your source
bitmap to the XOR bitmap using BitBlt(SRCCOPY).
Then you take your AND mask bitmap and copy it
to your XOR mask bitmap using BitBlt(SRCINVERT)
and finally take your AND mask bitmap and copy it
to your XOR mask bitmap using BitBlt(SRCAND).

You now have 2 bitmaps in the requisite format
necessary to create you cursor.  Use CreatIconIndirect
specifying the HBITMAPS that you created.

The following articles will provide background:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnargdi/html/ms
dn_transblt.asp


http://support.microsoft.com/default.aspx?scid=kb;en-us;318876

> Hi,
>
[quoted text clipped - 9 lines]
> thanks
> vinod

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.