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

PrintDlgEx

Scheduled Pinned Locked Moved C / C++ / MFC
c++
1 Posts 1 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.
  • _ Offline
    _ Offline
    _Superman_
    wrote on last edited by
    #1

    Hi, I'm working on Windows 2000 and VC++ 6.0. I need to show the new print property sheet available in windows 2000 onwards. I found a class called CPrintDialogEx that could display it but unfortunately it is available only in VC 7.0. So I did the following to get the property sheet - I created a dialog based application. The following is in the .h file of the dialog class

    typedef struct tagPRINTPAGERANGE {
    DWORD nFromPage;
    DWORD nToPage;
    } PRINTPAGERANGE, *LPPRINTPAGERANGE;

    typedef struct tagPDEX {
    DWORD lStructSize;
    HWND hwndOwner;
    HGLOBAL hDevMode;
    HGLOBAL hDevNames;
    HDC hDC;
    DWORD Flags;
    DWORD Flags2;
    DWORD ExclusionFlags;
    DWORD nPageRanges;
    DWORD nMaxPageRanges;
    LPPRINTPAGERANGE lpPageRanges;
    DWORD nMinPage;
    DWORD nMaxPage;
    DWORD nCopies;
    HINSTANCE hInstance;
    LPCTSTR lpPrintTemplateName;
    LPUNKNOWN lpCallback;
    DWORD nPropertyPages;
    HPROPSHEETPAGE *lphPropertyPages;
    DWORD nStartPage;
    DWORD dwResultAction;
    } PRINTDLGEX, *LPPRINTDLGEX;

    In a button click handler the following code is done -

    typedef HRESULT (\*Print)(LPPRINTDLGEX lppd);
    
    HMODULE hMod = LoadLibrary("C:\\\\WINNT\\\\system32\\\\comdlg32.dll");
    Print prn = (Print)GetProcAddress(hMod, "PrintDlgExA");
    
    PRINTDLGEX stprn;
    memset(&stprn, 0, sizeof PRINTDLGEX);
    
    stprn.lStructSize = sizeof PRINTDLGEX;
    stprn.hwndOwner = m\_hWnd;
    stprn.nCopies = 1;
    stprn.Flags = PD\_ALLPAGES|PD\_USEDEVMODECOPIES|PD\_HIDEPRINTTOFILE|PD\_NOPAGENUMS|PD\_NOSELECTION|0x00800000;
    stprn.Flags &= ~PD\_RETURNIC;
    stprn.nStartPage = -1;
    stprn.dwResultAction = 0;
    
    prn(&stprn);
    

    Now the dialog is displayed but on closing the dialog it breaks. I suspect it to be the wrong parameter used as the callback routine in the stprn.lpCallback parameter of the structure. I tried giving many other parameters for the callback function, but in vain Has anybody done this or does anybody have an idea as to what I must do, please reply. Regards Santosh « Superman »

    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