|
Hi,
Actually i want to know that, whether the printer DC is to be resized according to the paper sizes.
If yes, how can i change the size?
Me already checked with the following code
for( int nIndex = 0; nIndex < nNumPapers; nIndex++ )
{
CString csPaperSize = _T( pPaperNames ); /* Got from GetDeviceCapabilities */
memcpy( pDevModeOutput->dmFormName, csPaperSize.GetBuffer(csPaperSize.GetLength()), 32) ;
HDC hTempHandle;
pDevModeOutput->dmFields |= DM_FORMNAME;
CString csTemp( _T( "" ));
hTempHandle = ResetDC( hDc, pDevModeOutput );
nPixelX = GetDeviceCaps( hDc, HORZRES );
nPixelY = GetDeviceCaps( hDc, VERTRES );
csTemp.Format( _T( "%s : %d, %d" ), pDevModeOutput->dmFormName, nPixelX, nPixelY );
AfxMessageBox( csTemp );
}
but the nPixelX, nPixelY always getting the same for all paper sizes
Regards,
Krishnakumar
|
|
|
|
|
Did you see DEVMODE ? here[^] (dmPaperSize )
|
|
|
|
|
Hi,
The way I change the paper size is given below
pDevModeOutput->dmPaperSize = 0; // It should be set to zero if paper length and width are given seperately
pDevModeOutput->dmPaperLength = pPaperSizes[nSelection].y; // 2970 in case A4
pDevModeOutput->dmPaperWidth = pPaperSizes[nSelection].x; // 2100 in case A4
CString csPaperSize = _T( "" );
memcpy( pDevModeOutput->dmFormName, csPaperSize.GetBuffer(csPaperSize.GetLength()), 32) ;
pDevModeOutput->dmPrintQuality = -1;
pDevModeOutput->dmYResolution = 0;
//pDevModeOutput->dmScale = 90;
pDevModeOutput->dmFields = DM_PAPERSIZE |
DM_PAPERLENGTH |
DM_PAPERWIDTH |
DM_FORMNAME |
DM_PRINTQUALITY |
DM_YRESOLUTION; // DM_SCALE;
// To get the Devmode structure filled
if( !DocumentProperties( NULL, // handle to parent window
hHandle, // handle to printer object
csPrinterName.GetBuffer(csPrinterName.GetLength()+1), // device name
pDevModeOutput, // modified device mode
0, // original device mode
DM_IN_BUFFER// mode options
))
{
return;
}
hDc = CreateDC( NULL, csPrinterName.operator LPCTSTR(), NULL, pDevModeOutput );
nDPIX = GetDeviceCaps( hDc, LOGPIXELSX );
nDPIY = GetDeviceCaps( hDc, LOGPIXELSY );
Actually I don't know the procedure that how to change the paper size. I think some mistakes are there in my code or something is missing. I have to draw a rectangle that is fit into the specified paper size.
Please reply.
Krishnakumar
|
|
|
|
|
|
Hopefully this little cut & paste will help you...
Iain.
szPrintablePixelsMax.cx= ::GetDeviceCaps (hPrinterDC, HORZRES);
szPrintablePixelsMax.cy= ::GetDeviceCaps (hPrinterDC, VERTRES);
szPrintableArea.cx = ::GetDeviceCaps (hPrinterDC, HORZSIZE);
szPrintableArea.cy = ::GetDeviceCaps (hPrinterDC, VERTSIZE);
|
|
|
|
|
Me already tried the below code
szPrintablePixelsMax.cx= ::GetDeviceCaps (hPrinterDC, HORZRES);
szPrintablePixelsMax.cy= ::GetDeviceCaps (hPrinterDC, VERTRES);
it always returns the same value for all sheet sizes.
Regards,
Kumar
|
|
|
|
|
That's not a surprise - its returning the DPI for the printer. There were FOUR lines in the message I posted, and you are looking at the wrong two. Try the other two lines.
Iain.
|
|
|
|
|
As per MSDN, the below code returns the width and height in pixels,
int nX = GetDeviceCaps( hDc, HORZRES );
int nY = GetDeviceCaps( hDc, VERTRES );
Actually i meant that for some of the printers ( HP LaserJet 4250 PCL 5e ), the code gives different values for different sheet sizes.
But the problem is that some of other printers (hp deskjet 3500 series) gives the same values for different papaer sizes.
I am setting the size using the "DocumentProperties" function as below
pDevModeOutput->dmPaperSize = 0; // It should be set to zero if paper length and width are given seperately
pDevModeOutput->dmPaperLength = pPaperSizes[nSelection].y; // 2100 in case A4
pDevModeOutput->dmPaperWidth = pPaperSizes[nSelection].x; // 2970 in case A4
CString csPaperSize = _T( "" );
memcpy( pDevModeOutput->dmFormName, csPaperSize.GetBuffer(csPaperSize.GetLength()), 32) ;
pDevModeOutput->dmPrintQuality = -1;
pDevModeOutput->dmYResolution = 0;
//pDevModeOutput->dmScale = 90;
pDevModeOutput->dmFields = DM_PAPERSIZE |
DM_PAPERLENGTH |
DM_PAPERWIDTH |
DM_FORMNAME |
DM_PRINTQUALITY |
DM_YRESOLUTION; // DM_SCALE;
// To get the Devmode structure filled
if( !DocumentProperties( NULL, // handle to parent window
hHandle, // handle to printer object
csPrinterName.GetBuffer(csPrinterName.GetLength()+1), // device name
pDevModeOutput, // modified device mode
0, // original device mode
DM_IN_BUFFER// mode options
))
{
return;
}
Krishnakumar
|
|
|
|
|
What is the maximum possible size of an INI file in Windows XP to operate with standard windows APIs?
- NS -
|
|
|
|
|
|
NS17 wrote: What is the maximum possible size of an INI file in Windows XP to operate with standard windows APIs?
The maximum valid size for a .INI file is 64 kilobytes (K). Reference[^]
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
If API is used for .INI, then the Maximum limit is 64KB.
Come online at:-
jubinc@skype
|
|
|
|
|
HOWEVER, he explicitely asked for INI Files in Windows XP.
For those who havent noticed: The KB articles list all articles they apply to. In this case, the Windows Series up to Windows for Workgroups.
This might apply to Windows 95/98, but most certainly not to Windows XP.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Sebastian Schneider wrote: This might apply to Windows 95/98, but most certainly not to Windows XP.
Why would you think it would be any different for XP?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello everyone,
Suppose I have a file created with FILE_ATTRIBUTE_NORMAL attribute. I think it means attribute FILE_FLAG_WRITE_THROUGH is not enabled. Is my understanding correct?
And I think if I do not enable the FILE_FLAG_WRITE_THROUGH attribute, even if flush operation (function call) will not *truly* dump data to disk. Is my understanding also correct?
So, my question is, when will the data be dumped to disk -- only when we close the file?
thanks in advance,
George
|
|
|
|
|
FILE_FLAG_WRITE_THROUGH is an instruction to the OS about how you want it to handle cacheing, it has nothing to do with file attributes.
|
|
|
|
|
Hi Mike,
I heard sometimes people will mention that if we do not enable FILE_FLAG_WRITE_THROUGH mode, data will be not safe (data missing or inconsistency)? Why?
regards,
George
|
|
|
|
|
Imagine if that were true. How often do you add FILE_FLAG_WRITE_THROUGH to CreateFile() calls? I don't think I've ever used it. I imagine that many Windows programmers are like me, and don't use it (if they even know about it). Now think about all the programs those people have written. Do you think all of them have data-loss bugs?
|
|
|
|
|
Hi Mike, I think FILE_FLAG_WRITE_THROUGH will degrade the performance since it needs to sync the OS buffer and disk more frequently. So, I am wondering whether each time when we issue write API (without flush), the content will always be written to the disk?
Why people does not use FILE_FLAG_WRITE_THROUGH? It is a good question. I think the answer to this question is to answer what are the differences between the cases when FILE_FLAG_WRITE_THROUGH is enabled or disabled?
Any comments?
regards,
George
|
|
|
|
|
I wanted to operate the menu selection via space key from the keyboard.
How would I do that?
For Ex. If we select the Menu File->Open. If we hit the Enter key on
Open menu it opens File Dialog. I wanted to do the same operation on
space key.
Raj
|
|
|
|
|
Hello all,
I want to check for some folder c:\\a\\b and create if that folders does not exits.
Till now I have done with checking and creating the c:\\a
Can anyone help me hw to create the sub folder along with the main folder.
I am using below code.
<br />
int ret;<br />
char buf[ ] = "C:\\A";<br />
ret = PathFileExists(buf);<br />
if(ret == 0)<br />
{<br />
CreateDirectory(buf,NULL); <br />
}
if I give char buf[ ] = “C:\\A\\B\\”; this code has no effect .
|
|
|
|
|
one way use of PathFileExists to check its exist or no(you use of it)
(2) you can use of FindFirstFile/FindNext
(3) if you have folders name you can use of SetCurrectDirectory(); and check return value of it 0 or 1
Suresh H wrote: “C:\\A\\B\\”;
"C:\\A\\B"
|
|
|
|
|
What exactly is that you are not able to do? Weren't you answered[^] for this question already?
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
I was trying to create main and sub folder at a time so that was the problem
Now I changed my code as below , now its working correctly..
int ret;<br />
char buf[ ] = "C:\\A"; <br />
char buf1[ ] = "C:\\A\\B"<br />
ret = PathFileExists(buf);<br />
<br />
if(ret == 0)<br />
{<br />
CreateDirectory(buf,NULL); <br />
CreateDirectory(buf1,NULL);<br />
}
Thank you WhiteSky , brahmma & Prasad for yr help.
|
|
|
|
|
One question you want to use of
char buf[ ] = "C:\\A";
char buf1[ ] = "C:\\A\\B"
char buf2[ ] = "C:\\A\\B\\C"
...
...
char buf21[ ] = "C:\\A\\B\\C\\...T"
|
|
|
|