Muhammad Faisal
Muhammad Faisal

Reputation: 155

Draw Rectangle around border less form

I am trying to draw rectangle around border less form by simply drawing lines around forms, but the problem is Form bottom and Form left lines are not drawn Here is a code use for drawing on Form_Paint

 Line (0, 0)-(ScaleWidth, 0), vbWhite  ' work
 Line (0, 0)-(0, ScaleHeight), vbWhite ' work
 Line (ScaleWidth, 0)-(ScaleWidth, ScaleHeight), vbWhite ' not working
 Line (0, ScaleHeight)-(ScaleWidth, ScaleHeight), vbWhite ' not working

form is re-sizable so drawing rectangle create a problem when i re-size form

Upvotes: 1

Views: 612

Answers (1)

SuperDre
SuperDre

Reputation: 194

Is there a reason why you need to draw the line yourself? you could use a shape control en resize it in Form_Resize.

Private Sub Form_Resize()
  Call shp.Move(0, 0, Me.ScaleWidth, Me.ScaleHeight)
End Sub

The reason Line draws one pixel to far has propably got to do with the fact it is 0 based, and in reality you want it to put the pixel at position ScaleWidth, which is 1 pixel beyond the screen, as ScaleWidth is '1 based'.. So if you do want to draw the line yourself you could use the following (if your scalemode is set to twips (the default)):

Line (0, 0)-(ScaleWidth - Screen.TwipsPerPixelX, ScaleHeight - Screen.TwipsPerPixelY), vbWhite, B

Upvotes: 2

Related Questions