Page 1 of 2 12 LastLast
Results 1 to 40 of 45

Thread: Shaded mouse cursor like Win2K

  1. #1

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Unhappy

    Oops.
    How can we simulate the shaded mouse cursor like in Windows 2K?
    I think it is done use Alphablending? Correct?

  2. #2
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    Question

    What you mean?
    jovton

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    in your game or in windows environment?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    I mean through a Windows environment, like a personal app. I don't think Microsoft used DX to accomplish this, not?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I think it's just a modification to the windows internals, so that when it draws the cursor it automatically does the alpha-blending on it.

    I don't think it's the sort of thing that it's possible to change.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    I don't want to change it, I want to reproduce it! Come on Parksie, you're smart, give me the algorithm...

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You wouldn't be able to properly reproduce it in Windows, but you could do it in your own programs by blitting a 32-bit image with alpha as the pointer.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    That's what I had also in mind. But it has to be a transparent Blt too. So, this could be a nice exercise for me using this new Alphablend API, combined with the familiar Blt operations.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    ALphablendin effects in win2k are done with a certain api that is dependent on the system i think, the cursor is also pretty deep into the system since it's the last thing that moves when i crash. But the algoritm isn't that hard, split up all color components, multiply by alpha component for source and 1-alpha for target and add them up. On the cursor thing, a fullscreen app would be ideal but blitting outside wouldn't.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    If it's in Windows, you could hide the real cursor and use a small window with the effect in its position.

    But in that case the alpha blending routine would have to be very fast... there's an API that automatically alpha-blends a window; by modifying the form's shape so it looks like a regular cursor and using that, you should get a different cursor

  11. #11
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    Hey Jotaf

    Do you have any code for the window alphablending?? I had one some time ago, but it didn't work, so I didn't work further on it.
    Sanity is a full time job

    Puh das war harter Stoff!

  12. #12

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Lightbulb

    Hi kids, I'm back again in my thread.
    I developed some code to simulate the a-blended (shaded ) mouse cursor.
    See the attached ZIP, it also includes the source code.
    Unfortunately, there's some flicker (guess the for-next loop 32x32 getpixel and setpixelv) but I did not had the time yet to solve this.
    I also think that I should use another mask (a coloured one) for the shadow effect.
    Attached Files Attached Files

  13. #13
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234
    Why dont you just get a cursor makin proggie, and make your own cursor with a shadow? Their is a program called Microangelo, available on http://www.downloads.com/

    It might not look as beutiful as muh lil win2k cursor, :P but it will look better then using vb to make a fake shadow.

    The shading is Win2k specific, cant be done without it, unless you make a program that fakes it :P
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  14. #14
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457

    Unhappy

    Ph34R: I'm sure he worked very hard on this, so you shouldn't make it look like a joke now.

    All he has to do is make that effect appear in a shaped (notice the "P" in "shaPed", it's not a "D" ) form, and voila!
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  15. #15

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Thanks Jotaf98!
    And Ph34R or something, my goal was to fake it, so I don't need this stupid MicroAngelo soft.
    By the way, the flicker is almost gone by using a look-up table.
    See the attached ZIP.
    Attached Files Attached Files

  16. #16
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234
    hey, thats prety cool

    but i still prefer my win2k shaded cursor

    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  17. #17
    New Member
    Join Date
    Aug 2001
    Location
    Australia
    Posts
    2

    Transparent Shadows

    Sorry people, but the transparent shadow uses a widely documented API known as 'Layered Windows' (Win2K or above, not Windows Me).


    TO MAKE A WINDOW LAYERED:


    public const WS_EX_LAYERED = &H80000

    SetWindowLong hWnd, GetWindowLong(hWnd, GWL_EXSTYLE) or WS_EX_LAYERED)


    TO MAKE A WINDOW TRANSLUCENT:

    public const LWA_COLORKEY = 1
    public const LWA_ALPHA = 2

    public declare function SetLayeredWindowAttributes(ByVal hWnd as long, byval crKey as long, byval bAlpha as byte, byval dwFlags as long) as long

    SetLayeredWindowAttributes hWnd, 0, 128, LWA_ALPHA


    If you set the second argument, crKey, and put 'or LWA_COLORKEY' at the end, this will make whatever color crKey is completely invisible (i.e. if you set crKey to 0 which is black, all black parts of the form will be invisible). By invisible it means two things: not drawn on screen, and not able to be clicked on (if you click on an invisible bit, the focus goes through to the window underneath).

    Enjoy!

  18. #18
    New Member
    Join Date
    Aug 2001
    Location
    Australia
    Posts
    2
    Oops! I stuffed up. Should be:


    public declare function SetLayeredWindowAttributes lib "User32" (ByVal hWnd as Long, ByVal crKey as Long, ByVal bAlpha as Byte, ByVal dwFlags as Long) as Long

    public declare function SetWindowLong lib "User32" (ByVal hWnd as Long, ByVal Index as Long, ByVal NewValue as Long) as Long

    public const WS_EX_LAYERED = &H80000
    public const LWA_COLORKEY = &H1
    public const LWA_ALPHA = &H2
    public const GWL_EXSTYLE = ? (Get from Api Text Viewer)

    private sub Form_Load()
    SetWindowLong hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) or WS_EX_LAYERED

    SetLayeredWindowAttributes hWnd, 0, 128, LWA_ALPHA

    end sub


    That's better.

  19. #19
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Heh, cool! (Both of you )

    Mad Compie, you should probably use the layering technique to allow us to use your cursor with other programs
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  20. #20
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In Win2k, ASM was used for everything, I think. Therefore you will have to use some MOV statements and see what you get
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  21. #21
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Heh, I think I saw a "in-line ASM for VB" demo at Planet Source Code
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  22. #22

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    This layering API is only for WIN2K, not for Win9x.

  23. #23
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Ok, then he could use just the old "shaped form" APIs
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  24. #24

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Meaning: using a transparent form of let's say 32x32 as the screen cursor?
    Why not, let's give it a try...

  25. #25
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    When it's done, don't forget to reply here
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  26. #26

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    It won't be for the next couple of hours.

  27. #27
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Ok, no problem
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  28. #28

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Lightbulb

    Well here it is!

    Some considerations:
    * it's not really a cursor: clicks and mouse events should be programmed too (perhaps with WaitAsyncKeyState)
    * i hide the system mouse cursor, but when you move the mouse fastly, it appears again for some ms
    Attached Files Attached Files

  29. #29
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hey, that's easy to solve, just make it so that the pixel where the mouse pointer is a "hole" (with the shaped form functions). It only has to be the size of a pixel
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  30. #30
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Oh, and that's a nice effect you have there

    And the HideCursor API doesn't work well because it only works inside your form, and when the user moves it too quickly the form is not always there. And it will stop working after you do what I told you above
    Try passing it 0 as the handle, or get the handle of the desktop... something like that
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  31. #31
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yes, the desktop DC is GetDC(GetDesktopWindow)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  32. #32

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    What a nice remark, Jotaf98!
    That works, but then i can't use the ShowCursor API anymore and the form won't have the focus anymore. I think I'll have to use an empty cursor shape as the default cursor shape.
    Also: when loading my app, I grap a copy of the desktop, but when the desktop changes (like some selection with the mouse), the memory DC does not change!
    Any suggestions?

  33. #33
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    The form doesn't need the focus to move! Aren't you using an API to get the mouse's position? If you take out that pixel and give ShowCursor the desktop's handle or 0, it should work and with no cursor flickering

    Easy, just bitblt directly from the DC you just got from the desktop instead of using a copy
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  34. #34

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    ShowCursor's parameter is not a hWnd or hDC!
    Besides, I also lose a pixel (upper left corner) from my arrow if I use this method, I can't redraw a dot because it is not part of the form.

  35. #35
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    With the right cursor, you won't have any problem with that pixel

    Oh sorry, I thought that ShowCursor would take a handle and hide the cursor there How the hell does it find out it's that form's handle?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  36. #36
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In the call back procedures that VB takes care of you it accesses it's hWnd of the thing that called it, quite complicated really (if you think about it too hard!) but a bit simple at the same time...

    Anyways, you need to fix the problem in your cursor, how that it takes the DC but it doesnt refresh, so that I had a winzip open, it's titlebar was green. I clicked elsewhere and the titlebar turned gray (that's the colour scheme for my computer ) and when I put the mouse over it, the titlebar showed through green.

    Ah, "Also: when loading my app, I grap a copy of the desktop, but when the desktop changes (like some selection with the mouse), the memory DC does not change! Any suggestions?"

    I see you've already spotted this problem .
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  37. #37

    Thread Starter
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Question

    That's correct Sastraxi!
    That's why I implemented only a single GetDC(0) to obtain the desktop once (=most simple way of programming). If it changes, the changes won't affect my cursor app.
    So, anybody knows how to grab permanently only some segment of the desktop?
    Or does there exists some API to control/create a real global user-defined cursor?

    A consideration: the same effect should be acchieved when U drag a desktop icon (full coloured) around the desktop => also in Win98! ...

  38. #38
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hum, you're right, if you grab the screen again you'll get the screen + your cursor

    Maybe you could hide it, grab the screen and show it again. If you don't do it too often (every second should be enough) it won't flicker
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  39. #39
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    You're right about the icon thing.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  40. #40
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Yeah, but it's probably hard-coded into windows
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width