How to make cursor image like this program?
http://www.filefront.com/14858479/La...%20Builder.rar
I want to make Launcher like this but i can't make it even with autoupdater ;[
Printable View
How to make cursor image like this program?
http://www.filefront.com/14858479/La...%20Builder.rar
I want to make Launcher like this but i can't make it even with autoupdater ;[
can you post a screenshot?
on the screenshot don't show mouse cursor
ok. here's how to do it:
this is the class that contains the CreateCursor function:
vb Code:
Imports System.Windows.Forms Imports System.Runtime.InteropServices Imports System.drawing ''' <summary> ''' contains API + local functions for creating ''' a cursor from a bitmap on the fly ''' </summary> ''' <remarks></remarks> Public Class create #Region " CreateIconIndirect" Private Structure IconInfo Public fIcon As Boolean Public xHotspot As Int32 Public yHotspot As Int32 Public hbmMask As IntPtr Public hbmColor As IntPtr End Structure <DllImport("user32.dll", EntryPoint:="CreateIconIndirect")> _ Private Shared Function CreateIconIndirect(ByVal iconInfo As IntPtr) As IntPtr End Function <DllImport("user32.dll", CharSet:=CharSet.Auto)> _ Public Shared Function DestroyIcon(ByVal handle As IntPtr) As Boolean End Function <DllImport("gdi32.dll")> _ Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Boolean End Function ''' <summary> ''' CreateCursor ''' </summary> ''' <param name="bmp"></param> ''' <returns>custom Cursor</returns> ''' <remarks>creates a custom cursor from a bitmap</remarks> Public Shared Function CreateCursor(ByVal bmp As Bitmap, ByVal xHotspot As Integer, ByVal yHotspot As Integer) As Cursor 'Setup the Cursors IconInfo Dim tmp As New IconInfo tmp.xHotspot = xHotspot tmp.yHotspot = yHotspot tmp.fIcon = False tmp.hbmMask = bmp.GetHbitmap() tmp.hbmColor = bmp.GetHbitmap() 'Create the Pointer for the Cursor Icon Dim pnt As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(tmp)) Marshal.StructureToPtr(tmp, pnt, True) Dim curPtr As IntPtr = CreateIconIndirect(pnt) 'Clean Up DestroyIcon(pnt) DeleteObject(tmp.hbmMask) DeleteObject(tmp.hbmColor) Return New Cursor(curPtr) End Function #End Region End Class
to use it:
vb Code:
me.cursor = CreateCursor(img, xHotspot, yHotspot)
the first code i must make it .dll ?
and do i need any picture ?
you just need to add a class + name it 'create', then you can paste the code into it.
you pass any bitmap to it. if you want transparent areas in the bitmap, use the bitmaps maketransparent method before you call the createcursor function.
edit: change it from Public class to Friend Class
i have problem i make what you sayd but when i start i get error
Error 1 Name 'CreateCursor' is not declared.
i make new class with the name that you say insert the text i removed lines 1 2 3 .. and ' and # that are and add in Form1_Load the code and the words are underlined or can you make a full program with that cursor only and share me
can you post the code you tried?
i have closed the project i don't keep it but can you make 1 program with only cursor that i need i will take a look in the source
here's how to use it:
thanks i see the code is alot diferent that you show me before
paul ... nice demo. I have a few questions:
1) will this work using an animated gif?
2) how can I display text instead of an image? ie. I would like the cursor to say "Please wait" while some time consuming process runs.
1/ probably not, but i haven't tried it. edit: it doesn't work with an animated gif
2/ Dim textSize As SizeF = Me.CreateGraphics().MeasureString("Please wait", Me.Font, Me.Size, Drawing.StringFormat.GenericTypographic)
Dim img As New Bitmap(CInt(textSize.Width) + 5, CInt(textSize.Height) + 1)
Dim gr As Graphics = Graphics.FromImage(img)
gr.Clear(Color.White)
gr.DrawString("Please wait", Me.Font, Brushes.Black, 0, 0)
img.MakeTransparent(Color.White)
Me.Cursor = create.CreateCursor(img, 0, 0)
Thanks ... works great!