ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Draw lines in a userform (https://www.excelbanter.com/excel-programming/303555-draw-lines-userform.html)

gbottesi

Draw lines in a userform
 
I need to draw oblique lines in a form, as you can do in VB using th
drawline tool, but I don't know how todo that in VBA since there´s n
drawline tool.
I saw a post with the same problem, solved by using 1-pixel-widt
labels, but its only works with horizontal al vertical lines

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Draw lines in a userform
 
while cumbersome, you could create a bitmap that appears as you wish and
have it as the background of the userform or use several with image
controls.

--
Regards,
Tom Ogilvy


"gbottesi " wrote in message
...
I need to draw oblique lines in a form, as you can do in VB using the
drawline tool, but I don't know how todo that in VBA since there´s no
drawline tool.
I saw a post with the same problem, solved by using 1-pixel-width
labels, but its only works with horizontal al vertical lines.


---
Message posted from http://www.ExcelForum.com/




Michel Pierron[_2_]

Draw lines in a userform
 
Hi gbottesi,
For the fun, in the userform module:
Option Explicit
Private Declare Function GetDC& Lib "user32" (ByVal hWnd&)
Private Declare Function LineTo& Lib "gdi32" (ByVal hDc& _
, ByVal x&, ByVal y&)
Private Declare Function MoveToEx& Lib "gdi32" _
(ByVal hDc&, ByVal x&, ByVal y&, lpPoint As POINTAPI)
Private Declare Function GetActiveWindow& Lib "user32" ()

Private Type POINTAPI
x As Long
y As Long
End Type

Private hDc As Long

Private Sub DrawLine(ByVal X1&, ByVal Y1&, ByVal X2&, ByVal Y2&)
Dim pt As POINTAPI
MoveToEx hDc, X1, Y1, pt
LineTo hDc, X2, Y2
End Sub

Private Sub UserForm_Activate()
hDc = GetDC(GetActiveWindow)
Dim i As Byte
DoEvents
For i = 1 To 10
DrawLine 8, 8, i * 30, (Me.InsideHeight * 4 / 3) - 8
Next i
End Sub

MP

"gbottesi " a écrit dans le message de
...
I need to draw oblique lines in a form, as you can do in VB using the
drawline tool, but I don't know how todo that in VBA since there´s no
drawline tool.
I saw a post with the same problem, solved by using 1-pixel-width
labels, but its only works with horizontal al vertical lines.


---
Message posted from http://www.ExcelForum.com/




Jon Peltier[_7_]

Draw lines in a userform
 
You can paste a drawing object into an image control. Copy the drawing
object, select the image control, click in the picture property in the
Properties pane (where it probably says (none), and paste. (none)
changes to (Metafile). Format the image control so it has no border and
a transparent background, and choose the Center PictureAlignment and the
Stretch PictureSizeMode.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Tom Ogilvy wrote:

while cumbersome, you could create a bitmap that appears as you wish and
have it as the background of the userform or use several with image
controls.




All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com