how can i resize powerpoint presentation in my form?

A

assaf

hi all

i am displaying a powerpoint presentation inside my form.
when i resize the parent window,
the presentation [child] window moves to strange places.

how can i resize powerpoint presentation in my form?


here is the complete vb code:
you'll need to add a reference to:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\office.dll
and Interop.PowerPoint.dll


assaf


' the complete code - start

Option Strict Off
Option Explicit On
Friend Class frmSample
Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
Public Sub New()
MyBase.New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
Else
Try
'For the start-up form, the first instance created is the default
instance.
If
System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is
Me.GetType Then
m_vb6FormDefInstance = Me
End If
Catch
End Try
End If
End If
'This call is required by the Windows Form Designer.
InitializeComponent()
Form_Initialize_renamed()
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(Disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents _cmdShow_1 As System.Windows.Forms.Button
Public WithEvents lblMessage As System.Windows.Forms.Label
Public WithEvents frmSS As System.Windows.Forms.GroupBox
Public WithEvents _cmdShow_0 As System.Windows.Forms.Button
Public WithEvents cmdShow As
Microsoft.VisualBasic.Compatibility.VB6.ButtonArray
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me._cmdShow_1 = New System.Windows.Forms.Button
Me.frmSS = New System.Windows.Forms.GroupBox
Me.lblMessage = New System.Windows.Forms.Label
Me._cmdShow_0 = New System.Windows.Forms.Button
Me.cmdShow = New
Microsoft.VisualBasic.Compatibility.VB6.ButtonArray(Me.components)
Me.Splitter1 = New System.Windows.Forms.Splitter
Me.frmSS.SuspendLayout()
CType(Me.cmdShow,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'_cmdShow_1
'
Me._cmdShow_1.BackColor = System.Drawing.SystemColors.Control
Me._cmdShow_1.Cursor = System.Windows.Forms.Cursors.Default
Me._cmdShow_1.Dock = System.Windows.Forms.DockStyle.Top
Me._cmdShow_1.Font = New System.Drawing.Font("Arial", 8.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me._cmdShow_1.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdShow.SetIndex(Me._cmdShow_1, CType(1, Short))
Me._cmdShow_1.Location = New System.Drawing.Point(10, 35)
Me._cmdShow_1.Name = "_cmdShow_1"
Me._cmdShow_1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._cmdShow_1.Size = New System.Drawing.Size(324, 25)
Me._cmdShow_1.TabIndex = 3
Me._cmdShow_1.Text = "Show in a separate window"
'
'frmSS
'
Me.frmSS.BackColor = System.Drawing.SystemColors.Control
Me.frmSS.Controls.Add(Me.lblMessage)
Me.frmSS.Dock = System.Windows.Forms.DockStyle.Fill
Me.frmSS.Font = New System.Drawing.Font("Arial", 8.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.frmSS.ForeColor = System.Drawing.SystemColors.ControlText
Me.frmSS.Location = New System.Drawing.Point(10, 60)
Me.frmSS.Name = "frmSS"
Me.frmSS.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.frmSS.Size = New System.Drawing.Size(324, 215)
Me.frmSS.TabIndex = 1
Me.frmSS.TabStop = False
'
'lblMessage
'
Me.lblMessage.BackColor = System.Drawing.Color.Transparent
Me.lblMessage.Cursor = System.Windows.Forms.Cursors.Default
Me.lblMessage.Font = New System.Drawing.Font("Tahoma", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.lblMessage.ForeColor = System.Drawing.SystemColors.ControlText
Me.lblMessage.Location = New System.Drawing.Point(45, 112)
Me.lblMessage.Name = "lblMessage"
Me.lblMessage.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.lblMessage.Size = New System.Drawing.Size(231, 13)
Me.lblMessage.TabIndex = 2
Me.lblMessage.Text = "Please wait while the show is shutdown..."
Me.lblMessage.TextAlign = System.Drawing.ContentAlignment.TopCenter
Me.lblMessage.Visible = False
'
'_cmdShow_0
'
Me._cmdShow_0.BackColor = System.Drawing.SystemColors.Control
Me._cmdShow_0.Cursor = System.Windows.Forms.Cursors.Default
Me._cmdShow_0.Dock = System.Windows.Forms.DockStyle.Top
Me._cmdShow_0.Font = New System.Drawing.Font("Arial", 8.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me._cmdShow_0.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdShow.SetIndex(Me._cmdShow_0, CType(0, Short))
Me._cmdShow_0.Location = New System.Drawing.Point(10, 10)
Me._cmdShow_0.Name = "_cmdShow_0"
Me._cmdShow_0.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._cmdShow_0.Size = New System.Drawing.Size(324, 25)
Me._cmdShow_0.TabIndex = 0
Me._cmdShow_0.Text = "Show in a frame control"
'
'cmdShow
'
'
'Splitter1
'
Me.Splitter1.Dock = System.Windows.Forms.DockStyle.Top
Me.Splitter1.Location = New System.Drawing.Point(10, 60)
Me.Splitter1.Name = "Splitter1"
Me.Splitter1.Size = New System.Drawing.Size(324, 3)
Me.Splitter1.TabIndex = 4
Me.Splitter1.TabStop = False
'
'frmSample
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(344, 285)
Me.Controls.Add(Me.Splitter1)
Me.Controls.Add(Me.frmSS)
Me.Controls.Add(Me._cmdShow_1)
Me.Controls.Add(Me._cmdShow_0)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.DockPadding.All = 10
Me.Font = New System.Drawing.Font("Arial", 8.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Location = New System.Drawing.Point(3, 22)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmSample"
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Text = "#"
Me.frmSS.ResumeLayout(False)
CType(Me.cmdShow,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub
#End Region
#Region "Upgrade Support "
Private Shared m_vb6FormDefInstance As frmSample
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As frmSample
Get
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed
Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New frmSample()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set
m_vb6FormDefInstance = Value
End Set
End Property
#End Region
Const APP_NAME As String = "PowerPoint in VB window"

' PowerPoint Constants
Const ppShowTypeSpeaker As Short = 1
' Undocument constant used to display show in a window
' window any PowerPoint command bars
Const ppShowTypeInWindow As Short = 1000

Public oPPTApp As PowerPoint.Application
Public oPPTPres As PowerPoint.Presentation
Private _SlideShowWindow As PowerPoint.SlideShowWindow

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"(ByVal
lpClassName As String, ByVal lpWindowName As Integer) As Integer
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As
Integer, ByVal hWndNewParent As Integer) As Integer
Private Declare Function SetWindowText Lib "user32" Alias
"SetWindowTextA"(ByVal hwnd As Integer, ByVal lpString As String) As Integer


Private Sub cmdShow_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles cmdShow.Click
Dim Index As Short = cmdShow.GetIndex(eventSender)
Dim screenClasshWnd As Integer
On Error Resume Next
Me.oPPTApp = New PowerPoint.Application '
CreateObject("PowerPoint.Application")
If Not oPPTApp Is Nothing Then
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTApp.Presentations. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Me.oPPTPres = Me.oPPTApp.Presentations.Open("C:\Documents and
Settings\stud\Desktop\1111.ppt", , ,
Microsoft.Office.Core.MsoTriState.msoFalse)
If Not oPPTPres Is Nothing Then
With oPPTPres
Select Case Index
Case Is = 0
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
With .SlideShowSettings
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
.ShowType = ppShowTypeSpeaker
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Me._SlideShowWindow = .Run
With Me._SlideShowWindow
'UPGRADE_WARNING: Couldn't resolve
default property of object oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
.Width = VB6.FromPixelsX(frmSS.Width,
VB6.ScaleMode.Points)
'UPGRADE_WARNING: Couldn't resolve
default property of object oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
.Height = VB6.FromPixelsY(frmSS.Height,
VB6.ScaleMode.Points)
End With
End With
screenClasshWnd = FindWindow("screenClass", 0)
SetParent(screenClasshWnd, frmSS.Handle.ToInt32)
With Me
'.Height = VB6.TwipsToPixelsY(4545)
.Activate()
End With
Case Is = 1
'UPGRADE_WARNING: Couldn't resolve default
property of object oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
With .SlideShowSettings
'UPGRADE_WARNING: Couldn't resolve default
property of object oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
.ShowType = 1000
'UPGRADE_WARNING: Couldn't resolve default
property of object oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
.Run()
End With
Call SetWindowText(FindWindow("screenClass", 0),
APP_NAME)
End Select
End With
Else
MsgBox("Could not open the presentation.",
MsgBoxStyle.Critical, APP_NAME)
End If
Else
MsgBox("Could not instantiate PowerPoint.",
MsgBoxStyle.Critical, APP_NAME)
End If
End Sub

'UPGRADE_NOTE: Form_Initialize was upgraded to Form_Initialize_Renamed.
Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"'
Private Sub Form_Initialize_Renamed()
With Me
'UPGRADE_ISSUE: Constant vbPoints was not upgraded. Click for
more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2070"'
'UPGRADE_ISSUE: Form property frmSample.ScaleMode is not
supported. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2038"'
'VB6.ScaleMode.Points.ScaleMode = vbPoints
.Text = APP_NAME
End With
End Sub

'UPGRADE_WARNING: Form event frmSample.QueryUnload has a new behavior.
Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2065"'
Private Sub frmSample_Closing(ByVal eventSender As System.Object, ByVal
eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim Cancel As Short = eventArgs.Cancel
On Error Resume Next
lblMessage.Visible = True
System.Windows.Forms.Application.DoEvents()
If Not oPPTPres Is Nothing Then
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTPres.Close. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
oPPTPres.Close()
End If
'UPGRADE_NOTE: Object oPPTPres may not be destroyed until it is
garbage collected. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
oPPTPres = Nothing
If Not oPPTApp Is Nothing Then
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTApp.Quit. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
oPPTApp.Quit()
End If
'UPGRADE_NOTE: Object oPPTApp may not be destroyed until it is
garbage collected. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
oPPTApp = Nothing
lblMessage.Visible = False
eventArgs.Cancel = Cancel
End Sub

Private Sub frmSample_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize
If Me._SlideShowWindow Is Nothing Then
Return
End If
Me._SlideShowWindow.Top = 0
Me._SlideShowWindow.Left = 0
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Me._SlideShowWindow.Width = VB6.FromPixelsX(frmSS.Width,
VB6.ScaleMode.Points)
'UPGRADE_WARNING: Couldn't resolve default property of object
oPPTPres.SlideShowSettings. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Me._SlideShowWindow.Height = VB6.FromPixelsY(frmSS.Height,
VB6.ScaleMode.Points)
End Sub
End Class


' the complete code - end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top