I just flipped through CodeGuru and found that the control property page was displayed at runtime.
Http://www.codeguru.com/cpp/com-tech/activex/controls/article.php/c2649/
Try to do it as it looks.
Also, the example tppb in the previous step
1. Add HRESULT GetPages (CAUUID * pPages)
HRESULT CTppbCtrl: GetPages (CAUUID * pPages)
{
GUID * pGUID;
Const unsigned CPROPPAGES = 4;
PPages-> cElems = 0;
PPages-> pElems = NULL;
PGUID = (GUID *) CoTaskMemAlloc (CPROPPAGES * sizeof (GUID ));
If (NULL = pGUID)
{
Return ResultFromScode (E_OUTOFMEMORY );
}
// Fill the array of property pages now
PGUID [0] = CTestPropPage: guid;
PGUID [1] = CLSID_CFontPropPage;
PGUID [2] = CLSID_CColorPropPage;
PGUID [3] = CLSID_CPicturePropPage;
// Fill the structure and return
PPages-> cElems = CPROPPAGES;
PPages-> pElems = pGUID;
Return NOERROR;
}
This is a common member function. The main function is to obtain how many property pages are displayed and what property pages are available.
2. Add the control method void ShowProperties ()
Void CTppbCtrl: ShowProperties ()
{
// TODO: Add your dispatch handler code here
CAUUID caGUID;
HRESULT hr;
LPDISPATCH pIDispatch = GetIDispatch (TRUE );
LCID lcid = AmbientLocaleID ();
GetPages (& caGUID );
Hr = OleCreatePropertyFrame (
M_hWnd,
10,
10,
OLESTR ("Do something control "),
1,
(IUnknown **) & pIDispatch,
CaGUID. cElems,
CaGUID. pElems,
Lcid,
0L,
NULL );
If (FAILED (hr ))
{
AfxMessageBox ("unable to display attribute pages", MB_ OK | MB_ICONERROR, 0 );
}
CoTaskMemFree (void *) caGUID. pElems );
Return;
}
The function used to display the property page is OleCreatePropertyFrame, which is obtained through the GetPages function. The information of the property page is stored in the CAUUID caGUID structure.
The prototype of the OleCreatePropetyFrame function is
STDAPI OleCreatePropertyFrame (
HWNDHwndOwner,// The parent window of the property page dialog box
UINTX,// Horizontal position of the property page relative to the parent window
UINTY,// Vertical position of the property page relative to the parent window
LPCOLESTRLpszCaption, // Attribute page title
ULONGCObjects,// Number of controls that can be set on the property page
Lpunknown far *LplpUnk, // An array of all configurable controls on the property page
ULONGCPages,// Number of displayed property pages
LPCLSIDLpPageClsID, // CLSID array on the property page
LCIDLcid,// Language flag. If you do not care about it, you can set it to 0.
DWORDDwReserved,// Reserved
LPVOIDLpvReserved// Reserved);
For more information, see.
3. Compile and create a VB project, add the tppb control, and add the Code as follows:
Private Sub Form_Load ()
Tppb1.ShowProperties
End Sub
The properties page is displayed after running.