Click here to Skip to main content
15,911,762 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help with rand() definition Pin
Randor 12-Jun-09 7:16
professional Randor 12-Jun-09 7:16 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 8:02
Grimes12-Jun-09 8:02 
GeneralRe: Help with rand() definition Pin
harold aptroot12-Jun-09 8:50
harold aptroot12-Jun-09 8:50 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 17:03
Grimes12-Jun-09 17:03 
GeneralRe: Help with rand() definition [modified] Pin
T210212-Jun-09 22:57
T210212-Jun-09 22:57 
GeneralRe: Help with rand() definition Pin
Grimes12-Jun-09 23:44
Grimes12-Jun-09 23:44 
GeneralRe: Help with rand() definition [modified] Pin
T210212-Jun-09 23:57
T210212-Jun-09 23:57 
QuestionHow to Custom a papersize during a printer work under windows 2000/xp [modified] Pin
Crazy Wu12-Jun-09 5:40
Crazy Wu12-Jun-09 5:40 
I am developing a printing application under windowsXP, I have a problem with Custom the user papersize during printing. accordance to Microsoft, writing the change papersize function as follows.

LPDEVMODE CFileInfoView::ChangeDevMode(HWND hWnd, char *pDevice)
{
HANDLE hPrinter;
LPDEVMODE pDevMode;
DWORD dwNeeded, dwRet;
FORM_INFO_1 formInfo;

if (!OpenPrinter(pDevice, &hPrinter, NULL))
return NULL;

dwNeeded = DocumentProperties(hWnd,
hPrinter,
pDevice,
NULL,
NULL,
0);
pDevMode = (LPDEVMODE)malloc(dwNeeded);
//twice
dwRet = DocumentProperties(hWnd,
hPrinter,
pDevice,
pDevMode,
NULL,
DM_OUT_BUFFER);
if (dwRet != IDOK)
{
free(pDevMode);
ClosePrinter(hPrinter);
return NULL;
}

formInfo.Size.cx=176000;
formInfo.Size.cy=330000;
formInfo.Flags=FORM_USER;
formInfo.ImageableArea.left=0;
formInfo.ImageableArea.top=0;
formInfo.ImageableArea.right=176000;
formInfo.ImageableArea.bottom=330000;
formInfo.pName="Custom Paper(176*330)";
LPTSTR FormName=new char[32];
if(!GetForms(hPrinter,formInfo.Size,FormName))//the function Query the form is exiting
{
if(!AddForm(hPrinter,1,(LPBYTE)&formInfo))//add the custom papersize
{
DWORD dd=GetLastError();
free(pDevMode);
ClosePrinter(hPrinter);
return NULL;
}
//make sure the form is added
if(!GetForms(hPrinter,formInfo.Size,FormName))
{
AfxMessageBox("");
return NULL;
}
}
memcpy(pDevMode->dmFormName,FormName,strlen(FormName));
pDevMode->dmFormName[strlen(FormName)]='\0';//must null-terminated
pDevMode->dmFields=DM_FORMNAME;

dwRet = DocumentProperties(hWnd,
hPrinter,
pDevice,
pDevMode,
pDevMode,
DM_IN_BUFFER |
DM_OUT_BUFFER);

ClosePrinter(hPrinter);

if (dwRet != IDOK)
{
free(pDevMode);
return NULL;
}
delete [] FormName;
return pDevMode;
}

void CFileInfoView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo )
{
CScrollView::OnPrepareDC(pDC, pInfo);
if(pDC->IsPrinting())
{
if(IsWindowNT())//make sure Windows Version is support
{
Char* PrinterName = NULL;
CString s=pInfo->m_pPD->GetDeviceName();
PrinterName=s.GetBuffer(s.GetLength());
lpDevMode = ChangeDevMode(m_hWnd,PrinterName);
pDC->ResetDC(lpDevMode);
}
else
{
.....
}
}
}
However, after running, and some printers can be changed for custom paper, but some of the default paper, has not changed.why? please help me. thank you!

modified on Friday, June 12, 2009 12:12 PM

AnswerRe: How to Custom a papersize during a printer work under windows 2000/xp Pin
Crazy Wu12-Jun-09 17:36
Crazy Wu12-Jun-09 17:36 
QuestionConversion Pin
reddy0712-Jun-09 5:08
reddy0712-Jun-09 5:08 
AnswerRe: Conversion Pin
Crazy Wu12-Jun-09 5:48
Crazy Wu12-Jun-09 5:48 
AnswerRe: Conversion Pin
CPallini12-Jun-09 5:51
mveCPallini12-Jun-09 5:51 
AnswerRe: Conversion Pin
Rajesh R Subramanian12-Jun-09 9:20
professionalRajesh R Subramanian12-Jun-09 9:20 
GeneralRe: Conversion Pin
reddy0712-Jun-09 9:30
reddy0712-Jun-09 9:30 
QuestionUsing WMI to get hardware information Pin
Anthony Mushrow12-Jun-09 4:49
professionalAnthony Mushrow12-Jun-09 4:49 
QuestionRe: Using WMI to get hardware information Pin
Randor 12-Jun-09 6:23
professional Randor 12-Jun-09 6:23 
AnswerRe: Using WMI to get hardware information Pin
Anthony Mushrow12-Jun-09 7:47
professionalAnthony Mushrow12-Jun-09 7:47 
GeneralRe: Using WMI to get hardware information Pin
Randor 12-Jun-09 8:36
professional Randor 12-Jun-09 8:36 
GeneralRe: Using WMI to get hardware information Pin
Anthony Mushrow15-Jun-09 0:50
professionalAnthony Mushrow15-Jun-09 0:50 
AnswerRe: Using WMI to get hardware information Pin
Stuart Dootson12-Jun-09 13:00
professionalStuart Dootson12-Jun-09 13:00 
GeneralRe: Using WMI to get hardware information Pin
Anthony Mushrow15-Jun-09 0:46
professionalAnthony Mushrow15-Jun-09 0:46 
QuestionHow to avoid if else... Pin
vikasvds12-Jun-09 3:40
vikasvds12-Jun-09 3:40 
AnswerRe: How to avoid if else... Pin
harold aptroot12-Jun-09 4:05
harold aptroot12-Jun-09 4:05 
AnswerRe: How to avoid if else... Pin
KarstenK12-Jun-09 4:21
mveKarstenK12-Jun-09 4:21 
AnswerRepost Pin
led mike12-Jun-09 4:23
led mike12-Jun-09 4:23 

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.