pozitron969
Programmer
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
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