limiting print margins
-
Hi All, Is there a way of limiting the size of the margins when printing. At present I can't think of a better way than subclassing the pring dialog box and intercepting text input to the margin size edit boxes. The reason for this is that our test team have complained that if they put a huge number into the text margin boxes it messes up the appearance of the document and so should be prevented. Can you believe it :doh:
Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.
-
Hi All, Is there a way of limiting the size of the margins when printing. At present I can't think of a better way than subclassing the pring dialog box and intercepting text input to the margin size edit boxes. The reason for this is that our test team have complained that if they put a huge number into the text margin boxes it messes up the appearance of the document and so should be prevented. Can you believe it :doh:
Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.
I've done a bit of digging, and neither PRINTDLG or PRINTDLGEX have a margins member. So these margins you are talking about are app dependent, so we'd need to know more about the context. If this is a custom print box, then start looking at the code there... Iain. ps, Good surname...
Codeproject MVP for C++, I can't believe it's for my lounge posts...
-
I've done a bit of digging, and neither PRINTDLG or PRINTDLGEX have a margins member. So these margins you are talking about are app dependent, so we'd need to know more about the context. If this is a custom print box, then start looking at the code there... Iain. ps, Good surname...
Codeproject MVP for C++, I can't believe it's for my lounge posts...
Hi Iain, The actual dlg box in question can be seen in IE. If you click on print preview, the window that comes up has a button which fires up a page setup dialog box. It is on this that the margins can be altered. Sorry for the lack of clarity. ps. Best damn surname there is...
Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.
-
Hi All, Is there a way of limiting the size of the margins when printing. At present I can't think of a better way than subclassing the pring dialog box and intercepting text input to the margin size edit boxes. The reason for this is that our test team have complained that if they put a huge number into the text margin boxes it messes up the appearance of the document and so should be prevented. Can you believe it :doh:
Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.
If you are discussing about the page Setup dialog that you use in your own application, i also think so, you may need to subclass the dialog. First of all, obviously, if the margins are overbound it messes up, that is known to the user, do you need to correct it? If you want to disable the margin fields, simply use PSD_DISABLEMARGINS flags in [PageSetupDlg Function^]. Or you can validate the margin data entry, by subclassing it. That is setting the hook procedure.
PAGESETUPDLG psd; // common dialog box structure
// Initialize PAGESETUPDLG
ZeroMemory(&psd, sizeof(psd));
psd.lStructSize = sizeof(psd);
psd.hwndOwner =
....
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGESETUPHOOK
;
psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)PageSetupHook;if (PageSetupDlg(&psd)==TRUE) {
And in the hook procedure you can validate the text entry,
BOOL CALLBACK PageSetupHook(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{switch (uMsg)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;case WM\_COMMAND: if ((LOWORD(wParam) == 1155 // ID of LEFT MARGIN EDIT CTRL (from PrnSetup.Dlg) && HIWORD(wParam) == EN\_CHANGE) { // write the validation code
You can completely customise the page setup dialog with your own dialog by create a dialog template resource by modifying the default template available in VC\PlatformSDK\Include\PrnSetup.Dlg by specifying the flags,
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGESETUPHOOK |PSD_ENABLEPAGESETUPTEMPLATE
;
....
psd.lpPageSetupTemplateName = MAKEINTRESOURCE(IDD_PAGESETUP); // your dialog template
psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)PageSetupHook;
psd.hInstance = hInstance;see also [Customizing the Page Setup Dialog Box^]
-
If you are discussing about the page Setup dialog that you use in your own application, i also think so, you may need to subclass the dialog. First of all, obviously, if the margins are overbound it messes up, that is known to the user, do you need to correct it? If you want to disable the margin fields, simply use PSD_DISABLEMARGINS flags in [PageSetupDlg Function^]. Or you can validate the margin data entry, by subclassing it. That is setting the hook procedure.
PAGESETUPDLG psd; // common dialog box structure
// Initialize PAGESETUPDLG
ZeroMemory(&psd, sizeof(psd));
psd.lStructSize = sizeof(psd);
psd.hwndOwner =
....
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGESETUPHOOK
;
psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)PageSetupHook;if (PageSetupDlg(&psd)==TRUE) {
And in the hook procedure you can validate the text entry,
BOOL CALLBACK PageSetupHook(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{switch (uMsg)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;case WM\_COMMAND: if ((LOWORD(wParam) == 1155 // ID of LEFT MARGIN EDIT CTRL (from PrnSetup.Dlg) && HIWORD(wParam) == EN\_CHANGE) { // write the validation code
You can completely customise the page setup dialog with your own dialog by create a dialog template resource by modifying the default template available in VC\PlatformSDK\Include\PrnSetup.Dlg by specifying the flags,
psd.Flags = PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGESETUPHOOK |PSD_ENABLEPAGESETUPTEMPLATE
;
....
psd.lpPageSetupTemplateName = MAKEINTRESOURCE(IDD_PAGESETUP); // your dialog template
psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)PageSetupHook;
psd.hInstance = hInstance;see also [Customizing the Page Setup Dialog Box^]
Thank you so much Rajkumar, First of all, to respond to your comment: "First of all, obviously, if the margins are overbound it messes up, that is known to the user, do you need to correct it?" I couldn't agree more. It's another completely ridiculous example user madness. Unfortunately, my inclination to tell the user not to set stupid values has been overruled in this case, so here I am. My position is that the page setup dialog box is launched from IE. Therefore, I can either subclass IE's window or I can create my own one and replace the existing dialog box. Is there any way of applying the approach you showed me to an existing Page Setup dialog box owned by IE. I’m working from an ActiveX control running in IE? Many thanks
Cheers Tom Philosophy: The art of never getting beyond the concept of life. Religion: Morality taking credit for the work of luck.
modified on Friday, January 16, 2009 5:33 AM