Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inches to Pixel? 3

Status
Not open for further replies.

vbSun

Programmer
Dec 9, 2002
504
US
I just need some way to convert the inches measure to pixels. I am making a canvas with the inches measure, and i need to set the width and height of a picture box based on this.

Please help.

Thanks,
Sunil.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Set the scale mode of the picture box' container object to Inches. Your picture box height and width properties are now in inches...(they may not measure correctly on-screen, which is what a lot of the conversation here has been about, but will be on print-out)

e.g. if you have a form with a picturebox, the following will result in a picturebox that measures 2.5" x 2.5":


Private Sub Form_Load()
Me.ScaleMode = vbInches
Picture1.Width = 2.5
Picture1.Height = 2.5
End Sub
 
I got an error with your code on line...

MonitorKey = Left(strSubkey, InStr(strSubkey, Chr(0)) - 1)

Checked registry and key..

"System\CurrentControlSet\Enum\DISPLAY"

doesnt exist, under CurrentControlSet I have 'Control' and 'Services' Win98SE

 
As I said, it was a rough piece of code, quickly put together to illustrate a point, and was written for the NT family (because XP is what I happen to have at home). W98SE keeps the display info elsewhere. But I'm forward thinking, and try to make the code as flexible as possible so..wait one...um...OK, just change (I think; no W98 to test with here):
[tt]
DisplayKey = "System\CurrentControlSet\Enum\DISPLAY"
[/tt]
in the MonitorPeek Sub to:
[tt]
DisplayKey = "Enum\MONITOR"
[/tt]
 
Thanks strongm,

I managed to use image editing software (Adobe PhotoShop) to give me the conversion. They have the units inches and pixels, and i think they mean what i need.

strongm - We have a lot to learn from you !

Thanks,
Sunil.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top