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"
__user_driver;
typedef struct _tagCBUserData
{
HANDLE hComPropSheet;
HANDLE hPropPage;
POEMUIPSPARAM pOEMUIParam;
PFNCOMPROPSHEET pfnComPropSheet;
} CBUSERDATA, *PCBUSERDATA;
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);
#pragma warning( disable : 4100 )
HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam)
{
HRESULT hResult = S_OK;
VERBOSE("hrOEMPropertyPage entry.\r\n");
switch(dwMode)
{
case OEMCUIP_DOCPROP:
break;
case OEMCUIP_PRNPROP:
break;
default:
ERR("hrOEMPropertyPage() Invalid dwMode");
SetLastError(ERROR_INVALID_PARAMETER);
hResult = E_FAIL;
break;
}
return hResult;
}
HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam)
{
LONG_PTR lResult = 0;
VERBOSE("hrOEMDevicePropertySheets entry\r\n");
if( (NULL == pPSUIInfo)
||
(PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version)
)
{
ERR("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n");
SetLastError(ERROR_INVALID_PARAMETER);
return E_FAIL;
}
switch(pPSUIInfo->Reason)
{
case PROPSHEETUI_REASON_INIT:
{
PROPSHEETPAGE 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;
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:
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 (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)
{
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)