• Welcome to Jose's Read Only Forum 2023.
 

Outlook.Inc help

Started by Jim Dunn, May 14, 2010, 04:41:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jim Dunn

José,

I feel I'm very close to understand COM... but need a little help...

I created an OUTLOOK.INC from your TypeLib Browser 4.0.14 (attached) but get an error when I try to compile the following code.

The error is "Undefined Type: IFontDisp"...

Please help!  : (
Jim

'sed_pbcc

#COMPILER PBCC

#COMPILE EXE
#DIM ALL
'#INCLUDE "windows.inc"
#INCLUDE "outlook.inc"

FUNCTION PBMAIN () AS LONG

LOCAL objOutlook AS Outlook_Application
LOCAL objNS AS Outlook_NameSpace
LOCAL objContacts AS Outlook_MAPIFolder
LOCAL objItems AS Outlook_Items
LOCAL objOneContact AS Outlook_ContactItem
LOCAL i, iCount AS LONG

objOutlook = ANYCOM "Outlook.Application.12"
objNS = objOutlook.Session
objContacts = objNS.GetDefaultFolder(%olFolderContacts)
objItems = objContacts.Items
iCount = objItems.Count

    ? FORMAT$(iCount) 'This shows number of global contacts
    ?

LOCAL pDisp AS IDISPATCH
FOR i = 1 TO iCount
pDisp = objItems.Item(i)
objOneContact = pDisp
IF ISOBJECT(objOneContact) THEN
? ACODE$(objOneContact.FullName)
        ELSE
            ? "============================ NOT OBJECT ERROR: i =" + FORMAT$(i)
END IF
NEXT i

? : ? "Press any key to continue"; : WAITKEY$

END FUNCTION

José Roca

 
IFontDisp and IPictureDisp are two external OLE interfaces often referenced in Automation servers and ActiveX controls. They are automation wrappers on top of the standard IPicture and IFont interfaces.

In my headers, they are defined in "OCIdl.inc":


' ########################################################################################
' IFontDisp interface
' IID = BEF6E003-A874-101A-8BBA-00AA00300CAB
' Inherited interface = IDispatch
' Note: This interface is a wrapper on top of the IFont interface. You can use it
' calling the Invoke method or casting it to an object variable declared as StdFont.
' The definition for the StdFont interface is included in olectl.inc.
' ########################################################################################

#IF NOT %DEF(%IFontDisp_INTERFACE_DEFINED)
    %IFontDisp_INTERFACE_DEFINED = 1

$IID_IFontDisp = GUID$("{BEF6E003-A874-101A-8BBA-00AA00300CAB}")

INTERFACE IFontDisp $IID_IFontDisp

   INHERIT IDispatch

END INTERFACE

#ENDIF   ' /* __IFontDisp_INTERFACE_DEFINED__ */


' ########################################################################################
' IPictureDisp interface
' IID = 7BF80981-BF32-101A-8BBB-00AA00300CAB
' Inherited interface = IDispatch
' Note: This interface is a wrapper on top of the IPicture interface. You can use it
' calling the Invoke method or casting it to an object variable declared as StdPicture.
' The definition for the StdPicture interface is included in olectl.inc.
' ########################################################################################

#IF NOT %DEF(%IPictureDisp_INTERFACE_DEFINED)
    %IPictureDisp_INTERFACE_DEFINED = 1

$IID_IPictureDisp = GUID$("{7BF80981-BF32-101A-8BBB-00AA00300CAB}")

INTERFACE IPictureDisp $IID_IPictureDisp

   INHERIT IDispatch

END INTERFACE

#ENDIF              ' /* __IPictureDisp_INTERFACE_DEFINED__ */


Notice that the definitions don't include methods/properties because they are dispatch only interfaces and, when using direct interface calls, can only be called through the IDispatch::Invoke method.

As calling Invoke is not easy unless you're an experienced COM programmer, you have two other options:

1. Change IFontDisp / IPictureDdisp to IDispatch. This way, you can call the methods/properties of these interfaces using late binding with OBJECT CALL/GET/LET. This option has the advantage that you don't need to add any other include file.

2. Change IFontDisp to StdFont and IPictureDisp to StdPicture, and include "OleCtl.inc" (#INCLUDE "OleCtl.inc") in your Outlook.inc file. This way, you can call its methods/properties, if needed, using early binding with OBJECT CALL/GET/LET.

StdFont and StdPicture are defined in OleCtl.inc as follows:


' ========================================================================================
' CoClass name = StdFont
' Interface name = Font
' IID = {BEF6E003-A874-101A-8BBA-00AA00300CAB}
' Attributes = 4096 [&H1000] [Dispatchable]
' Inherited interface = IDispatch
' ========================================================================================

#IF NOT %DEF(%StdFont_DISPINTERFACE_DEFINED)
    %StdFont_DISPINTERFACE_DEFINED = 1

INTERFACE IDBIND StdFont
   MEMBER GET  Name <0> () AS STRING
   MEMBER LET  Name <0> ()   ' Parameter Type AS STRING
   MEMBER GET  Size <2> () AS CUR
   MEMBER LET  Size <2> ()   ' Parameter Type AS CUR
   MEMBER GET  Bold <3> () AS INTEGER
   MEMBER LET  Bold <3> ()   ' Parameter Type AS INTEGER
   MEMBER GET  Italic <4> () AS INTEGER
   MEMBER LET  Italic <4> ()   ' Parameter Type AS INTEGER
   MEMBER GET  Underline <5> () AS INTEGER
   MEMBER LET  Underline <5> ()   ' Parameter Type AS INTEGER
   MEMBER GET  Strikethrough <6> () AS INTEGER
   MEMBER LET  Strikethrough <6> ()   ' Parameter Type AS INTEGER
   MEMBER GET  Weight <7> () AS INTEGER
   MEMBER LET  Weight <7> ()   ' Parameter Type AS INTEGER
   MEMBER GET  Charset <8> () AS INTEGER
   MEMBER LET  Charset <8> ()   ' Parameter Type AS INTEGER
END INTERFACE

#ENDIF   ' /* __StdFont_DISPINTERFACE_DEFINED__ */

' ========================================================================================
' CoClass name = StdPicture
' Interface name = Picture
' IID = {7BF80981-BF32-101A-8BBB-00AA00300CAB}
' Attributes = 4096 [&H1000] [Dispatchable]
' Inherited interface = IDispatch
' ========================================================================================

#IF NOT %DEF(%StdPicture_DISPINTERFACE_DEFINED)
    %StdPicture_DISPINTERFACE_DEFINED = 1

INTERFACE IDBIND StdPicture
   MEMBER CALL Render <6> (prm_hdc AS LONG<0>, _
               prm_x AS LONG<1>, _
               prm_y AS LONG<2>, _
               prm_cx AS LONG<3>, _
               prm_cy AS LONG<4>, _
               prm_xSrc AS LONG<5>, _
               prm_ySrc AS LONG<6>, _
               prm_cxSrc AS LONG<7>, _
               prm_cySrc AS LONG<8>, _
               prm_prcWBounds AS DWORD<9>)
   MEMBER GET  Handle <0> () AS LONG   ' OLE_HANDLE
   MEMBER GET  hPal <2> () AS LONG   ' OLE_HANDLE
   MEMBER LET  hPal <2> ()   ' Parameter Type AS LONG <OLE_HANDLE>
   MEMBER GET  Type <3> () AS INTEGER
   MEMBER GET  Width <4> () AS LONG   ' OLE_XSIZE_HIMETRIC
   MEMBER GET  Height <5> () AS LONG   ' OLE_YSIZE_HIMETRIC
END INTERFACE

#ENDIF   ' /* __Picture_DISPINTERFACE_DEFINED__ */