📄 bcfcontrolppg.cpp
字号:
//=--------------------------------------------------------------------------=
// BCFControlPPG.Cpp
//=--------------------------------------------------------------------------=
// Copyright 1995 Microsoft Corporation. All Rights Reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//=--------------------------------------------------------------------------=
//
// property page implementations for BCFControl control.
//
#include "IPServer.H"
#include "LocalObj.H"
#include "BCFControlPPG.H"
#include "BCFControlCtl.H"
#include "Resrc1.H"
#include "Util.H"
#include "alignmentenums.h"
// for ASSERT and FAIL
//
SZTHISFILE
//=--------------------------------------------------------------------------=
// Property Page messages
//=--------------------------------------------------------------------------=
// in addition to regular windows messages you'll receive for a dialog box,
// you'll receive the following messages in your property page implementation:
//
// PPM_NEWOBJECTS:
// wParam = 0;
// lParam = (LPARAM)(HRESULT *)&hr
//
// - in this message, you should call FirstControl() to get a pointer to a
// control, and initialize the values in the property page dialog with
// values from the control object. put results from the operation in
// the HRESULT pointed to by LPARAM.
//
// PPM_APPLY:
// wParam = 0;
// lParam = (LPARAM)(HRESULT *)&hr
//
// - this message is sent to your dialog whenever the user clicks APPLY or OK
// in the dialog. you should have a loop with the following code in it:
//
// for (pUnk = FirstControl(&dwCookie) ; pUnk; pUnk = NextControl(&dwCookie)) {
// hr = pUnk->QueryInterface(IID_IMyCtlInterface, (void **)&pMyCtl);
// // set properties here!!!
// }
//
// call PropPageException() if there is an error while setting propertites
// to show the exception set up by the property set routine.
//
// PPM_EDITPROPERTY:
// wParam = dispid
// lParam = (LPARAM)(HRESULT *)&hr
//
// - sent to your dialog when somebody wants you to set the focus to a specific
// property [typically, one will see a call to this when one returns a page
// from IPerPropertyBrowsing::MapPropertyToPage]. you can use this
// to bring up dialogs, or do whatever flaps your flagella.
//
// PPM_FREEOBJECTS:
// wParam = 0
// lParam = (LPARAM)(HRESULT *)&hr
//
// - sent to your dialog when you should free up any objects. some people will
// find it interesting to QI and store objects in the PPM_INITOBJECTS message.
// this message tells the prop page that these objects are no longer valid,
// and any stashing of objects should be terminated.
//
//=--------------------------------------------------------------------------=
// CBCFControlGeneralPage::Create
//=--------------------------------------------------------------------------=
// global static creation function.
//
// Parameters:
// IUnknown * - [in] controlling unknown
//
// Output:
// IUnknown * - new prop page.
//
// Notes:
//
IUnknown *CBCFControlGeneralPage::Create
(
IUnknown *pUnkOuter
)
{
return (IUnknown *)new CBCFControlGeneralPage(pUnkOuter);
}
//=--------------------------------------------------------------------------=
// CBCFControlGeneralPage::CBCFControlGeneralPage
//=--------------------------------------------------------------------------=
// constructor.
//
// Parameters:
// IUnknown * - [in] controlling unknown.
//
// Notes:
//
CBCFControlGeneralPage::CBCFControlGeneralPage
(
IUnknown *pUnkOuter
)
: CPropertyPage(pUnkOuter, OBJECT_TYPE_PPGBCFCONTROLGENERAL)
{
// initialize local variables here.
}
//=--------------------------------------------------------------------------=
// CBCFControlGeneralPage::~CBCFControlGeneralPage
//=--------------------------------------------------------------------------=
// destructor.
//
// Notes:
//
CBCFControlGeneralPage::~CBCFControlGeneralPage()
{
// clean up
}
//=--------------------------------------------------------------------------=
// CBCFControlGeneralPage::DialogProc
//=--------------------------------------------------------------------------=
// our dialog proc.
//
// Parameters:
// - see win32sdk docs on DialogProc
//
// Notes:
//
BOOL CBCFControlGeneralPage::DialogProc
(
HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam
)
{
switch (msg)
{
case WM_INITDIALOG:
{
// get the window handle of the combobox control
HWND hTempWnd = ::GetDlgItem(hwnd, IDC_ALIGNMENTCOMBO);
// make sure that the control is empty
::SendMessage(hTempWnd, CB_RESETCONTENT, 0, 0);
// set the selection strings in the control - it is important that the control
// be unsorted since the entries index will relate to the property setting
::SendMessage(hTempWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) EALIGN_LEFT_TEXT);
::SendMessage(hTempWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) EALIGN_CENTER_TEXT);
::SendMessage(hTempWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) EALIGN_RIGHT_TEXT);
}
return TRUE;
// we've been given some new objects, so go and re-set up the dialog page.
case PPM_NEWOBJECTS:
{
HRESULT hr;
IBCFControl *pBCFControl;
IUnknown *pUnk;
DWORD dwDummy;
LONG lAlignment;
// get the IUnknown of the control
pUnk = FirstControl(&dwDummy);
// if we didn't get a pointer then exit
if (!pUnk) return FALSE;
// get the controls custom interface
hr = pUnk->QueryInterface(IID_IBCFControl, (void **)&pBCFControl);
// if it failed then exit
if (FAILED(hr)) return FALSE;
// get the alignment from the control
pBCFControl->get_Alignment(&lAlignment);
// set the alignment selection in the control
::SendMessage(::GetDlgItem(hwnd, IDC_ALIGNMENTCOMBO), CB_SETCURSEL, lAlignment, 0);
// release the interface
pBCFControl->Release();
}
return TRUE;
case PPM_APPLY:
{
IBCFControl *pBCFControl;
IUnknown *pUnk;
HRESULT hr;
DWORD dwCookie;
// get all the controls we have to update.
//
for(pUnk = FirstControl(&dwCookie); pUnk; pUnk = NextControl(&dwCookie))
{
// QI for the controls custom interface
hr = pUnk->QueryInterface(IID_IBCFControl, (void **)&pBCFControl);
// if it failed then continue to the next "for" iteration
if (FAILED(hr)) continue;
// get the alignment selection in the dialog control
long lAlignment = ::SendMessage(::GetDlgItem(hwnd, IDC_ALIGNMENTCOMBO), CB_GETCURSEL, 0, 0);
// set the alignment in the control
pBCFControl->put_Alignment(lAlignment);
// release the interface pointer
pBCFControl->Release();
}
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_ALIGNMENTCOMBO:
if(HIWORD(wParam) == CBN_SELCHANGE)
this->MakeDirty();
}
break;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -