Click here to Skip to main content
15,898,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRichEdit with Treeview - associating and saving Pin
Kayembi10-Oct-03 0:49
Kayembi10-Oct-03 0:49 
GeneralRe: RichEdit with Treeview - associating and saving Pin
Steve S10-Oct-03 1:42
Steve S10-Oct-03 1:42 
GeneralMFC printing: size and orientation Pin
zsnow9-Oct-03 23:40
zsnow9-Oct-03 23:40 
GeneralRe: MFC printing: size and orientation Pin
Steve S10-Oct-03 1:39
Steve S10-Oct-03 1:39 
GeneralRe: MFC printing: size and orientation Pin
zsnow10-Oct-03 2:14
zsnow10-Oct-03 2:14 
GeneralRe: MFC printing: size and orientation Pin
Steve S10-Oct-03 4:48
Steve S10-Oct-03 4:48 
GeneralRe: MFC printing: size and orientation Pin
Steve S10-Oct-03 4:56
Steve S10-Oct-03 4:56 
GeneralPrintDlgEx Pin
«_Superman_»9-Oct-03 23:11
professional«_Superman_»9-Oct-03 23:11 
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 »
GeneralAn interesting code Pin
FlyingDancer9-Oct-03 21:44
FlyingDancer9-Oct-03 21:44 
GeneralWhat does this do? Pin
Joaquín M López Muñoz9-Oct-03 21:51
Joaquín M López Muñoz9-Oct-03 21:51 
GeneralRe: What does this do? Pin
FlyingDancer9-Oct-03 22:20
FlyingDancer9-Oct-03 22:20 
GeneralRe: What does this do? Pin
jhwurmbach9-Oct-03 22:44
jhwurmbach9-Oct-03 22:44 
GeneralRe: What does this do? Pin
FlyingDancer9-Oct-03 23:24
FlyingDancer9-Oct-03 23:24 
GeneralRe: What does this do? Pin
jhwurmbach10-Oct-03 1:31
jhwurmbach10-Oct-03 1:31 
GeneralRe: What does this do? Pin
Steve S10-Oct-03 1:44
Steve S10-Oct-03 1:44 
GeneralRe: What does this do? Pin
jhwurmbach10-Oct-03 1:50
jhwurmbach10-Oct-03 1:50 
GeneralRe: What does this do? Pin
Steve S10-Oct-03 2:01
Steve S10-Oct-03 2:01 
GeneralRe: What does this do? Pin
FlyingDancer11-Oct-03 5:18
FlyingDancer11-Oct-03 5:18 
GeneralRe: What does this do? Pin
Joaquín M López Muñoz10-Oct-03 3:06
Joaquín M López Muñoz10-Oct-03 3:06 
GeneralRe: What does this do? Pin
FlyingDancer11-Oct-03 5:29
FlyingDancer11-Oct-03 5:29 
GeneralRe: What does this do? Pin
David Crow10-Oct-03 5:49
David Crow10-Oct-03 5:49 
GeneralRe: What does this do? Pin
FlyingDancer11-Oct-03 4:48
FlyingDancer11-Oct-03 4:48 
GeneralRe: An interesting code Pin
Anthony_Yio10-Oct-03 1:45
Anthony_Yio10-Oct-03 1:45 
GeneralRe: An interesting code Pin
TW10-Oct-03 2:30
TW10-Oct-03 2:30 
GeneralRe: An interesting code Pin
Earl Allen10-Oct-03 20:07
Earl Allen10-Oct-03 20:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.