Alex1986 Posted October 12, 2015 Share Posted October 12, 2015 (edited) HiI want help me about GetHicon From Bitmap , For create Cursor mousei write this Example on Vb.net :'_WinApi_CreateBitmap() Or GDI Create Bitmap = Autoti Dim bmCur As New Bitmap(60, 60) ' Create Graphic From Bitmap Similar _GDIPlus_ImageGetGraphicsContext($hBitmap) = Autoit Dim g As Graphics = Graphics.FromImage(bmCur) 'GDIPlus_CreatePen() = Autoit Dim blackPen As New Pen(Color.FromArgb(255, 1, 0, 6), 1) Dim X As Integer = 60 / 2 Dim Y As Integer = 60 / 2 '_GDIPlus_GraphicsDrawEllipse ( $hGraphics, $iX, $iY, $iWidth, $iHeight [, $hPen = 0] ) g.DrawEllipse(Pens.Red, X, Y, 1, 1) Dim X1 As Integer = 15 Dim Y1 As Integer = 15 g.DrawEllipse(blackPen, X1, Y1, 30, 30) 'Create Cursor/icon From Bitmap Dim ptrCur As IntPtr = bmCur.GetHicon Dim cur As Windows.Forms.Cursor cur = New Windows.Forms.Cursor(ptrCur) 'Change Cursor to New Me.Cursor = cur Edited October 12, 2015 by Alex1986 Link to comment Share on other sites More sharing options...
mLipok Posted October 12, 2015 Share Posted October 12, 2015 Please be more specyfic.What is your question ? Alex1986 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Alex1986 Posted October 12, 2015 Author Share Posted October 12, 2015 i want create cursor from bitmap , but I can't do it in Autoit Link to comment Share on other sites More sharing options...
Alex1986 Posted October 12, 2015 Author Share Posted October 12, 2015 (edited) this example#include <GDIplus.au3> $hGUI = GUICreate("" , 60 ,60 , -1 , -1 , -1 ) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hW = 60 , $hH = 60 $hBitmap = _GDIPlus_BitmapCreateFromGraphics($hW,$hH , $hGraphic) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hPen = _GDIPlus_PenCreate(0xFF0F0F0F , 2) $hX = $hW / 2 - $hW / 2 + 15 $hY = $hH / 2 - $hW / 2 + 15 _GDIPlus_GraphicsDrawRect($g_hGfxCtxt , $hX , $hY , 30 ,30 , $hPen) _GDIPlus_GraphicsDrawRect($g_hGfxCtxt , 60 / 2 , 60 / 2 , 1 ,1 ,_GDIPlus_PenCreate(0x99FF0000 , 2) ) _GDIPlus_GraphicsDrawImage($hGraphic , $hBitmap , 2 , 2) $icon = _GDIPlus_HICONCreateFromBitmap($hBitmap) ; { here stopped } Do Until GUIGetMsg() = -3i need create cursor and change to new cur Edited October 12, 2015 by Alex1986 Link to comment Share on other sites More sharing options...
Alex1986 Posted October 12, 2015 Author Share Posted October 12, 2015 Help Plz .. Link to comment Share on other sites More sharing options...
UEZ Posted October 12, 2015 Share Posted October 12, 2015 Try this:#include <GDIplus.au3> #include <WinAPIRes.au3> $hGUI = GUICreate("" , 260 ,260 , -1 , -1 , -1 ) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hW = 60 , $hH = 60 $hBitmap = _GDIPlus_BitmapCreateFromScan0($hW, $hH) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hPen = _GDIPlus_PenCreate(0xFF0F0F0F , 2) $hX = $hW / 2 - $hW / 2 + 15 $hY = $hH / 2 - $hW / 2 + 15 _GDIPlus_GraphicsDrawRect($g_hGfxCtxt , $hX , $hY , 30 ,30 , $hPen) _GDIPlus_PenSetColor($hPen, 0x99FF0000) _GDIPlus_GraphicsDrawRect($g_hGfxCtxt , 60 / 2 , 60 / 2 , 1 ,1 , $hPen) $icon = _GDIPlus_HICONCreateFromBitmap($hBitmap) Local $hPrev = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, 32512)) _WinAPI_SetSystemCursor($icon, 32512) Do Until GUIGetMsg() = -3 _WinAPI_SetSystemCursor($hPrev, 32512) _WinAPI_DestroyCursor($icon) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete() Alex1986 and mLipok 2 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
mikell Posted October 12, 2015 Share Posted October 12, 2015 (edited) An other one using _WinAPI_CreateIconIndirect, as described in the helpfile and here :http://www.codeguru.com/cpp/w-p/win32/cursors/article.php/c4529/Creating-a-Color-Cursor-from-a-Bitmap.htmexpandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIRes.au3> $hold_cursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor (0, $OCR_NORMAL)) ; Create XOR bitmap Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hXOR = _WinAPI_CreateCompatibleBitmapEx($hDC, 32, 32, 0) Local $hSv = _WinAPI_SelectObject($hMemDC, $hXOR) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH)) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_PEN)) Local $tRECT = _WinAPI_CreateRectEx(0, 1, 22, 22) _WinAPI_SetDCBrushColor($hMemDC, 0x0000FF) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, 11, 0) _WinAPI_SetDCBrushColor($hMemDC, 0x00FF00) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, -6, 9) _WinAPI_SetDCBrushColor($hMemDC, 0xFF0000) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_SelectObject($hMemDC, $hSv) _WinAPI_DeleteDC($hMemDC) ; Create AND bitmap $hDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hAND = _WinAPI_CreateBitmap(32, 32, 1, 1) $hSv = _WinAPI_SelectObject($hMemDC, $hAND) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH)) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_PEN)) _WinAPI_SetDCBrushColor($hMemDC, 0xFFFFFF) $tRECT = _WinAPI_CreateRectEx(0, 0, 33, 33) _WinAPI_Rectangle($hMemDC, $tRECT) _WinAPI_SetDCBrushColor($hMemDC, 0) $tRECT = _WinAPI_CreateRectEx(0, 1, 22, 22) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, 11, 0) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, -6, 9) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_SelectObject($hMemDC, $hSv) _WinAPI_DeleteDC($hMemDC) ; Create cursor Local $hnew_Cursor = _WinAPI_CreateIconIndirect($hXOR, $hAND, 0, 0, False) ; Free bitmaps _WinAPI_DeleteObject($hXOR) _WinAPI_DeleteObject($hAND) ; Create GUI $hGUI = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128) GUISetState(@SW_SHOW) _WinAPI_SetSystemCursor($hnew_Cursor, $OCR_NORMAL, 1) Do Until GUIGetMsg() = -3 _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL, 1) Edited October 12, 2015 by mikell Alex1986 1 Link to comment Share on other sites More sharing options...
KaFu Posted October 12, 2015 Share Posted October 12, 2015 This excellent UDF served me well ... Alex1986 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now