Help Center
Help CenterAfxNovaCOM

CAxHost Class

Members (18)

AfxCAxHostDispObjReturns a reference to the control's default interface given the handle of the window that hosts it.AfxCAxHostDispPtrReturns a reference to the control's default interface given the handle of the window that hosts it.AfxCAxHostForwardMessageForwards the Windows messages to the OLE Container window for processing.AfxCAxHostPtrReturns a reference to the OLE container class given the handle of its associated window.AfxCAxHostWindowReturns the OLE container window handle given the handle of the form, or any control in the form, and its control identifier.AdviseEstablishes a connection between a connection point object and the client's sink.ConstructorCreates an instance of the OLE container using a ProgId.ConstructorCreates an instance of the OLE container using a ProgId.ConstructorCreates an instance of the OLE container using a ProgId.CtrlIDReturns the identifier of the container's window.GuidFromStrConverts a string into a 16-byte (128-bit) Globally Unique Identifier (GUID).GuidTextReturns a 38-byte human-readable guid string from a 16-byte GUID.hWindowReturns the handle of the hosting window.OcxDispObjReturns a reference to the control's default interface given the handle of the window that hosts it.OcxDispPtrReturns a reference to the control's default interface given the handle of the window that hosts it.OleCreateFontCreates a standard IFont object.OleCreateFontDispCreates a standard IFont object.UnadviseTerminates an advisory connection previously established by the **Advise** method between a connection point object and a client's sink.

Documentation

CAxHost Class

CAxHost implements an OLE Container using a custom control to host ActiveX controls.

Include file: AfxNova/CaxHost.inc.


Constructors

NameDescription
CAXHOST_AMBIENTDISP structureContains information the ambient properties of the CAxHost control.
Constructor(ProgID)Creates an instance of the OLE container using a ProgId.
Constructor(ClsId)Creates an instance of the OLE container using a Clsid.
Constructor(LibName)Creates an instance of the OLE container using an unregistered OCX.

Methods

NameDescription
AdviseEstablishes a connection between a connection point object and the client's sink.
CtrlIDReturns the identifier of the container's window.
GuidFromStrConverts a string into a 16-byte (128-bit) Globally Unique Identifier (GUID).
GuidTextReturns a 38-byte human-readable guid string from a 16-byte GUID.
hWindowReturns the handle of the hosting window.
OcxDispObjReturns a reference to the control's default interface given the handle of the window that hosts it.
OcxDispPtrReturns a reference to the control's default interface given the handle of the window that hosts it.
OleCreateFontCreates a standard IFont object.
OleCreateFontDispCreates a standard IFont object.
UnadviseTerminates an advisory connection previously established by the Advise method between a connection point object and a client's sink.

Helper Procedures

NameDescription
AfxCAxHostDispObjReturns a reference to the control's default interface given the handle of the window that hosts it.
AfxCAxHostDispPtrReturns a reference to the control's default interface given the handle of the window that hosts it.
AfxCAxHostPtrReturns a reference to the OLE container class given the handle of its associated window.
AfxCAxHostWindowReturns the OLE container window handle given the handle of the form, or any control in the form, and its control identifier.
AfxCAxHostForwardMessageForwards the Windows messages to the OLE Container window for processing.

CAXHOST_AMBIENTDISP Structure

Contains information the ambient properties of the CAxHost control.

TYPE CAXHOST_AMBIENTDISP
   Font AS IFontDisp PTR
   BackColor AS LONG = &hFFFFFF
   ForeColor AS LONG = 0
   LocaleID AS LONG = LOCALE_USER_DEFAULT
   Silent AS VARIANT_BOOL = -1
   UIDead AS VARIANT_BOOL = 0
   DisplayAsDefault AS VARIANT_BOOL = 0
   SupportMnemonics AS VARIANT_BOOL = -1
   OffLineIfNoConnected AS VARIANT_BOOL = -1
   DlCtFlags AS LONG = 0
END TYPE
MemberDescription
FontPointer to a IFontDisp interface. To create the font you can use the OleCreateFontDisp method of the CAxHost class or the AfxOleCreateFontDisp function. The default font is SegoeUI, 9 points.
BackColorSpecifies the back color of the container. The default color is white. You can use the FreeBasic BGR macro to set the color.
ForeColorSpecifies the fore color of the container. The default color is black. You can use the FreeBasic BGR macro to set the color.
LocaleIDSpecifies the ambient locale ID of the container.
SilentIndicates the bind operation will be completed silently. No user interface or user notification will occur.
UIDeadIndicates whether the container wants the control to respond to user-interface actions. If TRUE, the control should not respond. Default value: FALSE.
DisplayAsDefaultA flag that is TRUE if the container has marked the control in this site to be a default button, and therefore a button control should draw itself with a thicker frame. Default value: FALSE.
SupportMnemonicsIndicates whether the container supports keyboard mnemonics. Default value: TRUE.
OffLineIfNotConnectedWebBrowser control. The control support offline browsing.
DlCtFlagsA combination of following flags, using the bitwise OR operator, to indicate your preferences. Most of the flag values have negative effects, that is, they prevent behavior that normally happens. For instance, scripts are normally executed by the WebBrowser Control if you don't customize its behavior. But if you set the DLCTL_NOSCRIPTS flag, no scripts will execute in that instance of the control. However, three flags—DLCTL_DLIMAGES, DLCTL_VIDEOS, and DLCTL_BGSOUNDS—work exactly opposite. If you set flags at all, you must set these three for the WebBrowser Control to behave in its default manner vis-a-vis images, videos and sounds.

Flags

  • DLCTL_DLIMAGES, DLCTL_VIDEOS, and DLCTL_BGSOUNDS: Images, videos, and background sounds will be downloaded from the server and displayed or played if these flags are set. They will not be downloaded and displayed if the flags are not set.
  • DLCTL_NO_SCRIPTS and DLCTL_NO_JAVA: Scripts and Java applets will not be executed.
  • DLCTL_NO_DLACTIVEXCTLS and DLCTL_NO_RUNACTIVEXCTLS : ActiveX controls will not be downloaded or will not be executed.
  • DLCTL_DOWNLOADONLY: The page will only be downloaded, not displayed.
  • DLCTL_NO_FRAMEDOWNLOAD: The WebBrowser Control will download and parse a frameset, but not the individual frame objects within the frameset.
  • DLCTL_RESYNCHRONIZE and DLCTL_PRAGMA_NO_CACHE: These flags cause cache refreshes. With DLCTL_RESYNCHRONIZE, the server will be asked for update status. Cached files will be used if the server indicates that the cached information is up-to-date. With DLCTL_PRAGMA_NO_CACHE, files will be re-downloaded from the server regardless of the update status of the files.
  • DLCTL_NO_BEHAVIORS: Behaviors are not downloaded and are disabled in the document.
  • DLCTL_NO_METACHARSET_HTML: Character sets specified in meta elements are suppressed.
  • DLCTL_URL_ENCODING_DISABLE_UTF8 and DLCTL_URL_ENCODING_ENABLE_UTF8: These flags function similarly to the DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 and DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 flags used with IDocHostUIHandler.GetHostInfo. The difference is that the DOCHOSTUIFLAG flags are checked only when the WebBrowser Control is first instantiated. The download flags here for the ambient property change are checked whenever the WebBrowser Control needs to perform a download.
  • DLCTL_NO_CLIENTPULL: No client pull operations will be performed.
  • DLCTL_SILENT: No user interface will be displayed during downloads.
  • DLCTL_FORCEOFFLINE: The WebBrowser Control always operates in offline mode.
  • DLCTL_OFFLINEIFNOTCONNECTED and DLCTL_OFFLINE: These flags are the same. The WebBrowser Control will operate in offline mode if not connected to the Internet.

Constructor(ProgId)

Creates an instance of the OLE container using a ProgId.

CONSTRUCTOR CAxHost (BYVAL pWindow AS CWindow PTR, BYVAL cID AS LONG_PTR, _
   BYREF wszProgID AS WSTRING, BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, _
   BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, _
   BYVAL dwStyle AS DWORD = 0, BYVAL dwExStyle AS DWORD = 0, _
   BYVAL pAmbientDisp AS CAXHOST_AMBIENTDISP PTR = NULL)
CONSTRUCTOR CAxHost (BYVAL pWindow AS CWindow PTR, BYVAL cID AS INTEGER, _
   BYREF wszProgID AS WSTRING, BYREF wszLicKey AS WSTRING, BYVAL x AS LONG = 0, _
   BYVAL y AS LONG = 0, BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, _
   BYVAL dwStyle AS DWORD = 0, BYVAL dwExStyle AS DWORD = 0, _
   BYVAL pAmbientDisp AS CAXHOST_AMBIENTDISP PTR = NULL)
ParameterDescription
pWindowPointer to the instance of the CWindow class used to create the form.
cIDThe identifier of the control. It must be unique.
wszProgIDThe ProgID of the object to create, such "MSCAL.Calendar".
wszLicKeyThe license key of the control, if the control is licensed.
x, yThe coordinates of the upper-left corner of the window relative to the upper-left corner of the parent window's client area.
nWidthThe width of the window.
nHeightThe height of the window.
dwStyleThe style of the window being created.
dwExStyleThe extended style of the window being created.
pAmbientDispPointer to a CAXHOST_AMBIENTDISP structure.
Example

The following example embeds an instance of the WebBrowser control and navigates to a site:

#define UNICODE
#include once "AfxNova/DVARIANT.inc"
#INCLUDE ONCE "AfxNova/CWindow.inc"
#include once "AfxNova/CAxHost.inc"
USING AfxNova

DECLARE FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
                           BYVAL hPrevInstance AS HINSTANCE, _
                           BYVAL pwszCmdLine AS WSTRING PTR, _
                           BYVAL nCmdShow AS LONG) AS LONG
   END wWinMain(GetModuleHandleW(NULL), NULL, wCommand(), SW_NORMAL)

' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

CONST IDC_WEBBROWSER = 1001

' ========================================================================================
' Main
' ========================================================================================
FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
                   BYVAL hPrevInstance AS HINSTANCE, _
                   BYVAL pwszCmdLine AS WSTRING PTR, _
                   BYVAL nCmdShow AS LONG) AS LONG

   ' // Set process DPI aware
   SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
   ' // Enable visual styles without including a manifest file
   AfxEnableVisualStyles

   ' // Creates the main window
   DIM pWindow AS CWindow = "MyClassName"   ' Use the name you wish
   DIM hWin AS HWND = pWindow.Create(NULL, "CWindow - CAxHost -WebBrowser", @WndProc)
   ' // Sizes it by setting the wanted width and height of its client area
   pWindow.SetClientSize(900, 450)
   ' // Centers the window
   pWindow.Center

   ' // Create an instance of the WebBrowser control
   DIM pHost AS CAxHost = CAxHost(@pWindow, IDC_WEBBROWSER, "Shell.Explorer", 0, 0, pWindow.ClientWidth, pWindow.ClientHeight)
   ' // Get a direct pointer to the Afx_IWebBrowser2 interface
   DIM hWb AS HWND = GetDlgItem(pWindow.hWindow, IDC_WEBBROWSER)
   DIM pWb AS Afx_IWebBrowser2 PTR = CAST(ANY PTR, AfxCAxHostDispPtr(hWb))
   IF pWb THEN
      DIM dvUrl AS DVARIANT = "http://www.jose.it-berater.org/index.html"
      DIM hr AS HRESULT = pWb->Navigate2(dvUrl, NULL, NULL, NULL, NULL)
   END IF

   ' // Displays the window and dispatches the Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

END FUNCTION
' ========================================================================================

' ========================================================================================
' Main window procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

   SELECT CASE uMsg

      ' // If an application processes this message, it should return zero to continue
      ' // creation of the window. If the application returns –1, the window is destroyed
      ' // and the CreateWindowExW function returns a NULL handle.
      CASE WM_CREATE
         RETURN 0

      ' // Sent when the user selects a command item from a menu, when a control sends a
      ' // notification message to its parent window, or when an accelerator keystroke is translated.
      CASE WM_COMMAND
         SELECT CASE CBCTL(wParam, lParam)
            CASE IDCANCEL
               ' // If ESC key pressed, close the application by sending an WM_CLOSE message
               IF CBCTLMSG(wParam, lParam) = BN_CLICKED THEN SendMessageW(hwnd, WM_CLOSE, 0, 0)
         END SELECT
         RETURN 0

      CASE WM_DESTROY
         ' // End the application by sending an WM_QUIT message
         PostQuitMessage(0)
         RETURN 0

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = DefWindowProcW(hwnd, uMsg, wParam, lParam)

END FUNCTION
' ========================================================================================

Constructor(ClsId)

Creates an instance of the OLE container using a ClsId.

CONSTRUCTOR CAxHost (BYVAL pWindow AS CWindow PTR, BYVAL cID AS LONG_PTR, _
   BYREF classID AS CONST CLSID, BYREF riid AS CONST IID, BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, _
   BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, BYVAL dwStyle AS DWORD = 0, _
   BYVAL dwExStyle AS DWORD = 0, BYVAL pAmbientDisp AS CAXHOST_AMBIENTDISP PTR = NULL)
CONSTRUCTOR CAxHost (BYVAL pWindow AS CWindow PTR, BYVAL cID AS INTEGER, _
   BYREF classID AS CONST CLSID, BYREF riid AS CONST IID, BYREF wszLicKey AS WSTRING, _
   BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, _
   BYVAL dwStyle AS DWORD = 0, BYVAL dwExStyle AS DWORD = 0, _
   BYVAL pAmbientDisp AS CAXHOST_AMBIENTDISP PTR = NULL)
ParameterDescription
pWindowPointer to the instance of the CWindow class used to create the form.
cIDThe identifier of the control. It must be unique.
classIDThe CLSID of the object to create, such "{8E27C92B-1264-101C-8A2F-040224009C02}"
riidThe IID of the object to create, such "{8E27C92C-1264-101C-8A2F-040224009C02}".
wszLicKeyThe license key of the control, if the control is licensed.
x, yThe coordinates of the upper-left corner of the window relative to the upper-left corner of the parent window's client area.
nWidthThe width of the window.
nHeightThe height of the window.
dwStyleThe style of the window being created.
dwExStyleThe extended style of the window being created.
pAmbientDispPointer to a CAXHOST_AMBIENTDISP structure.

Constructor(LibName)

Creates an instance of the OLE container using an unregistered OCX.

CONSTRUCTOR CAxHost (BYVAL pWindow AS CWindow PTR, BYVAL cID AS LONG_PTR, _
   BYREF wszLibName AS WSTRING, BYREF classID AS CONST CLSID, BYREF riid AS CONST IID, _
   BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, BYVAL nWidth AS LONG = 0, _
   BYVAL nHeight AS LONG = 0, BYVAL dwStyle AS DWORD = 0, BYVAL dwExStyle AS DWORD = 0, _
   BYVAL pAmbientDisp AS CAXHOST_AMBIENTDISP = NULL)
CONSTRUCTOR CAxHost (BYVAL pWindow AS CWindow PTR, BYVAL cID AS INTEGER, _
   BYREF wszLibName AS WSTRING, BYREF classID AS CONST CLSID, BYREF riid AS CONST IID, _
   BYREF wszLicKey AS WSTRING, BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, _
   BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, BYVAL dwStyle AS DWORD = 0, _
   BYVAL dwExStyle AS DWORD = 0, BYVAL pAmbientDisp AS CAXHOST_AMBIENTDISP PTR = NULL)
ParameterDescription
pWindowPointer to the instance of the CWindow class used to create the form.
cIDThe identifier of the control. It must be unique.
wszLibNameThe full qualified path to the OCX file.
classIDThe CLSID of the object to create, such "{8E27C92B-1264-101C-8A2F-040224009C02}"
riidThe IID of the object to create, such "{8E27C92C-1264-101C-8A2F-040224009C02}".
wszLicKeyThe license key of the control, if the control is licensed.
x, yThe coordinates of the upper-left corner of the window relative to the upper-left corner of the parent window's client area.
nWidthThe width of the window.
nHeightThe height of the window.
dwStyleThe style of the window being created.
dwExStyleThe extended style of the window being created.
pAmbientDispPointer to a CAXHOST_AMBIENTDISP structure.
DIM wszLibName AS WSTRING * 260 = ExePath & "\MSCOMCT2.OCX"
DIM CLSID_MSComCtl2_MonthView AS CLSID = (&h232E456A, &h87C3, &h11D1, {&h8B, &hE3,&h00, &h00, &hF8, &h75, &h4D, &hA1})
DIM IID_MSComCtl2_MonthView AS CLSID = (&h232E4565, &h87C3, &h11D1, {&h8B, &hE3,&h00, &h00, &hF8, &h75, &h4D, &hA1})
DIM RTLKEY_MSCOMCT2 AS WSTRING * 260 = "651A8940-87C5-11d1-8BE3-0000F8754DA1"
DIM pAxHost AS CAxHost PTR = CAxHost(@pWindow, IDC_WEBBROWSER, wszLibName, CLSID_MSComCtl2_MonthView, _
    IID_MSComCtl2_MonthView, RTLKEY_MSCOMCT2, 0, 0, pWindow.ClientWidth, pWindow.ClientHeight)

Advise

Establishes a connection between a connection point object and the client's sink.

FUNCTION Advise (BYVAL pEvtObj AS IDispatch PTR, BYVAL riid AS IID PTR) AS HRESULT
FUNCTION Advise (BYVAL pEvtObj AS IDispatch PTR, BYVAL riid AS CONST IID) AS HRESULT
FUNCTION Advise (BYVAL pEvtObj AS IDispatch PTR, BYREF riid AS IID) AS HRESULT
FUNCTION Advise (BYVAL pEvtObj AS IDispatch PTR, BYVAL riid AS IID PTR) AS HRESULT
FUNCTION Advise (BYVAL pEvtObj AS IDispatch PTR, BYREF riid AS CONST IID) AS HRESULT
FUNCTION Advise (BYVAL pEvtObj AS IDispatch PTR, BYREF riid AS IID) AS HRESULT
ParameterDescription
pEvtObjPointer to the sink event's class. The client's sink receives outgoing calls from the connection point.
riidIID of the events interface of the hosted OCX.

Return value

S_OK (0) or an error code.


CtrlID

Returns the identifier of the container's window.

FUNCTION CtrlID () AS LONG

GuidFromStr

Converts a string into a 16-byte (128-bit) Globally Unique Identifier (GUID)

FUNCTION GuidFromStr (BYVAL pwszGuidText AS WSTRING PTR = NULL) AS GUID
ParameterDescription
pwszGuidTextTo be valid, the string must contain exactly 32 hexadecimal digits, delimited by hyphens and enclosed by curly braces. For example: {B09DE715-87C1-11D1-8BE3-0000F8754DA1}. If pwszGuidText is omited, GuidFromStr generates a new unique guid.

GuidText

Returns a 38-byte human-readable guid string from a 16-byte GUID.

FUNCTION GuidText (BYVAL classID AS CLSID PTR) AS STRING
FUNCTION GuidText (BYVAL riid AS REFIID) AS STRING
FUNCTION GuidText (BYVAL classID AS CLSID) AS STRING
ParameterDescription
classID, riidThe 16-byte GUID.
Return value

The GUID as a human readable string.


hWindow

Returns the handle of the hosting window.

FUNCTION hWindow () AS HWND

OcxDispObj

Returns a reference to the control's default interface given the handle of the window that hosts it. This is a reference counted pointer, so you must release it calling the Release method of the interface, the IUnknown_Release macro or the AfxSaRelease function.

FUNCTION OcxDispObj () AS IDispatch PTR
Return value

IDispatch. A reference to the ActiveX control's default interface.


OcxDispPtr

Returns a reference to the control's default interface given the handle of the window that hosts it. This is not a reference counted pointer, so you must not release it.

FUNCTION OcxDispPtr () AS IDispatch PTR
Return value

IDispatch. A reference to the ActiveX control's default interface.


OleCreateFont

Creates a standard IFont object.

FUNCTION OleCreateFont (BYREF wszFaceName AS WSTRING, BYVAL cySize AS LONG, _
   BYVAL fWeight AS LONG = FW_NORMAL, BYVAL fItalic AS UBYTE = FALSE, _
   BYVAL fUnderline AS UBYTE = FALSE, BYVAL fStrikeOut AS UBYTE = FALSE, _
   BYVAL fCharSet AS UBYTE = DEFAULT_CHARSET) AS IFont PTR
ParameterDescription
wszFaceNameA string that specifies the typeface name of the font. The length of this string must not exceed 31 characters. The EnumFontFamilies function can be used to enumerate the typeface names of all currently available fonts. If wszFaceName is an empty string, GDI uses the first font that matches the other specified attributes.
cySizeSpecifies the height, in logical units, of the font's character cell or character.
fWeightInitial weight of the font. If the weight is below 550 (the average of FW_NORMAL, 400, and FW_BOLD, 700), then the Bold property is also initialized to FALSE. If the weight is above 550, the Bold property is set to TRUE.
The following values are defined for convenience: FW_DONTCARE (0), FW_THIN (100), FW_EXTRALIGHT (200), FW_ULTRALIGHT (200), FW_LIGHT (300), FW_NORMAL (400), FW_REGULAR (400), FW_MEDIUM (500), FW_SEMIBOLD (600), FW_DEMIBOLD (600), FW_BOLD (700), FW_EXTRABOLD (800), FW_ULTRABOLD (800), FW_HEAVY (900), FW_BLACK (900)
fItalicSpecifies an italic font if set to TRUE.
fUnderlineSpecifies an underlined font if set to TRUE.
fStrikeOutSpecifies a strikeout font if set to TRUE.
fCharSetSpecifies the character set. The following values are predefined:
ANSI_CHARSET, BALTIC_CHARSET, CHINESEBIG5_CHARSET, DEFAULT_CHARSET, EASTEUROPE_CHARSET, GB2312_CHARSET, GREEK_CHARSET, HANGUL_CHARSET, MAC_CHARSET, OEM_CHARSET, RUSSIAN_CHARSET, SHIFTJIS_CHARSET, SYMBOL_CHARSET, TURKISH_CHARSET.
Korean Windows: JOHAB_CHARSET
Middle-Eastern Windows: HEBREW_CHARSET, ARABIC_CHARSET.
Thai Windows: THAI_CHARSET.
Return value

A pointer to the object indicates success. NULL indicates failure.

Usage examples
DIM pFont AS IFont = CAxHost.CreateFont("MS Sans Serif", 8, FW_NORMAL, , , , DEFAULT_CHARSET)
DIM pFont AS IFont = CAxHost.CreateFont("Courier New", 10, FW_BOLD, , , , DEFAULT_CHARSET)
DIM pFont AS IFont = CAxHost.CreateFont("Marlett", 8, FW_NORMAL, , , , SYMBOL_CHARSET)

OleCreateFontDisp

Creates a standard IFontDisp object.

FUNCTION OleCreateFontDisp (BYREF wszFaceName AS WSTRING, BYVAL cySize AS LONG, _
   BYVAL fWeight AS LONG = FW_NORMAL, BYVAL fItalic AS UBYTE = FALSE, _
   BYVAL fUnderline AS UBYTE = FALSE, BYVAL fStrikeOut AS UBYTE = FALSE, _
   BYVAL fCharSet AS UBYTE = DEFAULT_CHARSET) AS IFont PTR
ParameterDescription
wszFaceNameA string that specifies the typeface name of the font. The length of this string must not exceed 31 characters. The EnumFontFamilies function can be used to enumerate the typeface names of all currently available fonts. If wszFaceName is an empty string, GDI uses the first font that matches the other specified attributes.
cySizeSpecifies the height, in logical units, of the font's character cell or character.
fWeightInitial weight of the font. If the weight is below 550 (the average of FW_NORMAL, 400, and FW_BOLD, 700), then the Bold property is also initialized to FALSE. If the weight is above 550, the Bold property is set to TRUE.
The following values are defined for convenience: FW_DONTCARE (0), FW_THIN (100), FW_EXTRALIGHT (200), FW_ULTRALIGHT (200), FW_LIGHT (300), FW_NORMAL (400), FW_REGULAR (400), FW_MEDIUM (500), FW_SEMIBOLD (600), FW_DEMIBOLD (600), FW_BOLD (700), FW_EXTRABOLD (800), FW_ULTRABOLD (800), FW_HEAVY (900), FW_BLACK (900)
fItalicSpecifies an italic font if set to TRUE.
fUnderlineSpecifies an underlined font if set to TRUE.
fStrikeOutSpecifies a strikeout font if set to TRUE.
fCharSetSpecifies the character set. The following values are predefined:
ANSI_CHARSET, BALTIC_CHARSET, CHINESEBIG5_CHARSET, DEFAULT_CHARSET, EASTEUROPE_CHARSET, GB2312_CHARSET, GREEK_CHARSET, HANGUL_CHARSET, MAC_CHARSET, OEM_CHARSET, RUSSIAN_CHARSET, SHIFTJIS_CHARSET, SYMBOL_CHARSET, TURKISH_CHARSET.
Korean Windows: JOHAB_CHARSET
Middle-Eastern Windows: HEBREW_CHARSET, ARABIC_CHARSET.
Thai Windows: THAI_CHARSET.
Return value

A pointer to the object indicates success. NULL indicates failure.

Usage examples
DIM pFontDisp AS IFontDisp = CAxHost.CreateFontDisp("MS Sans Serif", 8, FW_NORMAL, , , , DEFAULT_CHARSET)
DIM pFontDisp AS IFontDisp = CAxHost.CreateFontDisp("Courier New", 10, FW_BOLD, , , , DEFAULT_CHARSET)
DIM pFontDisp AS IFontDisp = CAxHost.CreateFontDisp("Marlett", 8, FW_NORMAL, , , , SYMBOL_CHARSET)

Unadvise

Terminates an advisory connection previously established by the Advise method between a connection point object and a client's sink.

FUNCTION Unadvise () AS HRESULT
Return value

S_OK (0) or an error code.


AfxCAxHostDispObj

Returns a reference to the control's default interface given the handle of the window that hosts it. This is a reference counted pointer, so you must release it calling the Release method of the interface, the IUnknown_Release macro or the AfxSafeRelease function.

FUNCTION AfxCAxHostDispObj (BYVAL hwnd AS HWND) AS IDispatch PTR
ParameterDescription
hwndHandle of the window that hosts the ActiveX control. If you don't know the value of this handle, you can get it calling the AfxCAxHostWindow function.
Return value

IDispatch. A reference to the ActiveX control's default interface.


AfxCAxHostDispPtr

Returns a reference to the OLE container class given the handle of its associated window. This is not an AddRefed pointer, so don't release it.

FUNCTION AfxCAxHostDispPtr (BYVAL hwnd AS HWND) AS IDispatch PTR
ParameterDescription
hwndHandle of the window that hosts the ActiveX control. If you don't know the value of this handle, you can get it calling the AfxCAxHostWindow function.
Return value

IDispatch. A reference to the ActiveX control's default interface.


AfxCAxHostPtr

Returns a reference to the OLE container class given the handle of its associated window.

FUNCTION AfxCAxHostPtr (BYVAL hwnd AS HWND) AS CAxHost PTR
FUNCTION AfxCAxHostPtr (BYVAL hwnd AS HWND, BYVAL cID AS WORD) AS CAxHost PTR
ParameterDescription
hwndHandle of the window that hosts the ActiveX control. If you don't know the value of this handle, you can get it calling the AfxCAxHostWindow function.
cIDIdentifier of the control, e.g. IDC_WEBBROWSER.
Return value

A pointer to the CAxHost class or NULL.


AfxCAxHostWindow

Returns the OLE container window handle given the handle of the form, or any control in the form, and its control identifier.

FUNCTION AfxCAxHostWindow (BYVAL hwnd AS HWND, BYVAL cID AS WORD) AS HWND
ParameterDescription
hwndHandle of the window that hosts he ActiveX control. If you don't know the value of this handle, you can get it calling the AfxCAxHostWindow function.
cIDIdentifier of the control, e.g. IDC_WEBBROWSER.
Return value

The handle of the window or NULL.


AfxCAxHostForwardMessage

Forwards the Windows messages to the OLE Container window for processing.

FUNCTION AfxCAxHostForwardMessage (BYVAL hctl AS HWND, BYVAL pMsg AS tagMSG PTR) AS BOOLEAN
ParameterDescription
hctlHandle of the control.
pMsgA pointer to a MSG structure that contains information about a message
Return value

TRUE if the message was processed, FALSE if not.

Remarks

Active in-place objects must always be given the first chance at translating accelerator keystrokes. You can provide this opportunity by calling IOleInPlaceActiveObject.TranslateAccelerator from your container's message loop before doing any other translation. You should apply your own translation only when this method returns FALSE.

Usage example
' // Dispatch Windows messages
DIM uMsg AS MSG
WHILE (GetMessageW(@uMsg, NULL, 0, 0) <> FALSE)
   IF AfxForwardMessage(GetFocus, @uMsg) = FALSE THEN
      IF IsDialogMessageW(hWndMain, @uMsg) = 0 THEN
         TranslateMessage(@uMsg)
         DispatchMessageW(@uMsg)
      END IF
   END IF
WEND