Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. limiting print margins

limiting print margins

Scheduled Pinned Locked Moved C / C++ / MFC
collaboration
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TClarke
    wrote on last edited by
    #1

    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 R 2 Replies Last reply
    0
    • T TClarke

      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 Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      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...

      T 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        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...

        T Offline
        T Offline
        TClarke
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • T TClarke

          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.

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #4

          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^]

          T 1 Reply Last reply
          0
          • R Rajkumar R

            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^]

            T Offline
            T Offline
            TClarke
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups