473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

VB6 Problem with Height and Width

2
Hello,

I have a code in which I set the size of the window before they are open, like that :

Public Sub Form_Load()
Me.width = 8160
Me.Height = 5970
Me.Show
End Sub

However, two days ago I bought a new computer with (new graphic card is matrox and old one was NVIDIA) and ever since I got this computer the size of the windows are totally different from what I set in "Form_Load". $



What can I do ?

Thanks in advance!!
Aug 20 '07 #1
7 31669
Robbie
180 100+
This is because you will be running at a different resolution.
What VB measures (Width and Height) and (Left and Top) in by default is called Twips. The ratio between a twip and a pixel differs depending on the display resolution of the computer which the program is run on.

What you need to do is tell it the size in pixels.
To do this, set the ScaleMode of the form to 3 - Pixel.
The two properties ScaleWidth and ScaleHeight will now be showing the width and height of the form in pixels.
But alas, you can't simply change ScaleWidth and ScaleHeight! VB Thinks you are changing the ratio between (Width and ScaleWidth) and (Height and ScaleHeight) if you try to do this.

Use this code to do it:
Expand|Select|Wrap|Line Numbers
  1. Me.Width = WidthInPixels * (Width / ScaleWidth)
  2. Me.Height = HeightInPixels * (Height / ScaleHeight)
  3.  
...where WidthInPixels and HeightInPixels are simply the width and height which you want the form to be. This way, the form will turn out to be the same width and height (in pixels) no matter what display resolution the program is run on.
Aug 20 '07 #2
redan
2
Hello Robbie,

Thanks!

So basically, If I want the size of the window to be 6000 by 8000 (height by width).

I have to do this.

Expand|Select|Wrap|Line Numbers
  1. Me.ScaleMode = vbPixels
  2. Me.ScaleHeight = 6000
  3. Me.ScaleWidth = 8000
  4.  
Is it correct ?
Aug 20 '07 #3
Robbie
180 100+
Hello Robbie,

Thanks!

So basically, If I want the size of the window to be 6000 by 8000 (height by width).

I have to do this.

Expand|Select|Wrap|Line Numbers
  1. Me.ScaleMode = vbPixels
  2. Me.ScaleHeight = 6000
  3. Me.ScaleWidth = 8000
  4.  
Is it correct ?
No, unfortunately you can't do it by changing the ScaleWidth and ScaleHeight. -_-
That won't change the size at all.
Use the little code example I gave before, at the bottom of my post.
You're going to need to work in pixels instead of twips though, and 6000 by 8000 pixels is unbelievably big. It's going to have to be nearer 600x800.
Just replace in my code where I put WidthInPixels with 600 and HeightInPixels with 800.
Expand|Select|Wrap|Line Numbers
  1. Me.Width = 600 * (Width / ScaleWidth)
  2. Me.Height = 800 * (Height / ScaleHeight)
Put that code there and you should see what I mean. Only change the 600 and 800 bit though, to what you want your form size to be, in pixels. Sorry that it seems we need to change from twips to pixels, but that's why I don't use twips, because the size they represent changes if your display resolution does, e.g. in 800x600, 1 twip is not the same size as it is in 1024x768
Aug 20 '07 #4
Killer42
8,435 Expert 8TB
I think you'll find Screen.TwipsPerPixelX and Screen.TwipsPerPixelY are a valuable source of information in this regard.
Aug 21 '07 #5
Robbie
180 100+
I think you'll find Screen.TwipsPerPixelX and Screen.TwipsPerPixelY are a valuable source of information in this regard.
Thanks Killer! That's really useful info.

Now Redan, if you could put your old graphics card back in =/, so you could find what Screen.TwipsPerPixel X/Y are with it, you could do this:

OldGraphicsTPPX = What Screen.TwipsPerPixelX is on your old graphics card
OldGraphicsTPPY = What Screen.TwipsPerPixelY is on your old graphics card

Then this would work on your old graphics card, new one, and any other one:

Me.Width = 8000 * (OldGraphicsTPPX / Screen.TwipsPerPixelX)
Me.Height = 6000 * (OldGraphicsTPPY / Screen.TwipsPerPixelY)

...unless Killer knows a better way which doesn't involve taking in and out graphics cards, hahaha... -_-;
Aug 21 '07 #6
Killer42
8,435 Expert 8TB
Well, I think all you need to know is what resolution was used before the switch. The actual card shouldn't matter.
Aug 21 '07 #7
Robbie
180 100+
Well, I think all you need to know is what resolution was used before the switch. The actual card shouldn't matter.
Yes, unless the old one was at a resolution which the new one can't do, or he just doesn't know what resolution was used. =/
Aug 22 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Ana | last post by:
I just ran a report on a site I'm redesigning and came up with all these missing height/width tags. How important are they? Should I go through the trouble of making sure they're there? Ana
2
by: Stephen Weatherly | last post by:
Could anyone please help me with a problem I am having with my table widths??? If I have 2 images within a td tag, but using CSS relative positioning I position one over the top of the second (I...
5
by: Dave Hammond | last post by:
You'd think this would be a basic part of the window object (and perhaps it is and I'm just being dense), but I can't find any reference in the IE window object documentation to a property which...
5
by: Linda | last post by:
Hi, I'm trying to get the Left/Top/Height/Width properties for some text boxes on a form to match exactly. Three of them are fine, but the fourth will not accept the changes I type into the...
1
by: Pums | last post by:
How to get the information(like height, width) of an image to be uploaded?
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
4
by: Hiwj | last post by:
I am having a problem with a cell in a table in ASP.NET which used to work OK in classic ASP. I have one cell in a row where the width should be 22 pixels and the other cell should take up the...
8
by: Kentor | last post by:
Hello, I have users that submit images to my website. By default I choose to make the width bigger than the height because usually pictures are taken horizontally... But in some cases people take...
1
by: Archana | last post by:
hi all, i am having one aspx page in wich i have 3 rows in table. first row has height 10% second has 70% and thrid has 20% in second row i am having another table which i have added in div tag...
15
dlite922
by: dlite922 | last post by:
I'm back again, Intro: I've got a floating div (outerDIV) with fixed width that contains an image (IMG) and a div that contains a short text (innerDIV) Problem: In FF, the innerDIV is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.