• June 11, 2019 04:44

    #1Cursor Byte

    Thread launcher

    fanatical dick

    Create And Load A Cursor From A Byte Array.


    Hello everyone

    Below may be a .cur data byte dump.

    I want to store those bytes in an array instead of bytes, re-create the cursor and just get a handle to it so I can pass the handle to the SetCursor API.

    I know I can get that cursor handle using this LoadCursorfromFile API, but I don’t want to use a file. I want the cursor to be loaded from a byte array in memory.

    Greetings.

    The cursor sends a dump.

    Code:

    00 00 02 00 01 double zero 20 20 10 00 0c 50 01 00 e8 02
    00 00 fourth error 16 00 00 00 28 00 double zero 00 20 00 00 00 forty 00
    00 00 01 00 04 double zero 00 00 00 00 80 10 00 00 00 00
    00 00 50 00 00 00 00 00 double zero 00 00 00 00 00 50 00
    00 00 00 00 80 50 00 80 00 00 00 81 80 00 80 00
    00 00 ninety 00 80 00 80 80 double zero 00 80 80 80 double zero c0 c0
    c0 00 00 00 ff double zero 00 ff 00 00 double nOl ff ff 00 ff 00
    00 double zero ff 00 ff 00 ff ff double zero 00 ff ff ff 00 50 00
    00 00 00 00 00 double zero 00 00 00 00 00 50 00 00 00 00
    00 00 double zero 00 00 00 00 00 double zero 00 00 00 00 00 double zero 00
    00 00 00 00 00 50 00 00 00 00 00 50 00 00 00 00
    00 00 50 00 00 00 00 00 50 00 00 00 00 00 double zero 00
    00 00 00 00 00 double zero 00 00 00 00 00 50 00 00 00 00
    00 00 50 00 00 00 00 00 double zero 00 00 00 00 00 50 00
    00 00 00 00 00 double zero 00 00 00 00 00 double zero 00 00 00 00
    00 00 50 00 00 00 00 00 double zero 00 00 00 00 00 50 00
    00 00 00 00 00 50 00 00 00 00 00 50 00 00 00 00
    00 00 50 00 0f ff ff f8 double zero 00 00 00 00 00 50 00
    00 00 00 00 off off off off 80 00 00 50 00 00 00 00
    00 00 50 0f ff ff ff ff ninety 00 00 00 00 00 double zero 00
    00 00 00 ff ff ff ff ff f8 00 00 double zero 00 00 00 00
    00 00 double zero ff ff ff ff ff f8 50 00 00 00 00 double zero 00
    00 00 0f ff ff ff ff ff f8 00 00 50 00 00 00 00
    00 50 0f ff ff ff ff ff ff 50 00 00 00 00 50 00
    00 00 ff ff ff ff ff ff 80 00 50 00 00 00 00
    00 50 ff 88 ff ff ff ff ff forty 00 00 00 00 double zero 00
    00 0f f8 00 ff ff ff ff ff 80 00 double zero 00 00 00 00
    00 0f 82 00 ff ff ff ff 7f 40 00 00 00 00 double zero 00
    00 f8 00 00 ff 7f f7 f8 0f 80 00 50 00 00 00 00
    00 00 double zero 00 f8 0f 80 f8 0f 50 00 00 00 00 50 00
    00 00 00 00 f8 0f 50 f8 00 00 00 double zero 00 00 00 00
    00 00 double zero 00 f8 0f 80 f8 50 00 00 00 00 00 double zero 00
    00 00 00 00 f8 0f seventy-eight 00 00 00 00 double zero 00 00 00 00
    00 00 50 00 f8 00 00 00 50 00 00 00 00 00 double zero 00
    00 00 00 00 f8 50 00 00 00 00 00 50 00 00 00 00
    00 00 50 00 f800 00 00 50 00 00 00 00 00 double zero 00
    00 00 00 00 f8 50 00 00 00 00 00 50 00 00 00 00
    00 00 50 00 f8 00 00 00 50 00 00 00 00 00 50 00
    00 00 00 00 00 double zero 00 00 00 00 00 double zero 00 00 00 00
    00 00 double zero 00 00 00 00 00 double zero 00 00 00 00 50 ff ff
    ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff ff ff ff ff ff ff f8
    07 ff ff f0 year 2007 ff ff e0 03 ff ff c0 drive ff ff 80
    01 ff ff 85 01 ff ff 00 06 ff ff 00 00 ff next 00
    00 ff fe 00 double zero ff fc 00 00 ff fc to 20 00 ff f8 60
    00 ff fc e0 00 ff ff e0 08 ff ff e0 07 ff ff e0
    0f ff ff e0 7f ff ff e1 ff ff ff e1 ff ff ff e1
    ff ff ff e1 ff ff ff f3 ff ff ff ff ff ff

  • June 11, 2019 06:51

    #2

    Re: Create A Cursor From An Array Of Bytes And Just Load It.

  • June 11, 2019 at 2:46 pm.

    #3<а

    Re: Name=”3″> Create, Not To Mention A Byte Array. To Load Cursor


    Sorry, this affects this thread, but it’s possible to create a mouse suggestion image from any bitmap I support and the size of the bitmap.

  • June 10, 2019 at 4:35 pm.#4

    Thread Launcher

    fanatical dick

    Re: Create And Load Cursor Provided By Byte Array.

    Originally published

    Trick

    Thanks for the tip.

    I didn’t know about this handy API function CreateIconFromResourceEx.

    However, this only works for PNG files, not .ICO and/or .CUR
    files

    Also, contrary to what the documentation says, there is actually no need to work with the cursor or icon, and then you can usually access the SetCursor API

    Below is the final code that uses the CreateIconFromResourceEx API to create a handle from a png (hand.png) file I purchased online.

    The LoadPNGtoICO aspect successfully returns an IPicture object, and in doing so, it can also be passed to this DrawIcon API that draws a popular DC, BUT the following does not immediately work:

    I need to dynamically call the SetCursor API on a form’s mouse gesture event.

    This code works No for creating an IPicture object and using the DrawIcon API, BUT does not work for some types of the SetCursor API.


    Code:

    Explicit option

    Private type uPicDesc
    the waist is so long
    Enter until
    hPic so long
    hello so long
    end type

    private type GUID
    data1 so long
    data2 as integer
    data3 as integer
    Data4 (0 to 7) in bytes
    end type

    CreateIconFromResourceEx Lib private declaration function "user32.dll" (preset bits ByRef As Any, ByVal dwResSize As Long, ByVal As fIcon Long, ByVal dwVer As Long, ByVal cxDesired As Long, ByVal cyDesired As Long, ByVal Flags As Long) As Long
    OleCreatePictureIndirect Lib private statement function "OleAut32.(lpPictDesc dll" As Any, riid As Any, ByVal fPictureOwnsHandle As Long, Ipic As IPicture) As Long
    CopyImage Lib private operator function "user32" (ByVal supports As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
    DestroyIcon Lib private declaration function "user32.dll" (ByVal hIcon As Long) As Long
    DrawIcon Lib "user32" private declaration function (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    GetDC Lib private declaration function "user32" (ByVal hwnd As Long) As Long
    ReleaseDC Lib private declaration function "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

    Private constant vbPicTypeIcon As Long = 3
    Private hIcon for now hCopy for now

    in privatedke