• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Why does my usercontrol not resize to fill the form with Visual Basic 6 ?

Adding the following code to Standard EXE project with one User Control I find that the control does not fill the entire form like I'd expect.  How do I fix this?

Private Sub Form_Resize()
   BackColor = 255 'change background color so that the user control can be seen
   UserControl11.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
0
Spedley
Asked:
Spedley
  • 4
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Private Sub Form_Resize()
   BackColor = 255 'change background color so that the user control can be seen
   UserControl11.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight
   doevents
End Sub
0
 
SpedleyAuthor Commented:
Unfortunately that doesn't change anything.

If I use Debug.Print Width in the user control it reports a different value to the Form using Debug.Print UserControl11.Width with the UserControl value being approx' 95% of the Form value.  I say approx' because it does vary slightly and the difference between the two also varies.
0
 
SpedleyAuthor Commented:
I've changed the code to include printing widths ...

In the Form:
Private Sub Form_Resize()
   BackColor = 255
   UserControl11.Move ScaleLeft, ScaleTop, ScaleWidth, ScaleHeight
   Caption = UserControl11.Width
End Sub

In the UserControl:
Private Sub UserControl_Paint()
   Cls
   Print Width
End Sub

Here is a link to a screen shot in case there is somethin I'm missing
http://www.cv32.com/cv32/VB6/Project1.GIF

Here is a link to the compiled program so you can see for yourself (if you trust me)
http://www.cv32.com/cv32/VB6/Project1.exe
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I couldn't see the usercontrol, but the 2 sizes in the caption and the printed value where always identical for me.
0
 
SpedleyAuthor Commented:
Thanks for that.  That means the problem must be my computer somehow?

This is what I get
http://www.cv32.com/cv32/VB6/Form1.GIF
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
is your windows configured to allow redrawing the form contents while resizing. I think that is what makes it not working, but i'm not sure.
0
 
SpedleyAuthor Commented:
It seems to be caused by having a different dpi setting in Windows (mine is currently set to 110% or 106pts instead of 96pts).  If I change it back to 100% and reboot the problem goes.
I can't believe no-one has come accross this before ??

Now I know what the problem is, the refined question is: Does anyone know how to make VB6 adjust to the current dpi settings?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please check out to multiply the ScaleWidth/scaleHeight by the Screen.TwipsPerPixelY/Screen.TwipsPerPixelY value.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now