This project is read-only.

GDIPlusX - Rubberband

Topics: General, Attention VFPX Admins
Mar 8, 2008 at 12:21 PM
I would like to create a rubber-band, as we know it from many graphical applications, Allowing the user to select several items within a certain area. The "certain area" in this case is an ActiveX - Control, making it a bit more tricky.
I think this could be accomplished using the GDIPlus, Any ideas how to start and where to look at?

Thanks a lot

F.
Mar 8, 2008 at 5:28 PM
To get you started, you may look at the following webpage from Craig Boyd , his site is full of amazing VFP code, worth every minute you spend on it :

http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,de3b099f-bca6-471e-89bf-ae094b823780.aspx

Cheers

Victor
Mar 9, 2008 at 12:21 AM
Edited Mar 9, 2008 at 12:22 AM
You are right the ActiveX is going to be tricky. In VFP, ActiveX controls are in their own client window. Any drawing you do with GDIPlusX is probably going to be in a VFP window or using the imgCanvas object. In this case all drawing command will be behind the ActiveX control.

One solution might be to create a client window, on top of all other client windows and use GDIPlusX to draw to that top window. The tricky part with this is you are probably going to loose your mouse events down to VFP. If you are only worried about the active rubberband, then you may not care. Otherwise you will have to pass the client window mouse events to the parent VFP window.

I haven't tried this myself, but it would be an interesting project.
Mar 9, 2008 at 8:29 AM
Victor,
To get you started, you may look at the following webpage from Craig Boyd , his site is full of amazing VFP code, worth every minute you spend on it :...

Thanks, Yes, his blog is fabulous. Just read in it yesterday and still have the browser open with the article on Aero glass effects.

I'll have a look and see if it gets me started.

F.
Mar 9, 2008 at 9:05 AM

You are right the ActiveX is going to be tricky. In VFP, ActiveX controls are in their own client window Any drawing you do with GDIPlusX is probably going to be in a VFP window or using the imgCanvas object. In this case all drawing command will be behind the ActiveX control.
One solution might be to create a client window, on top of all other client windows and use GDIPlusX to draw to that top window. The tricky part with this is you are probably going to loose your mouse events down to VFP. If you are only worried about the active rubberband, then you may not care. Otherwise you will have to pass the client window mouse events to the parent VFP window.

Yes, I know about the ActiveX issues. In this particular case I will need the rubber only within the ActiveX-Control. It's something different, but You could imagine it as selecting a bunch of nodes in a treeView-control. All I need is the coordinates of the rectangle and the visual feedback for the user during selection. Once I have these bounds, I can start to fiddle out which items are in that area and mark them selected.


I am capturing the CTRL-key to switch into "selection mode", One of my ideas was, like Yours, to create a transparent form over the control and work on that, as soon as the user presses CTRL. I'm not sure if I will be able to make that work ... maybe top-level form with almost no opacity....I'll need to play with that. Just started thinking of it more concrete.

Another Idea would be employing VFP 9's bindEvent() and capture all mouse messages... see if that would work

If I could make it with the topLevel-Form, I could emplay Craig's Rubber-class, victor pointed me to....
Mar 9, 2008 at 1:43 PM

OK, I now have an almost transparent form that appears and adjusts perfectly to the ActiveX-Control's client-area as soon as I press CTRL. Within the "layer" I capture WM_KEYUP Windows-Messages via bindEvent() and hide the layer and reset focus back to the control as soon as the User releases CTRL without having MouseDowned.

Works like a charm. Now I could employ Craig's rubber or something similar. However, as the form ist transparent, my rubber is also :-D
Mar 9, 2008 at 3:48 PM
Update

Wow! I remembered my Resze-Corner ( "The LittleLowerRightCorner" in the Universalthread.com - http://www.universalthread.com/wconnect/wc.dll?2,54,33,25353 ) which I did a few years ago with the help of Herman Tan, where I do something similar, directly painting into a DeviceContext. With only some minor changes now this code works great, even on my transparent layer.

If anyone is interested in this, I could make it a general class or post more infos and code.

Thanks for Your quick responses

F.
Mar 10, 2008 at 3:30 AM

If anyone is interested in this, I could make it a general class or post more infos and code.

It sounds very cool. I'd like to see it.
Mar 10, 2008 at 6:27 AM
Hi F ... I downloaded your LittleLowerRightCorner class from the UT ... really cool code ... I've seen a similar solution by Carlos Alloatti in his Gripper Class
you can see it at: http://www.ctl32.com.ar/ctl32_gripper.asp

Anyway, I would also like to see it your solution for Rubberband project ..

Thanks

Victor
Mar 10, 2008 at 8:58 AM

I downloaded your LittleLowerRightCorner class from the UT ... really cool code ... I've seen a similar solution by Carlos Alloatti in his Gripper Class ....

Yes, I've also seen it. He is doing great stuff. I think he employs VFP9's bindevent() for it, which we did not have when I did the LittleLowerRightCorner.

Anyway, I would also like to see it your solution for Rubberband project ...

Yes, I'll need to finish some other things first. Then I can beautify and make it a class. What I did yesterday was a really dirty try-and error-solution

I'll come back to both of You soon

F.