Custom Line Control... How?!

Volte
09-28-2001, 01:35 PM
OK - here's the deal. In my program, I want to use those cool 3D seperators like Microsoft's. I can always just use two line controls, but then I have to turn off grid, etc.

I made the 3D line control, but it draws like a box on the form. How do I make it draw in line form (like the real line control)?

Derek Stone
09-28-2001, 01:45 PM
Can you give us an example of what you're talking about?
Splitters? Or lines like the ones in an InstallShield setup program?
I believe I have an idea of what you're talking about but I just need it comfirmed.

Good Luck
-cl

Volte
09-28-2001, 01:53 PM
Line on the form, when you click and drag, right now it draws a box around the coords where you drag. I want it to draw a line from the starting point to the mouse cursor, as you move the mouse.

Derek Stone
09-28-2001, 02:09 PM
I have no idea how to do this with a control.
However it can be done using a simple module and some API.
Make a sub which accepts x and y coordinates and draws the line from there.
Alternatively you could make a control with no UI which draws the line using API.

<pre>Private Declare Function MoveToEx Lib "gdi32" _
(ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" _
(ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long

</pre>

Good Luck
-cl

Flyguy
09-29-2001, 12:33 AM
Maybe I don't understand what you mean, but ...

You talk about the turning of the grid, this is only when you are in design mode.
You can change to coordinates of the line to whatever you like.
In a program I used the following code to draw 2 lines beneath a Toolbar control.
<pre>
Private Sub Form_Resize()
Line2.Y1 = Toolbar1.Height + Screen.TwipsPerPixelY
Line2.Y2 = Line2.Y1
Line1.Y1 = Line2.Y1 + Screen.TwipsPerPixelY
Line1.Y2 = Line1.Y1
End Sub
</pre>

Derek Stone
09-29-2001, 09:18 AM
He is trying to create a custom line control.
Hence the subject of this thread.
He doesn't want to use the Line control which is included in VB, but instead he wants to create his own.

Regards,
-cl

Squirm
09-29-2001, 09:34 AM
I *think* he might be wanting to make the separator bar between two textboxes for example, and by moving the bar up and down, resizes the above and below textboxes. If the line drawing is drawing a box, it could be that the B setting has been included, which draws a box to the co-ordinates instead of a line:

<pre>Form1.Line (10,10) (20,20), ,B</pre>

That one draws it as a box.

<pre>Form1.Line (10,10) (20,20)</pre>

That one draws it as a line.

Volte
09-29-2001, 11:19 AM
no, no, that's not what I want. I just want a 3D line. That's it. Just have it draw like a line, instead of a box. I don't know if it's possible, but thanks anyway.

BillSoo
09-29-2001, 01:47 PM
I don't know if it will help, but you could try <a href="http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=visbas&Number=26160&page=&view=&sb=&o=&vc=1"> THIS POST</a>


"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

Derek Stone
09-29-2001, 03:47 PM
Check this out:
3D Line Control (http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=CodeLib&Number=53198&page=0&view=collapsed&sb=5&o=7&part=&vc=)

Good Luck
-cl

Volte
09-29-2001, 05:08 PM
Yes, that is basically it, but, that's what I already made. It may not be possible, so I'll just make do, I guess.

Squirm
09-29-2001, 05:14 PM
I'm just wondering what cool 3D separators like Microsoft you are talking about....

Volte
09-29-2001, 05:33 PM
like the ones in the menus, and the about boxes.

Squirm
09-29-2001, 05:46 PM
Ah - now I see........

klinky
01-03-2002, 01:37 PM
heehehe this is too little too late..but you can get a groovy looking 3D line by using the frame control,erasing the caption and stretching it as far as you need.Then set the height to 30 - 50.



klinky

divil
01-03-2002, 02:31 PM
Just use two line controls dude, thats what I do.

Hold down ctrl and shift while dragging the second one and you don't have to turn off grid alignment manually.

MPi
01-03-2002, 04:18 PM
You could also use something like a textbox, with a Font = SmallFont, FontSize = 2, 3D look and then resize the textbox the way you want.

just an idea.

Banjo
01-03-2002, 04:39 PM
divil - nice shortcut. I'm used to manually adjusting the settings in the properties window!

Shimms
01-03-2002, 10:34 PM
As am I :) Thanks divil.

As for the 3D Lines, we just use two lines, one that is coloured Button Shadow, and the other Button Highlight. The top line (the darker of the two) is one pixel above and to the left of the bottom line.

Hope this helps.

Garrett Sever
01-04-2002, 06:38 AM
Just to stop Volte from spontaneously combusting:

The line control isn't a true "control" much in the same way that the Label isn't a true control. It doesn't have a hWnd property, it can't be subclassed [LOL! :D], and is mostly some drawing instruction that the VB engine uses when drawing the forms DC.

Another possible API which you may want to look at is DrawEdge. A 3D line can be created by simply using BDR_SUNKENOUTER and BDR_RAISEDINNER (or EDGE_ETCHED) on one of the four sides of your RECT structure. That's what I do to create the seperator bars in my Menu Bitmap project. Granted, that's only if you want horizontal/vertical lines. For diagonal, you're gonna be out of luck.


Later.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum