In a MDI form you can't center picture/or any kind of objects... they always align to left, top, bottom, or right
Here's how I did it, you have to put a PictureBox on the form that is used as a temporary holder for the picture... (make the picture.Visible = False)
VB Code:
Option Explicit
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const swpFlags As Long = SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private LoadPic As StdPicture
Private Sub MDIForm_Load()
Set LoadPic = LoadPicture("C:\windows\winnt.bmp") ' change the path to your picture
Re: [RESOLVED] how to make a picture from a MDIparent centered?
Even though this thread have been marked as resolved I would like to add another solution. It's very simular to the one that CVMicheal posted but it doesn't require you to add a picture box on the MDI form during design time. Instead a picture box is created during run-time by adding it to the MDIForm controls collection. For some reason when you do that the control doesn't have to be aligned to one of the borders. It's a surprising little feature (or bug?) but makes it very interesting since you can now wrap it up in an easy to use class.
I quickly wrote a class that you find attached to this thread. To use it add code simular to this to your MDI Form.
VB Code:
Private oPic As CMDIPicture
Private Sub MDIForm_Load()
Set oPic = New CMDIPicture
'The Init method takes the MDI form and a standard picture object
'as argument. Instead of LoadPicture you can pass the Picture property of
'any PictureBox or Image control or load an image from a resource file.
oPic.Init Me, LoadPicture("c:\TheImage.jpg")
End Sub
That's it the rest is handled by the class in a very simular way CVMichael did.