|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
hot to create cursors in c#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 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/msdn_transblt.asp http://support.microsoft.com/default.aspx?scid=kb;en-us;318876 Show quoteHide quote "ve" <v*@discussions.microsoft.com> wrote in message news:EE7CBF79-3AD1-42AA-BCB1-9A46A632B236@microsoft.com... > 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
Other interesting topics
Drag & Drop Folder Name from Windows Explorer to a Windows Form
Form Instance Problem with .net framework 1.1 german language pack Embedding IE inside a windows form, is it any sample code? ListView "small icon" display badly formatted run the win app.exe when the windows start Opening form from another .NET windows project Problem Debugging Need link to info about how to implement a DataGridComboBoxColumn CRYSTAL REPORTS VIEWER - URL REMOTING |
|||||||||||||||||||||||