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

Centering an Image Box

Status
Not open for further replies.

pozitron969

Programmer
May 14, 2002
29
0
0
US
Hello,

I wrote an ActiveX control that loads an image and tries to center the image box on the screen. Unfortunately it seems to be giving me odd results. Sometimes the image is centered (I think), others it will be centered on the right hand side of the image, and still others it will center the image on the left side of the image. I would like to match the center coordinates of the image with the center coordinates of the screen. I am not sure if this is any help but the control is loaded into a web browser. Am I overlooking something? Thank you very much.



Private Sub SetPicture(sPath As String)
Dim picHalfWidth, ctlHalfWidth, imgLeft As Integer
On Error Resume Next
Set imgImage.Picture = LoadPicture(sPath)
picHalfWidth = imgImage.Width / 2
cltHalfWidth = Screen.Width / 2
frmInfo.lblImg = imgImage.Width
frmInfo.lblScreen = Screen.Width
'imgLeft = Abs(ctlHalfWidth - picHalfWidth)
imgLeft = picHalfWidth - ctlHalfWidth
imgImage.Left = imgLeft
frmInfo.lblCalc = imgLeft
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top