PDA

View Full Version : [ActiveX] How to save a .mdi document?



Mika Vainio
29-Jan-2005, 04:40 PM
hi everybody

i would like to work with .mdi-documents in my application (former used .tif
files are getting to big). therefore i am using the "microsoft office
document imaging (modi) activeX control". i am just used to work with "easy
to understand" activex controls...

this is what i wanted to do to get some experience (example from ms-help):

Sub TestCreate()
Dim miDoc As MODI.Document

Set miDoc = New MODI.Document
miDoc.Create "C:\document1.tif"

miDoc.SaveAs "C:\document1.mdi", miFILE_FORMAT_MDI

Set miDoc = Nothing
End Sub

opening/creating the .tif document works. the thing that does not is the
"saveas"...
i did not understand the full structure of the .pkg file - there is the
activex class and there are some automation objects... how is this working?

can anybody help me?

best regards
mika

ps: here some code...

########## MDI.vw ##########
Object oMdi_View is a dbView
(...)
Object oComMiDocView1 is a cComMiDocView
INCLUDE_ACTIVEX_RESOURCE "Mdi.res" oComMiDocView1
Set Size to 172 234
Set Location to 5 6

Procedure OnCreate
Forward Send OnCreate

// ToDo: Set the ActiveX properties here...
End_Procedure // OnCreate
End_Object // oComMiDocView1

Object oButton1 is a Button
Set Label to "oButton1"
Set Location to 21 250

Procedure OnClick
Set ComFileName of oComMiDocView1 to "n:\trans\tiff\K10466.tif"
// Works ! ! ! :D
End_Procedure // OnClick
End_Object // oButton1

Object oButton2 is a Button
Set Label to "oButton2"
Set Location to 44 253

//AB-StoreStart
Procedure OnClick
// send ComSaveAs of oComMiDocView1
"n:\trans\tiff\K10466.mdi" -1 1 // Does not works ! ! ! :(

End_Procedure // OnClick
//AB-StoreEnd

End_Object // oButton2
CD_End_Object // oMdi_View


########## cComMiDocView.pkg ##########
(...)
// CLSID: {D4073843-A58A-469A-A8E2-CFF3FF77EE4E}
// IDocument Interface
Class cComIDocument is a Mixin

// method SaveAs
Procedure ComSaveAs String llFileName OLEMiFILE_FORMAT llFileFormat
OLEMiCOMP_LEVEL llCompLevel
Handle hDispatchDriver
Get phDispatchDriver to hDispatchDriver
Send PrepareParams to hDispatchDriver 3
Send DefineParam to hDispatchDriver OLE_VT_BSTR llFileName
Send DefineParam to hDispatchDriver OLE_VT_I4 llFileFormat
Send DefineParam to hDispatchDriver OLE_VT_I4 llCompLevel
Send InvokeComMethod to hDispatchDriver 4 OLE_VT_VOID
End_Procedure

(...)
End_Class

// CoClass
// ProgID: MODI.Document.1
// CLSID: {40942A6C-1520-4132-BDF8-BDC1F71F547B}
// Document Class
Class cComDocument is a cComAutomationObject
Import_Class_Protocol cComIDocument
Import_Class_Protocol cCom_IDocumentEvents

Procedure Construct_Object
Forward Send Construct_Object
Set psProgID to "{40942A6C-1520-4132-BDF8-BDC1F71F547B}"
Set psEventId to "{0CF31963-5E4D-4772-AE8D-82FE5A082B26}"
Set peAutoCreate to acNoAutoCreate
End_Procedure
End_Class

// CoClass
// ProgID: MiDocViewer.MiDocView.1
// CLSID: {EF347A62-BA21-42E4-94A0-1C0A6D7FDFE7}
Class cComMiDocView is a cComActiveXControl
Import_Class_Protocol cComIMiDocView
Import_Class_Protocol cCom_IMiDocViewEvents
// Import_Class_Protocol cComIDocument // no way :(

Procedure Construct_Object
Forward Send Construct_Object
Set psProgID to "{EF347A62-BA21-42E4-94A0-1C0A6D7FDFE7}"
Set psEventId to "{9028B775-EC59-4118-862A-EFDEAF5955A4}"
Set peAutoCreate to acDeferredAutoCreate
End_Procedure
End_Class

LasseJ
29-Jan-2005, 06:23 PM
Mika,

Without having seen the complete pkg generated I would guess you need to
create 2 objects in your view, one for viewing and one for other stuff (see
code):


########## MDI.vw ##########
Object oMdi_View is a dbView
(...)
//New object
Object oComDocument1 is a cComDocument
//This is where ComSaveAs is declared!!!
End_Object // oComDocument1

Object oComMiDocView1 is a cComMiDocView
INCLUDE_ACTIVEX_RESOURCE "Mdi.res" oComMiDocView1
Set Size to 172 234
Set Location to 5 6

Procedure OnCreate
Forward Send OnCreate

// ToDo: Set the ActiveX properties here...
End_Procedure // OnCreate
End_Object // oComMiDocView1

Object oButton1 is a Button
Set Label to "oButton1"
Set Location to 21 250

Procedure OnClick
Set ComFileName of oComMiDocView1 to "n:\trans\tiff\K10466.tif"
// Works ! ! ! :D
End_Procedure // OnClick
End_Object // oButton1

Object oButton2 is a Button
Set Label to "oButton2"
Set Location to 44 253

//AB-StoreStart
Procedure OnClick
// send ComSaveAs of oComMiDocView1
"n:\trans\tiff\K10466.mdi" -1 1 // Does not works ! ! ! :(
//CHANGE THIS TO
send ComSaveAs of oComDocument1 n:\trans\tiff\K10466.mdi" -1 1

End_Procedure // OnClick
//AB-StoreEnd

End_Object // oButton2
CD_End_Object // oMdi_View

/Lars J
"Mika Vainio" <mika@NO-SPAM-vainio.de> skrev i meddelandet
news:56DAoskBFHA.1912@dacmail.dataaccess.com...
> hi everybody
>
> i would like to work with .mdi-documents in my application (former used
..tif
> files are getting to big). therefore i am using the "microsoft office
> document imaging (modi) activeX control". i am just used to work with
"easy
> to understand" activex controls...
>
> this is what i wanted to do to get some experience (example from ms-help):
>
> Sub TestCreate()
> Dim miDoc As MODI.Document
>
> Set miDoc = New MODI.Document
> miDoc.Create "C:\document1.tif"
>
> miDoc.SaveAs "C:\document1.mdi", miFILE_FORMAT_MDI
>
> Set miDoc = Nothing
> End Sub
>
> opening/creating the .tif document works. the thing that does not is the
> "saveas"...
> i did not understand the full structure of the .pkg file - there is the
> activex class and there are some automation objects... how is this
working?
>
> can anybody help me?
>
> best regards
> mika
>
> ps: here some code...
>
> ########## MDI.vw ##########
> Object oMdi_View is a dbView
> (...)
> Object oComMiDocView1 is a cComMiDocView
> INCLUDE_ACTIVEX_RESOURCE "Mdi.res" oComMiDocView1
> Set Size to 172 234
> Set Location to 5 6
>
> Procedure OnCreate
> Forward Send OnCreate
>
> // ToDo: Set the ActiveX properties here...
> End_Procedure // OnCreate
> End_Object // oComMiDocView1
>
> Object oButton1 is a Button
> Set Label to "oButton1"
> Set Location to 21 250
>
> Procedure OnClick
> Set ComFileName of oComMiDocView1 to
"n:\trans\tiff\K10466.tif"
> // Works ! ! ! :D
> End_Procedure // OnClick
> End_Object // oButton1
>
> Object oButton2 is a Button
> Set Label to "oButton2"
> Set Location to 44 253
>
> //AB-StoreStart
> Procedure OnClick
> // send ComSaveAs of oComMiDocView1
> "n:\trans\tiff\K10466.mdi" -1 1 // Does not works ! ! ! :(
>
> End_Procedure // OnClick
> //AB-StoreEnd
>
> End_Object // oButton2
> CD_End_Object // oMdi_View
>
>
> ########## cComMiDocView.pkg ##########
> (...)
> // CLSID: {D4073843-A58A-469A-A8E2-CFF3FF77EE4E}
> // IDocument Interface
> Class cComIDocument is a Mixin
>
> // method SaveAs
> Procedure ComSaveAs String llFileName OLEMiFILE_FORMAT llFileFormat
> OLEMiCOMP_LEVEL llCompLevel
> Handle hDispatchDriver
> Get phDispatchDriver to hDispatchDriver
> Send PrepareParams to hDispatchDriver 3
> Send DefineParam to hDispatchDriver OLE_VT_BSTR llFileName
> Send DefineParam to hDispatchDriver OLE_VT_I4 llFileFormat
> Send DefineParam to hDispatchDriver OLE_VT_I4 llCompLevel
> Send InvokeComMethod to hDispatchDriver 4 OLE_VT_VOID
> End_Procedure
>
> (...)
> End_Class
>
> // CoClass
> // ProgID: MODI.Document.1
> // CLSID: {40942A6C-1520-4132-BDF8-BDC1F71F547B}
> // Document Class
> Class cComDocument is a cComAutomationObject
> Import_Class_Protocol cComIDocument
> Import_Class_Protocol cCom_IDocumentEvents
>
> Procedure Construct_Object
> Forward Send Construct_Object
> Set psProgID to "{40942A6C-1520-4132-BDF8-BDC1F71F547B}"
> Set psEventId to "{0CF31963-5E4D-4772-AE8D-82FE5A082B26}"
> Set peAutoCreate to acNoAutoCreate
> End_Procedure
> End_Class
>
> // CoClass
> // ProgID: MiDocViewer.MiDocView.1
> // CLSID: {EF347A62-BA21-42E4-94A0-1C0A6D7FDFE7}
> Class cComMiDocView is a cComActiveXControl
> Import_Class_Protocol cComIMiDocView
> Import_Class_Protocol cCom_IMiDocViewEvents
> // Import_Class_Protocol cComIDocument // no way :(
>
> Procedure Construct_Object
> Forward Send Construct_Object
> Set psProgID to "{EF347A62-BA21-42E4-94A0-1C0A6D7FDFE7}"
> Set psEventId to "{9028B775-EC59-4118-862A-EFDEAF5955A4}"
> Set peAutoCreate to acDeferredAutoCreate
> End_Procedure
> End_Class
>
>
>

Mika Vainio
29-Jan-2005, 07:32 PM
lars,

thanks for your help - now it worked out! :D

i had to add a link to the com object:

##### button2 #####
Procedure OnClick
variant var
get ComDocument of oComMiDocView1 to var
Set pvComObject of oComDocument1 to var
send ComSaveAs of oComDocument1 "n:\trans\tiff\K10466.mdi" -1 1
End_Procedure // OnClick

best regards,
mika


"Lars Jarnhäll" <LasseJ@oasystem.se> schrieb im Newsbeitrag
news:LCVGSmlBFHA.4336@dacmail.dataaccess.com...
> Mika,
>
> Without having seen the complete pkg generated I would guess you need to
> create 2 objects in your view, one for viewing and one for other stuff
> (see
> code):
>
>
> ########## MDI.vw ##########
> Object oMdi_View is a dbView
> (...)
> //New object
> Object oComDocument1 is a cComDocument
> //This is where ComSaveAs is declared!!!
> End_Object // oComDocument1
>
> Object oComMiDocView1 is a cComMiDocView
> INCLUDE_ACTIVEX_RESOURCE "Mdi.res" oComMiDocView1
> Set Size to 172 234
> Set Location to 5 6
>
> Procedure OnCreate
> Forward Send OnCreate
>
> // ToDo: Set the ActiveX properties here...
> End_Procedure // OnCreate
> End_Object // oComMiDocView1
>
> Object oButton1 is a Button
> Set Label to "oButton1"
> Set Location to 21 250
>
> Procedure OnClick
> Set ComFileName of oComMiDocView1 to "n:\trans\tiff\K10466.tif"
> // Works ! ! ! :D
> End_Procedure // OnClick
> End_Object // oButton1
>
> Object oButton2 is a Button
> Set Label to "oButton2"
> Set Location to 44 253
>
> //AB-StoreStart
> Procedure OnClick
> // send ComSaveAs of oComMiDocView1
> "n:\trans\tiff\K10466.mdi" -1 1 // Does not works ! ! ! :(
> //CHANGE THIS TO
> send ComSaveAs of oComDocument1 n:\trans\tiff\K10466.mdi" -1 1
>
> End_Procedure // OnClick
> //AB-StoreEnd
>
> End_Object // oButton2
> CD_End_Object // oMdi_View
>
> /Lars J