Click here to Skip to main content
15,888,286 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhelp, Implement Flashwindow like MNS Msg? Pin
OGIR18-Sep-01 12:30
OGIR18-Sep-01 12:30 
AnswerRe: help, Implement Flashwindow like MNS Msg? Pin
Michael P Butler18-Sep-01 22:21
Michael P Butler18-Sep-01 22:21 
Generalchar* as template parameter Pin
Aaron Schaefer18-Sep-01 12:22
Aaron Schaefer18-Sep-01 12:22 
GeneralRe: char* as template parameter Pin
Michael Dunn18-Sep-01 21:16
sitebuilderMichael Dunn18-Sep-01 21:16 
GeneralRe: char* as template parameter Pin
Aaron Schaefer19-Sep-01 3:48
Aaron Schaefer19-Sep-01 3:48 
GeneralDebug vs Release Pin
18-Sep-01 11:58
suss18-Sep-01 11:58 
GeneralRe: Debug vs Release Pin
Tomasz Sowinski19-Sep-01 1:06
Tomasz Sowinski19-Sep-01 1:06 
GeneralWin32 Printing Problems - 32character device names. Pin
Mike Doner18-Sep-01 11:19
Mike Doner18-Sep-01 11:19 
Hello folks,

I have a question with regards to printing in Win32 to printers who's name exceed the DEVMODE.dmDeviceName[32] limit.

In our product, we allow the user to set a default printer. We populate the possible printer list by using the following code:

flags = PRINTER_ENUM_LOCAL;

if ( IsWindows95 () )
level = 5;
else
flags |= PRINTER_ENUM_CONNECTIONS;

pbuf = (PBYTE) NULL;
EnumPrinters ( flags, NULL, level, pbuf, 0, &size, &num );

if ( asize > 0 )
{
pbuf = (PBYTE ) calloc ( size, 1 );
if ( pbuf == (PBYTE) NULL )
goto exit_func;
size = num = 0;
EnumPrinters ( flags, NULL, level, pbuf, asize, &size, &num );
if ( size == 0 || num == 0 )
goto exit_func;

if ( IsWindows95 ( ) )
pinf5 = (PRINTER_INFO_5 *) pbuf;
else
pinf4 = (PRINTER_INFO_4 *) pbuf;
retval = TRUE;

/* Now fill the listbox with the printers available. */

SendDlgItemMessage ( hwnd, id, CB_RESETCONTENT, 0, 0 );
for ( i = 0; i < num; i++ )
{
if ( IsWindows95 () )
{
SendDlgItemMessage ( hwnd, id, CB_ADDSTRING,
(WPARAM) 0, (LPARAM) pinf5->pPrinterName );
pinf5++; /* Next structure */
}
else
{
SendDlgItemMessage ( hwnd, id, CB_ADDSTRING,
(WPARAM) 0, (LPARAM) pinf4->pPrinterName );
pinf4++; /* Next structure */
}
}

No problems here, we simply store the pPrinterName in one of our variables such that when the time comes to print, we build the DEVMODE structure, then create our dc.

The problem comes when the user selects a printer that exceeds the 32 character maximum, (ie, network printer), where the name could be "\\nt200\FOO\FOO\PRINTER1010101". If the variable we stored was something like "\\nt200\laser1", everything would be fine, the document would print without any problems.

In the MSDN documentation it notes the following on the dmDeviceName variable:

Specifies the the "friendly" name of the printer; for example, "PCL/HP LaserJet" in the case of PCL/HP LaserJet®. This string is unique among device drivers. Note that this name may be truncated to fit in the dmDeviceName array.

How does Windows handle the case where the printer name exceeds the 32character max? Is there a field I could put the server name?

Mike.
GeneralWin2000/XP Job Kernel Object Pin
18-Sep-01 11:12
suss18-Sep-01 11:12 
GeneralMFC Extension DLL Pin
sfanjoy18-Sep-01 10:56
sfanjoy18-Sep-01 10:56 
GeneralRe: MFC Extension DLL Pin
Tomasz Sowinski18-Sep-01 11:10
Tomasz Sowinski18-Sep-01 11:10 
GeneralExecuting a database macro from VC++ Pin
duggie18-Sep-01 10:55
duggie18-Sep-01 10:55 
GeneralRe: Executing a database macro from VC++ Pin
Carlos Antollini18-Sep-01 11:01
Carlos Antollini18-Sep-01 11:01 
GeneralRe: Executing a database macro from VC++ Pin
duggie18-Sep-01 11:11
duggie18-Sep-01 11:11 
GeneralRe: Executing a database macro from VC++ Pin
Carlos Antollini18-Sep-01 11:24
Carlos Antollini18-Sep-01 11:24 
GeneralRe: Executing a database macro from VC++ Pin
duggie19-Sep-01 4:01
duggie19-Sep-01 4:01 
GeneralRe: Executing a database macro from VC++ Pin
Carlos Antollini19-Sep-01 4:23
Carlos Antollini19-Sep-01 4:23 
GeneralRe: Executing a database macro from VC++ Pin
Todd Smith18-Sep-01 11:57
Todd Smith18-Sep-01 11:57 
GeneralRe: Executing a database macro from VC++ Pin
duggie19-Sep-01 4:06
duggie19-Sep-01 4:06 
GeneralRe: Executing a database macro from VC++ Pin
Steen Krogsgaard18-Sep-01 23:06
Steen Krogsgaard18-Sep-01 23:06 
GeneralPosition of SystemTray area Pin
Michael P Butler18-Sep-01 10:45
Michael P Butler18-Sep-01 10:45 
GeneralRe: Position of SystemTray area Pin
Carlos Antollini18-Sep-01 11:16
Carlos Antollini18-Sep-01 11:16 
QuestionModifyMenu Why this doesn´t work ? Pin
Braulio Dez18-Sep-01 5:05
Braulio Dez18-Sep-01 5:05 
GeneralMinimize a dialog type app Pin
RobJones18-Sep-01 5:00
RobJones18-Sep-01 5:00 
GeneralRe: Minimize a dialog type app Pin
Michael P Butler18-Sep-01 5:06
Michael P Butler18-Sep-01 5:06 

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.