Oops.
How can we simulate the shaded mouse cursor like in Windows 2K?
I think it is done use Alphablending? Correct?
Printable View
Oops.
How can we simulate the shaded mouse cursor like in Windows 2K?
I think it is done use Alphablending? Correct?
What you mean?
in your game or in windows environment?
I mean through a Windows environment, like a personal app. I don't think Microsoft used DX to accomplish this, not?
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 don't want to change it, I want to reproduce it! Come on Parksie, you're smart, give me the algorithm...
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.
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.
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.
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 ;)
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.
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.
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
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! ;)
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.
hey, thats prety cool :)
but i still prefer my win2k shaded cursor
;)
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!
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.
Heh, cool! (Both of you :p )
Mad Compie, you should probably use the layering technique to allow us to use your cursor with other programs ;)
In Win2k, ASM was used for everything, I think. Therefore you will have to use some MOV statements and see what you get ;)
Heh, I think I saw a "in-line ASM for VB" demo at Planet Source Code ;)
This layering API is only for WIN2K, not for Win9x.
Ok, then he could use just the old "shaped form" APIs :)
Meaning: using a transparent form of let's say 32x32 as the screen cursor?
Why not, let's give it a try...
When it's done, don't forget to reply here ;)
It won't be for the next couple of hours.
Ok, no problem :)
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
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 :)
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 :eek:
Try passing it 0 as the handle, or get the handle of the desktop... something like that :)
Yes, the desktop DC is GetDC(GetDesktopWindow)
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?
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 :D
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.
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? :eek:
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 ;).
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! ...
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 ;)
You're right about the icon thing.
Yeah, but it's probably hard-coded into windows :(
So?... :D
I was kind of just thinking out loud, if a problem was with the cursor showing on the desktop DC :p
Overlaying windows in Win9x? It should be possible in VB, not?
Question is: how?
Any guru around?
Look, our problem here is grabbing the desktop's dc WITHOUT a window, not overlaying or anything :D
I think I have a quick fix BRB