示例#1
0
文件: docppg.cpp 项目: kcrazy/winekit
/*++

Routine Name:

    CDocPropPage::PropPageInit

Routine Description:

    Adds an additional Feature property page to the existing Unidrv supplied property pages.
    Called from the Unidrv UI Plug-in entry point for DocumentPropertySheets(),
    on the PROPSHEETUI_REASON_INIT message.

    This base class implementation provides common property page intialisation functionality for
    all property pages. Derived property page classes are required to provide the dialog box template
    and the dialog box title.

Arguments:

    pPSUIInfo - Pointer to a PPROPSHEETUI_INFO structure.

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CDocPropPage::PropPageInit(
    __in CONST PPROPSHEETUI_INFO pPSUIInfo
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pPSUIInfo, E_POINTER)))
    {
        //
        // Only proceed if we have effectively published the helper interfaces to the UI
        // control objects.
        //
        // We also need to retrieve the dialog template resource and dialog title from the
        // derived property page class.
        //
        PROPSHEETPAGE page = {0};
        if (SUCCEEDED(hr = PublishHelpToControls()) &&
            SUCCEEDED(hr = InitDlgBox(&page.pszTemplate, &page.pszTitle)))
        {
            page.dwSize = sizeof(PROPSHEETPAGE);
            page.dwFlags = PSP_DEFAULT | PSP_USETITLE;
            page.hInstance = g_hInstance;

            page.pfnDlgProc = CDocPropPage::DlgProc;
            page.lParam = reinterpret_cast<LPARAM>(this);

            pPSUIInfo->Result = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet,
                                                           CPSFUNC_ADD_PROPSHEETPAGE,
                                                           reinterpret_cast<LPARAM>(&page),
                                                           0);

            if (SUCCEEDED(hr = SetComPropSheetFunc(pPSUIInfo->pfnComPropSheet)) &&
                SUCCEEDED(hr = SetPageHandle(reinterpret_cast<HANDLE>(pPSUIInfo->Result))))
            {
                hr = SetComPropSheetHandle(pPSUIInfo->hComPropSheet);
            }
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
示例#2
0
/*
 *  Process dialog box messages
 */
static int DlgFnOpen(WINDOW wnd,MESSAGE msg,PARAM p1,PARAM p2)
{
    switch (msg)    {
        case CREATE_WINDOW:    {
            int rtn = DefaultWndProc(wnd, msg, p1, p2);
            DBOX *db = wnd->extension;
            WINDOW cwnd = ControlWindow(db, ID_FILENAME);
            SendMessage(cwnd, SETTEXTLENGTH, 64, 0);
            return rtn;
        }
        case INITIATE_DIALOG:
            InitDlgBox(wnd);
            break;
        case COMMAND:
            switch ((int) p1)    {
                case ID_OK:
				{
                    if ((int)p2 == 0)	{
						char fn[MAXPATH+1];
						char nm[MAXFILE];
						char ext[MAXEXT];
                    	GetItemText(wnd, ID_FILENAME, fn, MAXPATH);
						fnsplit(fn, NULL, NULL, nm, ext);
						strcpy(FileName, nm);
						strcat(FileName, ext);
						CreatePath(NULL, fn, FALSE, TRUE);
                    	if (IncompleteFilename(FileName))    {
                        	/* --- no file name yet --- */
            				DBOX *db = wnd->extension;
            				WINDOW cwnd = ControlWindow(db, ID_FILENAME);
	                    	strcpy(FileSpec, FileName);
	                    	strcpy(SrchSpec, FileName);
	                       	InitDlgBox(wnd);
							SendMessage(cwnd, SETFOCUS, TRUE, 0);
                        	return TRUE;
						}
                    }
                    break;
				}
                case ID_FILES:
                    switch ((int) p2)    {
						case ENTERFOCUS:
                        case LB_SELECTION:
                            /* selected a different filename */
                            GetDlgListText(wnd, FileName, ID_FILES);
                            PutItemText(wnd, ID_FILENAME, FileName);
                            break;
                        case LB_CHOOSE:
                            /* chose a file name */
                            GetDlgListText(wnd, FileName, ID_FILES);
                            SendMessage(wnd, COMMAND, ID_OK, 0);
                            break;
                        default:
                            break;
                    }
                    return TRUE;
                case ID_DIRECTORY:
                    switch ((int) p2)    {
						case ENTERFOCUS:
                            PutItemText(wnd, ID_FILENAME, FileSpec);
							break;
                    	case LB_CHOOSE:
						{
                        	/* chose dir */
                        	char dd[15];
                        	GetDlgListText(wnd, dd, ID_DIRECTORY);
							chdir(dd);
                        	InitDlgBox(wnd);
                            SendMessage(wnd, COMMAND, ID_OK, 0);
							break;
	                    }
						default:
							break;
					}
                    return TRUE;

                case ID_DRIVE:
                    switch ((int) p2)    {
						case ENTERFOCUS:
                            PutItemText(wnd, ID_FILENAME, FileSpec);
							break;
                    	case LB_CHOOSE:
						{
                        	/* chose dir */
                        	char dr[15];
                        	GetDlgListText(wnd, dr, ID_DRIVE);
							setdisk(*dr - 'A');
                        	InitDlgBox(wnd);
                            SendMessage(wnd, COMMAND, ID_OK, 0);
	                    }
						default:
							break;
					}
                    return TRUE;

                default:
                    break;
            }
        default:
            break;
    }
    return DefaultWndProc(wnd, msg, p1, p2);
}