Dear API gurus;
I am using Progress V8.0, it does not have PRINTER-NAME attribute on SESSION
handle. I want to one of followings:
a) Use SYSTEM-DIALOG PRINTER-SETUP statement and pass the printer name to a
DLL I made
b) EnumPrinters to list all printer configured on my Windows then pass
selected printer to the DLL
c) PrintDLG in the DLL to select a printer configured.
All of my trial was failed.
- NT 4.0/SP3
- Our company has more than hundreds of printers on network and I have
configuration with 2 remote printer (EnumPrinters(PRINTER_ENUM_REMOTE, ...)
returns hundreds of printer and does not return port-number, so not useful.
- Most of them including thunking is from Jurjen Dijkstra's sample
1) Isn't there any way to get the printer name which set by the PRINTER-SETUP
(in Progress or in C) ?
2) My printers are not attached to Local Printer port. Is it the reason why
EnumPrinters(PRINTER_ENUM_LOCAL) returns nothing
3) If it is not possible, then can I make Printer Dialog in the DLL?
The DLL prints on default printer and I just insert SetPrinter() to see if I
can put Printer Dialog before finding default printer, it did not have compile
error, no run-time complaint and no-screen shown on the screen.
*** I just started C programming ***
<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
int StartDocument( void )
{
char DeviceName[128], DeviceSpecs[255];
int FirstPos;
DEVMODE DefaultDevMode, DevMode;
DOCINFO DocInfo;
memset( DeviceSpecs, '\0', 255 );
memset( DeviceName, '\0', 128 );
SetPrinter();
GetProfileString( "windows",
"device",
"-unknown-",
DeviceSpecs,
sizeof( DeviceSpecs )
);
FirstPos = strcspn( DeviceSpecs, "," );
strncpy( DeviceName, DeviceSpecs, FirstPos-- );
if ( strcmp( DeviceName, "-unknown-" ) == 0 )
{
// Error on getting default printer
return 2;
}
DocumentProperties( 0,
0,
DeviceName,
&DefaultDevMode,
0,
DM_OUT_BUFFER
);
DefaultDevMode.dmOrientation = DM_ORIENTATION;
DefaultDevMode.dmPaperSize = DMORIENT_PORTRAIT;
DocumentProperties( 0,
0,
DeviceName,
&DevMode,
&DefaultDevMode,
DM_IN_BUFFER + DM_OUT_BUFFER
);
hPrinterDC = CreateDC( "WINSPOOL",
DeviceName,
0,
&DevMode
);
if ( hPrinterDC == 0 )
{
// Error on CreateDC
return 3;
}
DocInfo.cbSize = sizeof( DOCINFO );
DocInfo.lpszDocName = "Bar Code";
DocInfo.lpszOutput = (LPTSTR) NULL;
DocInfo.lpszDatatype = (LPTSTR) NULL;
DocInfo.fwType = 0;
if ( StartDoc( hPrinterDC, &DocInfo ) < 1 )
{
// Error on StartDoc
return 2;
}
return 0;
}
void SetPrinter( void )
{
PRINTDLG pd;
HWND hwnd;
// Initialize PRINTDLG
ZeroMemory(&pd, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = hwnd;
pd.hDevMode = NULL; // Don't forget to free or store hDevMode.
pd.hDevNames = NULL; // Don't forget to free or store hDevNames.
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
if (PrintDlg(&pd)==TRUE) {
// GDI calls to render output.
// Delete DC when done.
DeleteDC(pd.hDC);
}
}
[/code]
Thanks in advance
Simon Kim
____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at http://webmail.netscape.com.
I am using Progress V8.0, it does not have PRINTER-NAME attribute on SESSION
handle. I want to one of followings:
a) Use SYSTEM-DIALOG PRINTER-SETUP statement and pass the printer name to a
DLL I made
b) EnumPrinters to list all printer configured on my Windows then pass
selected printer to the DLL
c) PrintDLG in the DLL to select a printer configured.
All of my trial was failed.
- NT 4.0/SP3
- Our company has more than hundreds of printers on network and I have
configuration with 2 remote printer (EnumPrinters(PRINTER_ENUM_REMOTE, ...)
returns hundreds of printer and does not return port-number, so not useful.
- Most of them including thunking is from Jurjen Dijkstra's sample
1) Isn't there any way to get the printer name which set by the PRINTER-SETUP
(in Progress or in C) ?
2) My printers are not attached to Local Printer port. Is it the reason why
EnumPrinters(PRINTER_ENUM_LOCAL) returns nothing
3) If it is not possible, then can I make Printer Dialog in the DLL?
The DLL prints on default printer and I just insert SetPrinter() to see if I
can put Printer Dialog before finding default printer, it did not have compile
error, no run-time complaint and no-screen shown on the screen.
*** I just started C programming ***
<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
int StartDocument( void )
{
char DeviceName[128], DeviceSpecs[255];
int FirstPos;
DEVMODE DefaultDevMode, DevMode;
DOCINFO DocInfo;
memset( DeviceSpecs, '\0', 255 );
memset( DeviceName, '\0', 128 );
SetPrinter();
GetProfileString( "windows",
"device",
"-unknown-",
DeviceSpecs,
sizeof( DeviceSpecs )
);
FirstPos = strcspn( DeviceSpecs, "," );
strncpy( DeviceName, DeviceSpecs, FirstPos-- );
if ( strcmp( DeviceName, "-unknown-" ) == 0 )
{
// Error on getting default printer
return 2;
}
DocumentProperties( 0,
0,
DeviceName,
&DefaultDevMode,
0,
DM_OUT_BUFFER
);
DefaultDevMode.dmOrientation = DM_ORIENTATION;
DefaultDevMode.dmPaperSize = DMORIENT_PORTRAIT;
DocumentProperties( 0,
0,
DeviceName,
&DevMode,
&DefaultDevMode,
DM_IN_BUFFER + DM_OUT_BUFFER
);
hPrinterDC = CreateDC( "WINSPOOL",
DeviceName,
0,
&DevMode
);
if ( hPrinterDC == 0 )
{
// Error on CreateDC
return 3;
}
DocInfo.cbSize = sizeof( DOCINFO );
DocInfo.lpszDocName = "Bar Code";
DocInfo.lpszOutput = (LPTSTR) NULL;
DocInfo.lpszDatatype = (LPTSTR) NULL;
DocInfo.fwType = 0;
if ( StartDoc( hPrinterDC, &DocInfo ) < 1 )
{
// Error on StartDoc
return 2;
}
return 0;
}
void SetPrinter( void )
{
PRINTDLG pd;
HWND hwnd;
// Initialize PRINTDLG
ZeroMemory(&pd, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = hwnd;
pd.hDevMode = NULL; // Don't forget to free or store hDevMode.
pd.hDevNames = NULL; // Don't forget to free or store hDevNames.
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
if (PrintDlg(&pd)==TRUE) {
// GDI calls to render output.
// Delete DC when done.
DeleteDC(pd.hDC);
}
}
[/code]
Thanks in advance
Simon Kim
____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at http://webmail.netscape.com.