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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CENTER image in picturebox

Status
Not open for further replies.
As it stands your code is not doing anything like what you think it is doing.

Let's simplify.

Add a second picturebox to your form, set .Visible=False

Then try the following code:

Code:
[COLOR=blue]    Picture1.AutoRedraw = True
    Picture2.AutoSize = True
    Picture1.ScaleMode = vbPixels
    Picture2.ScaleMode = Picture1.ScaleMode [COLOR=green]' Ensure same scalemode for both[/color]
    Picture2.Picture = LoadPicture(("C:\Lavori_Vb6\TEST_MAPPA\PROVINCE\IMGPR\SU.gif"))
    Picture1.PaintPicture Picture2, (Picture1.ScaleWidth - Picture2.ScaleWidth) \ 2, (Picture1.ScaleHeight - Picture2.ScaleHeight) \ 2
    Picture1.AutoRedraw = False[/color]
 
tks!!!!
work

but a little question:

why you use \ instead /
 
Me? I was just following your code. But I'm guessing you didn't actually write your code from scratch, you got it from someone else and then tried to modify it to do what you needed, in which case you are wondering why that original code used \ rather than /

So here's an answer - you can't have 0.5 of a pixel, or twip ... the original code writer just wanted to make sure silly values were not sent to the PainPicture function (albeit paintpicture can handle silly values)
 
I like your answer that \ (rather than /) avoid "silly values" [wink]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top