PDA

Click to See Complete Forum and Search --> : Line Control with Click Event


Elias
Mar 13th, 2000, 11:53 PM
Please Help!

I want to know how to create a line control with the same properties and events as a line in MS Word, or Powerpoint. When you click on the line, I want handle bars to appear, and be able to move the object around using the handle bars.

Extra brownie points for this one!

-Elias

Sam Finch
Mar 14th, 2000, 04:32 AM
This is actually surprisingly hard, it involves a technique called subclassing, subclassing is the VB equivalent of chainsaw juggling, i could explain the basics but i might as well just give you some chainsaws and a juggling book, If you go to the VB API site in th side bar there should be some in depth articles there or if you want I could post up the code for the control (I need all the subclassing practice i can get) but subclassing is a good techniqu to learn so if you're quite familiar with the API you should have a go.

If you know about subclassing the message you want to intercept is th WM_NCHITTEST Message the lparam is a C++ word copy this into an array of 2 integers using the copy memory API then put the 1st integer into the x of a POINTAPI structure and the 2nd into the Y value, then use the screentoclient API to convert these into usercontroll coords
if these coords are over one of your handles set the return value to HTTOPLEFT, HTTOP, HTTOPRIGHT etc depending on which handle you're over, these handles will then act like resize handles for your control. Remember to unsubclass the usercontrol before the program ends, you can do this safley by intercepting the WM_destroy message.

Otherwise just post up a message and I'll do it for you.

Elias
Mar 15th, 2000, 10:07 AM
Can I say waaaah? I don't want to touch API stuff yet. Can someone create a class module for me that I can use, I would rather not crash my system trying to learn API at this moment. It seems to me that there would be a 3rd party control, or an .dll that was compiled in VC++ or something that I can use.

Any more suggestions out there? I hated that last one. No offense Mr. Finch, but someone out there has had to do this before. Those tools are used in PowerPoint, Access, Excel, etc. ARGH!!!!


P.S. I emailed a friend of my girlfriend who wrote a VB Book. I will be sure to post his reply to this. Seriously, thank you Sam Finch for you response.

-Elias