Solved

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

Posted on 2006-06-09
9
257 Views
Last Modified: 2010-04-30
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
Comment
Question by:Spedley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16870769
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
 

Author Comment

by:Spedley
ID: 16872761
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
 

Author Comment

by:Spedley
ID: 16872870
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16873259
I couldn't see the usercontrol, but the 2 sizes in the caption and the printed value where always identical for me.
0
 

Author Comment

by:Spedley
ID: 16873510
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16873642
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
 

Author Comment

by:Spedley
ID: 16876887
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 16877532
please check out to multiply the ScaleWidth/scaleHeight by the Screen.TwipsPerPixelY/Screen.TwipsPerPixelY value.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question