![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Aug 2001
Posts: 3
| Thanks Sugunan |
| Sugunan is offline | |
| | #2 |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,452
| Try, PageSetUp->lStructSize=sizeof(PAGESETUPDLG) ; PageSetUp->hwndOwner= hWnd ; PageSetUp->hDevMode = NULL ; PageSetUp->hDevNames= NULL; PageSetUp->Flags=PSD_RETURNDEFAULT; //stack the structure with data for the default printer PageSetupDlg(PageSetUp); This should call the Print Dlg without showing it, returning the default printers settings. The DevMode struct will contain the paper size. Also you can use the EnumPrinters() function, with the PRINTER_ENUM_DEFAULT flag. You will need to know what OS is running, to tell what PRINT_INFO struct to use, and watch for truncated printer names under NT/2000. Then create a DC and use GetDeviceCaps() on the printer DC. iWidth =GetDeviceCaps(hdcTemp,HORZRES); iHeight =GetDeviceCaps(hdcTemp,VERTRES); I find, under NT/2000 GetProfileString("windows", "device", (LPCTSTR) &szBuffer,(LPTSTR) &szOutputString, 255); will get the printer name without the truncation. (If the printer has a long driver name it won't fit in the string, the last characters are lost and so you can't getDC with it) Isn't this easy! ///////// I should read these questions more carefully. This is how to GET the paper size. Last edited by novacain; 08-30-2001 at 09:46 PM. |
| novacain is offline | |
| | #3 |
| Registered User Join Date: Aug 2001
Posts: 3
| Thanks for the fast response Dear Novacain, thank you for the fast response and the tip to execute the Print Setup Dialog without actually showing it. May be there is a way on similar lines to set the property also. I shall read the MSDN documantation in detail. regards Sugunan |
| Sugunan is offline | |
| | #4 |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,452
| A way round the problem may be to save the data, DEVNAME and DEVMODE from the PAGESETUP struct, to disk and load them up when you need a new print. All you need are the settings to save in the first place. |
| novacain is offline | |
| | #5 |
| Registered User Join Date: Aug 2001
Posts: 3
| Just one more question Thanks for the tip. Is it necessary to free the HGLOBAL returned in the hDevMode parameter? MSDN doesn't say anything about this. thanks Sugunan |
| Sugunan is offline | |
| | #6 |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,452
| As far as I know you do not have to free the HGLOBAL returned DEVMODE or DEVNAME structure. You may have to use GlobalLock on them to 'type cast' them to the structures to use the data returned in them. |
| novacain is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Issues and questions about queues | Nazgulled | C Programming | 36 | 12-13-2007 02:03 PM |
| Using variables in system() | Afro | C Programming | 8 | 07-03-2007 12:27 PM |
| Trouble with DMA Segmentation Faults | firestorm717 | C Programming | 2 | 05-07-2006 09:20 PM |
| OpenGL and Windows | sean345 | Game Programming | 5 | 06-24-2002 10:14 PM |
| Tab Controls - API | -KEN- | Windows Programming | 7 | 06-02-2002 09:44 AM |