如何保存在属性页上所做的更改

如何保存在属性页上所做的更改

本文介绍了当用户单击“应用"按钮时,如何保存在属性页上所做的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我已经使用"PROPSHEETPAGE"为打印机属性创建了一个新的属性页.

在该新属性页中,我保留了一个静态文本标签并编辑了文本框.
在该编辑文本框中输入数值后,属性表中的应用"按钮将被启用.
我单击了应用"按钮;关闭窗口并再次打开后,应用的更改不会反映出来. (即).在编辑"文本框中不存在输入的值.

编辑"文本框为空.

我需要的是:再次打开属性表时,以前所做的更改应该会反映出来.

我尝试使用SetPrinterData API.
它不起作用.

请帮我解决这个问题.

提前谢谢.
问候
希拉

****************************************************** *****
下面的代码无法正常工作.请帮助我...

Dear Friends,

I have created a new property page for a printer properties using "PROPSHEETPAGE".

In that new property page, I kept a static text label and edit text box.
After entering numeric values to that edit text box, the Apply Button in the property sheet gets enabled.
I clicked the APPLY Button; After closing the window and open again, applied changes is not reflected back. (Ie)., the entered values in the Edit text box is not present.

The Edit text box is empty.

What I need is: The previously done changes should get reflected back when I open the property sheet again.

I tried using SetPrinterData API.
It is not working.

Kindly help me out to solve this issue.

Thanks in advance.
Regards
Heera

*******************************************************
This below code is not working.. Pls help me...

#include "precomp.h"
#include "debug.h"
#include "resource.h"
#include "globals.h"
#include "devmode.h"
#include "oemui.h"
// This indicates to Prefast that this is a usermode driver file.
__user_driver;
////////////////////////////////////////////////////////
//      INTERNAL MACROS and DEFINES
////////////////////////////////////////////////////////
typedef struct _tagCBUserData
{
    HANDLE          hComPropSheet;
    HANDLE          hPropPage;
    POEMUIPSPARAM   pOEMUIParam;
    PFNCOMPROPSHEET pfnComPropSheet;
} CBUSERDATA, *PCBUSERDATA;

////////////////////////////////////////////////////////
//      INTERNAL PROTOTYPES
////////////////////////////////////////////////////////
LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam);
LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam);
LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam);
INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);


////////////////////////////////////////////////////////////////////////////////
//
// Initializes OptItems to display OEM device or document property UI.
//
//Added the below line for Warning Removal : warning C4100: ''pOEMUIParam'' : unreferenced formal parameter
#pragma warning( disable : 4100 )
HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam)
{
    HRESULT hResult = S_OK;
    VERBOSE("hrOEMPropertyPage entry.\r\n");
    switch(dwMode)
    {
        case OEMCUIP_DOCPROP:
          //  hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam);
            break;
        case OEMCUIP_PRNPROP:
          //  hResult = hrPrinterPropertyPage(dwMode, pOEMUIParam);
            break;
        default:
            // Should never reach this!
            ERR("hrOEMPropertyPage() Invalid dwMode");
            SetLastError(ERROR_INVALID_PARAMETER);
            hResult = E_FAIL;
            break;
    }
    return hResult;
}
////////////////////////////////////////////////////////////////////////////////
//
// Adds property page to printer property sheet.
//
HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam)
{
    LONG_PTR    lResult = 0;
    VERBOSE("hrOEMDevicePropertySheets entry\r\n");
    // Validate parameters.
    if( (NULL == pPSUIInfo)
        ||
        (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version)
      )
    {
        ERR("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n");
        // Return invalid parameter error.
        SetLastError(ERROR_INVALID_PARAMETER);
        return E_FAIL;
    }
    // Do action.
    switch(pPSUIInfo->Reason)
    {
        case PROPSHEETUI_REASON_INIT:
            {
                PROPSHEETPAGE   Page;
                // Init property page.
                memset(&Page, 0, sizeof(PROPSHEETPAGE));
                Page.dwSize = sizeof(PROPSHEETPAGE);
                Page.dwFlags = PSP_DEFAULT;
                Page.hInstance = ghInstance;
                Page.pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPPAGE);
                Page.pfnDlgProc = DevicePropPageProc;
                // Add property sheets.
                lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PROPSHEETPAGE, (LPARAM)&Page, 0);
            }
            break;
        case PROPSHEETUI_REASON_GET_INFO_HEADER:
            {
                PPROPSHEETUI_INFO_HEADER    pHeader = (PPROPSHEETUI_INFO_HEADER) lParam;
                pHeader->pTitle = (LPTSTR)PROP_TITLE;
                lResult = TRUE;
            }
            break;
        case PROPSHEETUI_REASON_GET_ICON:
            // No icon
            lResult = 0;
            break;
        case PROPSHEETUI_REASON_SET_RESULT:
            {
                PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam;
                lResult = pInfo->Result;
            }
            break;
        case PROPSHEETUI_REASON_DESTROY:
            lResult = TRUE;
            break;
    }
    pPSUIInfo->Result = lResult;
    return S_OK;
}

INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
	HWND hWndVal;
	hWndVal = GetDlgItem(hDlg, IDC_EDIT1);
	char strVal[20];
	int Val_len = 0;
	LPWSTR buffer = NULL;


    switch (uiMsg)
    {

		case WM_INITDIALOG:


			GetDlgItemText(hDlg,IDC_EDIT1, buffer,2);
			if (buffer != NULL)
			{
				SetWindowText(hWndVal, (LPCWSTR) buffer);
			}

			return TRUE;
        case WM_COMMAND:
            //if the textboxes are changed
			if (HIWORD(wParam) == EN_CHANGE)
			{
				SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
			}
            return TRUE;
        case WM_NOTIFY:
            {
		NMHDR* pnmh = (NMHDR*)lParam;
            if (pnmh->code == PSN_APPLY)
            {
				return TRUE;
            }
		if (pnmh->code == PSN_KILLACTIVE)
		{
		SetPrinterData(hDlg, OEMUI_VALUE, REG_DWORD, (PBYTE) (GetWindowText(hWndVal, (LPWSTR) strVal, 20)), sizeof(DWORD));

		GetWindowText(hWndVal, (LPWSTR) strVal, 20);
		Val_len = GetWindowTextLength(hWndVal);
			if (Val_len > 1)
			{
				//Error Enter value between 1 to 9
				MessageBox(hDlg, L"Enter value between 1 to 9", L"TESTING", MB_ICONWARNING | MB_OK);
			}
			else
			{
				SetWindowText(hWndVal, (LPCWSTR) strVal);
			}

			}
            break;
            }
            break;
    }
    return FALSE;
}
#pragma warning(pop)

推荐答案



这篇关于当用户单击“应用"按钮时,如何保存在属性页上所做的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:00