コード例 #1
0
STDMETHODIMP CShellPropSheetExt::AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
{
	PROPSHEETPAGE  psp;
	HPROPSHEETPAGE hPage;

	size_t	pos = filepath.find_last_of('.');
	if(pos == std::wstring::npos || _tcsicmp(filepath.substr(pos + 1).c_str(), TEXT("zip")))
		return S_OK;

	psp.dwSize        = sizeof(PROPSHEETPAGE);
	psp.dwFlags       = PSP_USEREFPARENT | PSP_USETITLE | PSP_USECALLBACK;
	psp.hInstance     = hDllInstance;
	psp.pszTemplate   = MAKEINTRESOURCE(IDD_PROPSHEET1);
	psp.hIcon         = 0;
	psp.pszTitle      = TEXT("CubeICE");
	psp.pfnDlgProc    = (DLGPROC)DialogProc;
	psp.lParam        = (LPARAM)this;
	psp.pfnCallback   = PropSheetPageProc;
	psp.pcRefParent   = (PUINT)&dllRefCount;

	hPage = CreatePropertySheetPage(&psp);
	if (hPage == NULL)
		return E_OUTOFMEMORY;
	
	if (!pfnAddPage(hPage, lParam)) {
		DestroyPropertySheetPage(hPage);
		return E_FAIL;
	}

	AddRef();

	return S_OK;
}
コード例 #2
0
ファイル: processor.c プロジェクト: GYGit/reactos
BOOL
APIENTRY
PropSheetExtProc(PSP_PROPSHEETPAGE_REQUEST PropPageRequest, LPFNADDPROPSHEETPAGE fAddFunc, LPARAM lParam)
{
    PROPSHEETPAGE PropSheetPage;
    HPROPSHEETPAGE hPropSheetPage;

    if(PropPageRequest->PageRequested != SPPSR_ENUM_ADV_DEVICE_PROPERTIES)
        return FALSE;

    if ((!PropPageRequest->DeviceInfoSet) || (!PropPageRequest->DeviceInfoData))
        return FALSE;

    ZeroMemory(&PropSheetPage, sizeof(PROPSHEETPAGE));
    PropSheetPage.dwSize = sizeof(PROPSHEETPAGE);
    PropSheetPage.hInstance = g_hInstance;
    PropSheetPage.pszTemplate = MAKEINTRESOURCE(DLG_PROCESSORINFO);
    PropSheetPage.pfnDlgProc = ProcessorDlgProc;

    hPropSheetPage = CreatePropertySheetPage(&PropSheetPage);
    if(!hPropSheetPage)
        return FALSE;

    if(!(fAddFunc)(hPropSheetPage, lParam)) {
        DestroyPropertySheetPage (hPropSheetPage);
        return FALSE;
    }

    return TRUE;
}
コード例 #3
0
ファイル: sysdm.c プロジェクト: GYGit/reactos
static HMODULE
AddNetIdPage(PROPSHEETHEADER *ppsh)
{
    HPROPSHEETPAGE hPage;
    HMODULE hMod;
    PCreateNetIDPropertyPage pCreateNetIdPage;

    hMod = LoadLibrary(TEXT("netid.dll"));
    if (hMod != NULL)
    {
        pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod,
                                                                    "CreateNetIDPropertyPage");
        if (pCreateNetIdPage != NULL)
        {
            hPage = pCreateNetIdPage();
            if (hPage == NULL)
                goto Fail;

            if (!PropSheetAddPage(hPage, (LPARAM)ppsh))
            {
                DestroyPropertySheetPage(hPage);
                goto Fail;
            }
        }
        else
        {
Fail:
            FreeLibrary(hMod);
            hMod = NULL;
        }
    }

    return hMod;
}
コード例 #4
0
void CBasePropertySheet::AddPage(CPropertyPage* pPage)
{
	ASSERT_VALID(this);
	ASSERT(pPage != NULL);
	ASSERT_KINDOF(CPropertyPage, pPage);
	ASSERT_VALID(pPage);

	// add page to internal list
	m_pages.Add(pPage);

	// add page externally
	if (m_hWnd != NULL)
	{
		// build new prop page array
		AFX_OLDPROPSHEETPAGE *ppsp = new AFX_OLDPROPSHEETPAGE[m_pages.GetSize()];
		memcpy(ppsp, m_psh.ppsp, sizeof(AFX_OLDPROPSHEETPAGE) * (m_pages.GetSize()-1));
		delete[] (PROPSHEETPAGE*)m_psh.ppsp;
		m_psh.ppsp = (PROPSHEETPAGE*)ppsp;
		ppsp += m_pages.GetSize()-1;

		// copy processed PROPSHEETPAGE struct to end
		memcpy(ppsp, &pPage->m_psp, sizeof(pPage->m_psp));
//		pPage->PreProcessPageTemplate((PROPSHEETPAGE&)*ppsp, IsWizard());
		CPropertyPage_PreProcessPageTemplate((_CCPropertyPage*)pPage, (PROPSHEETPAGE&)*ppsp, IsWizard());
		HPROPSHEETPAGE hPSP = CreatePropertySheetPage((PROPSHEETPAGE*)ppsp);
		if (hPSP == NULL)
			AfxThrowMemoryException();

		if (!SendMessage(PSM_ADDPAGE, 0, (LPARAM)hPSP))
		{
			DestroyPropertySheetPage(hPSP);
			AfxThrowMemoryException();
		}
	}
}
コード例 #5
0
void CListViewWalkerPropertySheet::InsertPage(int iIndex, CPropertyPage* pPage)
{
    ASSERT_VALID( this );
    ASSERT( pPage != NULL );
    ASSERT_KINDOF( CPropertyPage, pPage );
    ASSERT_VALID( pPage );

    m_pages.InsertAt(iIndex, pPage);
    BuildPropPageArray();

    if (m_hWnd != NULL)
    {
        PROPSHEETPAGE* ppsp = const_cast<PROPSHEETPAGE*>(m_psh.ppsp);
        for (UINT i = 0; i < m_psh.nPages; i++) {
            if (i == (UINT)iIndex)
                break;
            (BYTE*&)ppsp += ppsp->dwSize;
        }

        HPROPSHEETPAGE hPSP = CreatePropertySheetPage(ppsp);
        if (hPSP == NULL)
            AfxThrowMemoryException();

        if (!SendMessage(PSM_INSERTPAGE, iIndex, (LPARAM)hPSP)) {
            DestroyPropertySheetPage(hPSP);
            AfxThrowMemoryException();
        }
    }
}
コード例 #6
0
// ----------------------------------------------------------------------------
// Function:
//      CSwapPropPage::AddPages
//
// Description:
//      Implementation of IShellPropSheetExt::AddPages. Adds one or more pages
//      to a property sheet that the Shell displays for a file object.
//
// Parameters:
//      lpfnAddPage - [in] Address of a function that the property sheet
//                    handler calls to add a page to the property sheet. The
//                    function takes a property sheet handle returned by the
//                    CreatePropertySheetPage function and the lParam parameter
//                    passed to the AddPages method. 
//      lParam - [in] Parameter to pass to the function specified by the
//               lpfnAddPage method.
//
// Return values:
//      Returns S_OK if successful. If the method fails, an OLE-defined error
//      code is returned
// ----------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT STDMETHODCALLTYPE CSwapPropPage::AddPages
(
    LPFNADDPROPSHEETPAGE    lpfnAddPage,    // See PrSht.h
    LPARAM                  lParam          // Used by caller, don't modify
)
{
    HRESULT                 hr = S_OK;
    PROPSHEETPAGE           psp;
    HPROPSHEETPAGE          hPage1 = NULL;
    AudioFXExtensionParams* pAudioFXParams = (AudioFXExtensionParams*)lParam;
#pragma warning(push)
#pragma warning(disable: 28197)
    AudioFXExtensionParams* pAudioFXParamsCopy = new AudioFXExtensionParams;
#pragma warning(pop)

    if (pAudioFXParamsCopy == NULL)
    {
        return E_OUTOFMEMORY;
    }

    // Make a copy of the params
    CopyMemory(pAudioFXParamsCopy, pAudioFXParams, sizeof(AudioFXExtensionParams));
    SAFE_ADDREF(pAudioFXParamsCopy->pFxProperties);

    // Initialize property page params and create page
    psp.dwSize        = sizeof(psp);
    psp.dwFlags       = PSP_USEREFPARENT | PSP_USECALLBACK;
    psp.hInstance     = _AtlBaseModule.GetModuleInstance();
    psp.hIcon         = 0;
    psp.pcRefParent   = (UINT*)&m_dwRef;
    psp.lParam        = (LPARAM)pAudioFXParamsCopy;
    psp.pszTemplate   = MAKEINTRESOURCE(IDD_SWAP_PROP_PAGE);
    psp.pfnDlgProc    = (DLGPROC)DialogProcPage1;
    psp.pfnCallback   = PropSheetPageProc;

    // Create the property sheet page and add the page
    hPage1 = CreatePropertySheetPage(&psp);
    if (hPage1)
    {
        if (!lpfnAddPage(hPage1, pAudioFXParams->AddPageParam))
        {
            hr = E_FAIL;
            delete pAudioFXParamsCopy;
            DestroyPropertySheetPage(hPage1);
        }
        else
        {
            // Add ref for page
            this->AddRef();
        }
    }
    else
    {
        delete pAudioFXParamsCopy;
        hr = E_OUTOFMEMORY;
    }

    return(hr);
}
コード例 #7
0
STDMETHODIMP CHashCheck::AddPages( LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam )
{
	PROPSHEETPAGE psp;
	psp.dwSize = sizeof(psp);
	psp.dwFlags = PSP_USECALLBACK | PSP_USEREFPARENT | PSP_USETITLE;
	psp.hInstance = g_hModThisDll;
	psp.pszTemplate = MAKEINTRESOURCE(IDD_HASHPROP);
	psp.pszTitle = MAKEINTRESOURCE(IDS_HP_TITLE);
	psp.pfnDlgProc = HashPropDlgProc;
	psp.lParam = (LPARAM)m_hList;
	psp.pfnCallback = HashPropCallback;
	psp.pcRefParent = (PUINT)&g_cRefThisDll;

	if (ActivateManifest(FALSE))
	{
		psp.dwFlags |= PSP_USEFUSIONCONTEXT;
		psp.hActCtx = g_hActCtx;
	}

	HPROPSHEETPAGE hPage = CreatePropertySheetPage(&psp);

	if (hPage && !pfnAddPage(hPage, lParam))
		DestroyPropertySheetPage(hPage);

	// HashProp has AddRef'ed and now owns our list
	SLRelease(m_hList);
	m_hList = NULL;

	return(S_OK);
}
コード例 #8
0
STDMETHODIMP
CSSHProperty::AddPages(
    LPFNADDPROPSHEETPAGE lpfnAddPageProc, LPARAM lParam)
{
    PROPSHEETPAGE  psp;
    HPROPSHEETPAGE hPage;

    // Set up the PROPSHEETPAGE struct.
    ZeroMemory(&psp, sizeof(PROPSHEETPAGE));

    psp.dwSize      = sizeof(PROPSHEETPAGE);
    psp.dwFlags     = PSP_USEREFPARENT | PSP_USETITLE | PSP_DEFAULT |
                      PSP_USEICONID | PSP_USECALLBACK;
    psp.hInstance   = _AtlBaseModule.GetResourceInstance();
    psp.pszTemplate = MAKEINTRESOURCE(IDD_SSH_PROPERTY);
    psp.pszIcon     = NULL;//MAKEINTRESOURCE(IDI_TAB_ICON);
    psp.pszTitle	= TEXT("Permission");
    psp.pfnDlgProc  = PropPageDlgProc;
    psp.lParam      = (LPARAM)new string_list(m_lsFiles);
    psp.pfnCallback = PropPageCallbackProc;
    psp.pcRefParent = (UINT*) &_AtlModule.m_nLockCnt;

    // Create the page & get a handle.
    hPage = CreatePropertySheetPage(&psp);

    if (NULL != hPage) {
        // Call the shell's callback function, so it adds the page to
        // the property sheet.
        if (!lpfnAddPageProc(hPage, lParam))
            DestroyPropertySheetPage(hPage);
    }

    return S_OK;
}
コード例 #9
0
ファイル: pp.c プロジェクト: kcrazy/winekit
/*++

Routine Description: SerialPortPropPageProvider

    Entry-point for adding additional device manager property
    sheet pages.  Registry specifies this routine under
    Control\Class\PortNode::EnumPropPage32="msports.dll,thisproc"
    entry.  This entry-point gets called only when the Device
    Manager asks for additional property pages.

Arguments:

    Info  - points to PROPSHEETPAGE_REQUEST, see setupapi.h
    AddFunc - function ptr to call to add sheet.
    Lparam - add sheet functions private data handle.

Return Value:

    BOOL: FALSE if pages could not be added, TRUE on success

--*/
BOOL CALLBACK SerialPortPropPageProvider(LPVOID               Info,
                                         LPFNADDPROPSHEETPAGE AddFunc,
                                         LPARAM               Lparam
                                         )
{
   PSP_PROPSHEETPAGE_REQUEST pprPropPageRequest;
   PROPSHEETPAGE             psp;
   HPROPSHEETPAGE            hpsp;
   PPORT_PARAMS              params = NULL;

   pprPropPageRequest = (PSP_PROPSHEETPAGE_REQUEST) Info;

   if (PortTypeSerial != 
       GetPortType(pprPropPageRequest->DeviceInfoSet,
                   pprPropPageRequest->DeviceInfoData,
                   FALSE)) {
       return FALSE;
   }

   //
   // Allocate and zero out memory for the struct that will contain
   // page specific data
   //
   params = (PPORT_PARAMS) LocalAlloc(LPTR, sizeof(PORT_PARAMS));

   if (!params) {
       ErrMemDlg(GetFocus());
       return FALSE;
   }

   if (pprPropPageRequest->PageRequested == SPPSR_ENUM_ADV_DEVICE_PROPERTIES) 
   {
        InitPortParams(params,
                       pprPropPageRequest->DeviceInfoSet,
                       pprPropPageRequest->DeviceInfoData);

        hpsp = InitSettingsPage(&psp, params);

        if (!hpsp) {
            LocalFree(params);
            return FALSE;
        }

        if (!(*AddFunc)(hpsp, Lparam)) {
            DestroyPropertySheetPage(hpsp);
            return FALSE;
        }
   }
   else
   {
       LocalFree(params);
   }

   return TRUE;
} /* SerialPortPropPageProvider */
コード例 #10
0
ファイル: serial.c プロジェクト: GYGit/reactos
BOOL
WINAPI
SerialPortPropPageProvider(PSP_PROPSHEETPAGE_REQUEST lpPropSheetPageRequest,
                           LPFNADDPROPSHEETPAGE lpfnAddPropSheetPageProc,
                           LPARAM lParam)
{
    PROPSHEETPAGEW PropSheetPage;
    HPROPSHEETPAGE hPropSheetPage;

    FIXME("SerialPortPropPageProvider(%p %p %lx)\n",
          lpPropSheetPageRequest, lpfnAddPropSheetPageProc, lParam);

    if (lpPropSheetPageRequest->PageRequested == SPPSR_ENUM_ADV_DEVICE_PROPERTIES)
    {
        FIXME("SPPSR_ENUM_ADV_DEVICE_PROPERTIES\n");

        PropSheetPage.dwSize = sizeof(PROPSHEETPAGEW);
        PropSheetPage.dwFlags = 0;
        PropSheetPage.hInstance = hInstance;
        PropSheetPage.pszTemplate = MAKEINTRESOURCE(IDD_SERIALSETTINGS);
        PropSheetPage.pfnDlgProc = SerialSettingsDlgProc;
        PropSheetPage.lParam = 0;
        PropSheetPage.pfnCallback = NULL;

        hPropSheetPage = CreatePropertySheetPageW(&PropSheetPage);
        if (hPropSheetPage == NULL)
        {
            FIXME("CreatePropertySheetPageW() failed!\n");
            return FALSE;
        }

        if (!(*lpfnAddPropSheetPageProc)(hPropSheetPage, lParam))
        {
            FIXME("lpfnAddPropSheetPageProc() failed!\n");
            DestroyPropertySheetPage(hPropSheetPage);
            return FALSE;
        }
    }

    FIXME("Done!\n");

    return TRUE;
}
コード例 #11
0
static
HRESULT
WINAPI
INetConnectionPropertyUi2_fnAddPages(
    INetConnectionPropertyUi2 * iface,
    HWND hwndParent, 
    LPFNADDPROPSHEETPAGE pfnAddPage,
    LPARAM lParam)
{
    HPROPSHEETPAGE hProp;
    BOOL ret;
    HRESULT hr = E_FAIL;
    INITCOMMONCONTROLSEX initEx;
    INetConnectionPropertyUiImpl * This =  (INetConnectionPropertyUiImpl*)iface;


    initEx.dwSize = sizeof(initEx);
    initEx.dwICC = ICC_LISTVIEW_CLASSES;
    if(!InitCommonControlsEx(&initEx))
        return E_FAIL;

    hr = INetConnection_GetProperties(This->pCon, &This->pProperties);
    if (FAILED(hr))
        return hr;

	hProp = InitializePropertySheetPage(MAKEINTRESOURCEW(IDD_NETPROPERTIES), LANPropertiesUIDlg, (LPARAM)This, This->pProperties->pszwName);
    if (hProp)
    {
        ret = (*pfnAddPage)(hProp, lParam);
        if (ret)
        {
            hr = NOERROR;
        }
        else
        {
            DestroyPropertySheetPage(hProp);
        }
    }
    return hr;
}
コード例 #12
0
ファイル: person~2.cpp プロジェクト: mingpen/OpenNT
extern "C" BOOL CALLBACK AddPersonalTrustDBPages(
//
// Add the pages of our trust database editor to the indicated property
// sheet by using the indicated callback function. Return success or failure
//
    LPVOID lpv, 	
    LPFNADDPROPSHEETPAGE lpfnAddPage, 	
    LPARAM lParam	
   ) { 
    PROPSHEETPAGE psp; 

    CDialogTrustDB* pdlg = new CDialogTrustDB;
    if (!pdlg)
        return FALSE; 

    psp.dwSize      = sizeof(psp);   // no extra data 
    psp.dwFlags     = PSP_USECALLBACK | PSP_USETITLE;
    psp.hInstance   = hinst; 
    psp.pszTemplate = MAKEINTRESOURCE(IDD_TRUSTDIALOG);
    psp.pfnDlgProc  = TrustPropSheetDialogProc; 
    psp.pfnCallback = TrustPropSheetDialogReleaseProc;
    psp.lParam      = (LPARAM)pdlg; 
    psp.pszTitle    = MAKEINTRESOURCE(IDS_TRUSTDIALOG);

    BOOL fSuccess = TRUE;
    HPROPSHEETPAGE hpage = CreatePropertySheetPage(&psp); 
    if (hpage) 
        { 
        if (!lpfnAddPage(hpage, lParam)) 
            {
            DestroyPropertySheetPage(hpage);
            fSuccess = FALSE;
            }
        }
    else
        fSuccess = FALSE;

    return fSuccess;
    } 
コード例 #13
0
//----------------------------------------------------------------------------
//
//  Description:
//      Adds another property page to the handler's properties dialog.
//
//  Parameters:
//      lpfnAddPage         - Pointer to the function which we call to add the page.
//      lParam              - Reserved, must be passed to lpfnAddPage.
//
//  Return Values:
//      S_OK                - Page was successfully added.
//      Other HRESULTs      - Page was not added.
//
//----------------------------------------------------------------------------
STDMETHODIMP CMyDevicePropertySheet::AddPages(
    __in LPFNADDPROPSHEETPAGE lpfnAddPage,
    __in LPARAM               lParam)
{
    HRESULT          hr = E_FAIL;
    PROPSHEETPAGEW   psp = {0};
    HPROPSHEETPAGE  hPage = NULL;;

    // Build the PROPSHEETPAGEW structure which
    // describes the page we will add
    psp.dwSize      = sizeof(psp);
    psp.dwFlags     = PSP_DEFAULT | PSP_USETITLE;
    psp.hInstance   = g_hmodThisDll;
    psp.pszTemplate = MAKEINTRESOURCEW(IDD_PROPPAGE);
    psp.pfnDlgProc  = _DlgProc;
    psp.lParam      = (LPARAM) this;
    psp.pszTitle    = MAKEINTRESOURCEW(IDS_PROPS_TITLE);

    hPage = CreatePropertySheetPageW(&psp);
    if (hPage != NULL)
    {
        // Add the page.  If it fails, then destroy the
        // page we have created.
        if (!lpfnAddPage(hPage, lParam))
        {
            DestroyPropertySheetPage(hPage);
            hPage = NULL;
        }
    }

    if (hPage != NULL)
    {
        hr = S_OK;
    }

    return hr;

} //*** CMyDevicePropertySheet::AddPages
コード例 #14
0
HRESULT CFileTimeShlExt::AddPages ( LPFNADDPROPSHEETPAGE lpfnAddPageProc,
                                    LPARAM lParam )
{
PROPSHEETPAGE  psp;
HPROPSHEETPAGE hPage;
TCHAR          szPageTitle [MAX_PATH];
string_list::const_iterator it, itEnd;
                                  
    for ( it = m_lsFiles.begin(), itEnd = m_lsFiles.end();
          it != itEnd;
          it++ )
        {
        // 'it' points at the next filename.  Allocate a new copy of the string
        // that the page will own.
        LPCTSTR szFile = _tcsdup ( it->c_str() );

        if ( NULL == szFile )
            return E_OUTOFMEMORY;

        // Strip the path and extension from the filename - this will be the
        // page title.  The name is truncated at 24 chars so it fits on the tab.

        lstrcpy ( szPageTitle, it->c_str() );
        PathStripPath ( szPageTitle );
        PathRemoveExtension ( szPageTitle );
        szPageTitle[24] = '\0';

        // Set up the PROPSHEETPAGE struct.

        ZeroMemory ( &psp, sizeof(PROPSHEETPAGE) );

        psp.dwSize      = sizeof(PROPSHEETPAGE);
        psp.dwFlags     = PSP_USEREFPARENT | PSP_USETITLE | PSP_DEFAULT |
                            PSP_USEICONID | PSP_USECALLBACK;
        psp.hInstance   = _Module.GetModuleInstance();
        psp.pszTemplate = MAKEINTRESOURCE(IDD_FILETIME_PROPPAGE);
        psp.pszIcon     = MAKEINTRESOURCE(IDI_ICON);
        psp.pszTitle    = szPageTitle;
        psp.pfnDlgProc  = PropPageDlgProc;
        psp.lParam      = (LPARAM) szFile;
        psp.pfnCallback = PropPageCallbackProc;
        psp.pcRefParent = (UINT*) &_Module.m_nLockCnt;

        // Create the page & get a handle.

        hPage = CreatePropertySheetPage ( &psp );

        if ( NULL != hPage )
            {
            // Call the shell's callback function, so it adds the page to
            // the property sheet.

            if ( !lpfnAddPageProc ( hPage, lParam ))
                {
                DestroyPropertySheetPage ( hPage );
                }
            }
        }   // end for

    return S_OK;
}
コード例 #15
0
ファイル: propsheet.c プロジェクト: Strongc/reactos
static void test_PSM_INSERTPAGE(void)
{
    HPROPSHEETPAGE hpsp[5];
    PROPSHEETPAGEA psp;
    PROPSHEETHEADERA psh;
    HWND hdlg, tab;
    BOOL ret;
    DWORD r;

    memset(&psp, 0, sizeof(psp));
    psp.dwSize = sizeof(psp);
    psp.dwFlags = 0;
    psp.hInstance = GetModuleHandleA(NULL);
    U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_MESSAGE_TEST);
    U2(psp).pszIcon = NULL;
    psp.pfnDlgProc = page_dlg_proc_messages;
    psp.lParam = 0;

    /* multiple pages with the same data */
    hpsp[0] = CreatePropertySheetPageA(&psp);
    hpsp[1] = CreatePropertySheetPageA(&psp);
    hpsp[2] = CreatePropertySheetPageA(&psp);

    U(psp).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_ERROR);
    hpsp[3] = CreatePropertySheetPageA(&psp);

    psp.dwFlags = PSP_PREMATURE;
    hpsp[4] = CreatePropertySheetPageA(&psp);

    memset(&psh, 0, sizeof(psh));
    psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
    psh.dwFlags = PSH_MODELESS;
    psh.pszCaption = "test caption";
    psh.nPages = 1;
    psh.hwndParent = GetDesktopWindow();
    U3(psh).phpage = hpsp;

    hdlg = (HWND)PropertySheetA(&psh);
    ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg);

    /* add pages one by one */
    ret = SendMessageA(hdlg, PSM_INSERTPAGE, 5, (LPARAM)hpsp[1]);
    ok(ret == TRUE, "got %d\n", ret);

    /* try with invalid values */
    ret = SendMessageA(hdlg, PSM_INSERTPAGE, 0, 0);
    ok(ret == FALSE, "got %d\n", ret);

if (0)
{
    /* crashes on native */
    ret = SendMessageA(hdlg, PSM_INSERTPAGE, 0, (LPARAM)INVALID_HANDLE_VALUE);
}

    ret = SendMessageA(hdlg, PSM_INSERTPAGE, (LPARAM)INVALID_HANDLE_VALUE, (LPARAM)hpsp[2]);
    ok(ret == FALSE, "got %d\n", ret);

    /* check item count */
    tab = (HWND)SendMessageA(hdlg, PSM_GETTABCONTROL, 0, 0);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 2, "got %d\n", r);

    ret = SendMessageA(hdlg, PSM_INSERTPAGE, (WPARAM)hpsp[1], (LPARAM)hpsp[2]);
    ok(ret == TRUE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 3, "got %d\n", r);

    /* add property sheet page that can't be created */
    ret = SendMessageA(hdlg, PSM_INSERTPAGE, 1, (LPARAM)hpsp[3]);
    ok(ret == TRUE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 4, "got %d\n", r);

    /* select page that can't be created */
    ret = SendMessageA(hdlg, PSM_SETCURSEL, 1, 0);
    ok(ret == TRUE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 3, "got %d\n", r);

    /* test PSP_PREMATURE flag with incorrect property sheet page */
    ret = SendMessageA(hdlg, PSM_INSERTPAGE, 0, (LPARAM)hpsp[4]);
    ok(ret == FALSE, "got %d\n", ret);

    r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
    ok(r == 3, "got %d\n", r);

    DestroyPropertySheetPage(hpsp[4]);
    DestroyWindow(hdlg);
}
コード例 #16
0
//------------------------------------------------------------------------------
// CDevicePropertyPage::AddPages
//
//      This method is called by the Windows Shell to give oportunity to 
//      register one or more property pages with the property sheet. Minimal
//      work should be done here. Essentially only enough work to figure out
//      whether the property page should be added or not (i.e. no critical data
//      is missing). All other work should be done in the DlgProc function
//      when the WM_INITDIALOG message is sent.
//------------------------------------------------------------------------------
IFACEMETHODIMP CDevicePropertyPage::AddPages(
    __in LPFNADDPROPSHEETPAGE pfnAddPage,
    __in LPARAM lParam
    )
{
    HPROPSHEETPAGE  hPage;
    HRESULT         hr  = S_OK;
    PROPSHEETPAGE   psp = {0};
    PROPSINPUT*     pPropsInput = NULL;

    if( NULL == pfnAddPage )
    {
        return E_INVALIDARG;
    }

    //
    // Allocate the PROPSINPUT struct
    //
    pPropsInput = new (std::nothrow) PROPSINPUT;
    if( NULL == pPropsInput )
    {
        hr = E_OUTOFMEMORY;
    }

    if( S_OK == hr )
    {
        //
        // Fill out the PROPSHEETPAGE structure
        //
        psp.dwSize = sizeof(PROPSHEETPAGE);
        psp.dwFlags = PSP_USECALLBACK;
        psp.hInstance = g_hInstance;
        psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_DEVICE);
        psp.pfnDlgProc = PropPageDlgProc;
        psp.lParam = reinterpret_cast<LPARAM>( pPropsInput );
        psp.pfnCallback = PropPageDlgCleanup;

        //
        // Give a reference to the shell item to the callback data
        //
        hr = m_pShellItem->QueryInterface( &pPropsInput->pShellItem );
    }

    //
    // Grab the icon from the shell item
    //
    if( S_OK == hr )
    {
        hr = GetIconFromItem( m_pShellItem, SHIL_LARGE, &pPropsInput->hIcon );
    }

    //
    // Create the page
    //
    hPage = CreatePropertySheetPage( &psp );
    if( NULL == hPage )
    {
        hr = E_OUTOFMEMORY;
    }

    //
    // Give the shell the page
    //
    if( S_OK == hr &&
        !pfnAddPage( hPage, lParam ) )
    {
        hr = E_FAIL;
    }

    //
    // As the documentation for AddPages describes, you can "request" that your
    // page is the one visibile when the property sheet is loaded. You can do
    // this by giving the index of the page you added (1 based). In this sample
    // we just added one page, so we can return 1 instead of the HR (assuming
    // we didn't fail) to request our page to be the one visible on launch.
    // Keep in mind it is a "request" and is not guaranteed. 
    //
    if( S_OK == hr )
    {
        hr = static_cast<HRESULT>(1);
    }
    else
    {
        if( NULL != hPage )
        {
            DestroyPropertySheetPage( hPage );
        }
        if( NULL != pPropsInput->pShellItem )
        {
            pPropsInput->pShellItem->Release();
        }
        if( NULL != pPropsInput->hIcon )
        {
            DestroyIcon( pPropsInput->hIcon );
        }
    }

    return hr;
}// CDevicePropertyPage::AddPages
コード例 #17
0
ファイル: shell_ext.cpp プロジェクト: bagdxk/openafs
STDMETHODIMP CShellExt::XPropertySheetExt::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
{
    METHOD_PROLOGUE(CShellExt, PropertySheetExt);

    if(pThis->m_bIsPathInAFS) {
        // add the property page for files/folder/mount points/symlinks
        PROPSHEETPAGE psp;
        SecureZeroMemory(&psp, sizeof(PROPSHEETPAGE));
        HPROPSHEETPAGE hPage;
        CPropFile *filesheet = NULL;
        CPropVolume *volsheet = NULL;
        CPropACL * aclsheet = NULL;

        filesheet = new CPropFile(pThis->m_astrFileNames);

        if (filesheet == NULL)
            return E_OUTOFMEMORY;

        HINSTANCE hInst = 0;
        TaLocale_GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_PROPPAGE_FILE), LANG_USER_DEFAULT, &hInst);
        filesheet->m_hInst = hInst;
        filesheet->m_bIsMountpoint = pThis->m_bIsMountpoint;
        filesheet->m_bIsSymlink = pThis->m_bIsSymlink;
        filesheet->m_bIsDir = pThis->m_bDirSelected;
        psp.dwSize = sizeof (psp);
        psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE | PSP_USECALLBACK | PSP_USETITLE;
        psp.hInstance = hInst;
        psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_FILE);
        psp.pszIcon = NULL;
        psp.pszTitle = _T("AFS");
        psp.pfnDlgProc = (DLGPROC) PageProc;
        psp.lParam = (LPARAM) filesheet;
        psp.pfnCallback = PropPageCallbackProc;
        psp.pcRefParent = (UINT*) &nPSRefCount;

        hPage = CreatePropertySheetPage (&psp);

        if (hPage != NULL) {
            if (!lpfnAddPage (hPage, lParam)) {
                delete filesheet;
                DestroyPropertySheetPage (hPage);
            }
        }

        // add the property page for Volume Data
        SecureZeroMemory(&psp, sizeof(PROPSHEETPAGE));
        volsheet = new CPropVolume(pThis->m_astrFileNames);
        if (volsheet == NULL)
            return E_OUTOFMEMORY;

        hInst = 0;
        TaLocale_GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_PROPPAGE_VOLUME), LANG_USER_DEFAULT, &hInst);
        volsheet->m_hInst = hInst;
        volsheet->m_bIsMountpoint = pThis->m_bIsMountpoint;
        volsheet->m_bIsSymlink = pThis->m_bIsSymlink;
        volsheet->m_bIsDir = pThis->m_bDirSelected;
        psp.dwSize = sizeof (psp);
        psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE | PSP_USECALLBACK | PSP_USETITLE;
        psp.hInstance = hInst;
        psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_VOLUME);
        psp.pszIcon = NULL;
        psp.pszTitle = _T("AFS Volume");
        psp.pfnDlgProc = (DLGPROC) PageProc;
        psp.lParam = (LPARAM) volsheet;
        psp.pfnCallback = PropPageCallbackProc;
        psp.pcRefParent = (UINT*) &nPSRefCount;

        hPage = CreatePropertySheetPage (&psp);

        if (hPage != NULL) {
            if (!lpfnAddPage (hPage, lParam)) {
                delete volsheet;
                DestroyPropertySheetPage (hPage);
            }
        }

        if(pThis->m_bDirSelected) {
            // add the property page for ACLs
            SecureZeroMemory(&psp, sizeof(PROPSHEETPAGE));

            aclsheet = new CPropACL(pThis->m_astrFileNames);
            if (aclsheet == NULL)
                return E_OUTOFMEMORY;

            hInst = 0;
            TaLocale_GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_PROPPAGE_ACL), LANG_USER_DEFAULT, &hInst);
            aclsheet->m_hInst = hInst;
            aclsheet->m_bIsMountpoint = pThis->m_bIsMountpoint;
            aclsheet->m_bIsSymlink = pThis->m_bIsSymlink;
            aclsheet->m_bIsDir = pThis->m_bDirSelected;
            psp.dwSize = sizeof (psp);
            psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE | PSP_USECALLBACK | PSP_USETITLE;
            psp.hInstance = hInst;
            psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_ACL);
            psp.pszIcon = NULL;
            psp.pszTitle = _T("AFS ACL");
            psp.pfnDlgProc = (DLGPROC) PageProc;
            psp.lParam = (LPARAM) aclsheet;
            psp.pfnCallback = PropPageCallbackProc;
            psp.pcRefParent = (UINT*) &nPSRefCount;

            hPage = CreatePropertySheetPage (&psp);

            if (hPage != NULL) {
                if (!lpfnAddPage (hPage, lParam)) {
                    delete aclsheet;
                    DestroyPropertySheetPage (hPage);
                }
            }
        }
    }

    return S_OK;
}
コード例 #18
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int nCmdShow)
{
    UNREFERENCED_PARAMETER(nCmdShow);
    UNREFERENCED_PARAMETER(hPrevInstance);

    PROPSHEETPAGE   psp;					//defines the property sheet pages
    HPROPSHEETPAGE  rhpsp[MAXPAGES];		//an array to hold the page's HPROPSHEETPAGE handles
    SHAREDWIZDATA   wizdata;				//the shared data structure
    UINT            cPages          = 0;    //number of pages being added
    BOOL            fPagesCreated   = FALSE;//were all of the pages created successfully?

    ZeroMemory(&psp, sizeof(psp));
    ZeroMemory(&wizdata, sizeof(wizdata));
    ZeroMemory(&rhpsp, sizeof(HPROPSHEETPAGE)*MAXPAGES);

    //
    // Create the Wizard pages
    //

    // First interior page

    psp.dwSize              = sizeof(psp);
    psp.dwFlags             = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
    psp.hInstance           = hInstance;
    psp.lParam              = (LPARAM) &wizdata; //The shared data structure
    psp.pszHeaderTitle      = MAKEINTRESOURCE(IDS_TITLE1);
    psp.pszHeaderSubTitle	= MAKEINTRESOURCE(IDS_SUBTITLE1);
    psp.pszTemplate         = MAKEINTRESOURCE(IDD_INTERIOR1);
    psp.pfnDlgProc          = (DLGPROC)IntPage1DlgProc;

    rhpsp[cPages]           = CreatePropertySheetPage(&psp);

    if (rhpsp[cPages])
    {
        ++cPages;

        // Second interior page

        psp.dwFlags             = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
        psp.pszHeaderTitle      = MAKEINTRESOURCE(IDS_TITLE2);
        psp.pszHeaderSubTitle   = MAKEINTRESOURCE(IDS_SUBTITLE2);
        psp.pszTemplate         = MAKEINTRESOURCE(IDD_INTERIOR2);
        psp.pfnDlgProc          = (DLGPROC)IntPage2DlgProc;

        rhpsp[cPages]           = CreatePropertySheetPage(&psp);

        if (rhpsp[cPages])
        {
            ++cPages;

            //Third interior page

            psp.dwFlags             = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
            psp.pszHeaderTitle      = MAKEINTRESOURCE(IDS_TITLE3);
            psp.pszHeaderSubTitle   = MAKEINTRESOURCE(IDS_SUBTITLE3);
            psp.pszTemplate         = MAKEINTRESOURCE(IDD_INTERIOR3);
            psp.pfnDlgProc          = (DLGPROC)IntPage3DlgProc;

            rhpsp[cPages]           = CreatePropertySheetPage(&psp);

            if (rhpsp[cPages])
            {
                ++cPages;
                fPagesCreated = TRUE;
            }
        }
    }

    if (fPagesCreated)
    {
        // Create the property sheet
        PROPSHEETHEADER psh;  //defines the property sheet
        ZeroMemory(&psh, sizeof(psh));

        psh.dwSize          = sizeof(psh);
        psh.hInstance       = hInstance;
        psh.hwndParent      = NULL;
        psh.phpage          = rhpsp;
        psh.dwFlags         = PSH_AEROWIZARD | PSH_USEICONID;
        psh.pszCaption      = MAKEINTRESOURCE(IDS_WIZTITLE);
        psh.pszIcon         = MAKEINTRESOURCE(IDI_WIZICON);
        psh.nStartPage      = 0;
        psh.nPages          = cPages;

        //Display the wizard
        if (PropertySheet(&psh) == -1)
        {
            // an error occurred, call GetLastError() to retrieve it here.
        }
    }
    else
    {
        // error creating pages -- clean up any we did create
        for (UINT iPage = 0; iPage < cPages; ++iPage)
        {
            DestroyPropertySheetPage(rhpsp[iPage]);
        }
    }

    return 0;
}