Click here to Skip to main content
15,909,242 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralConfused about Bound sockets and deamons Pin
Jason Hihn21-Jun-02 7:51
Jason Hihn21-Jun-02 7:51 
GeneralRe: Confused about Bound sockets and deamons Pin
21-Jun-02 10:28
suss21-Jun-02 10:28 
GeneralRe: Confused about Bound sockets and deamons Pin
jferrell121123-Jun-02 3:37
jferrell121123-Jun-02 3:37 
GeneralSend Message WM_CLOSE Pin
MyEden21-Jun-02 7:16
MyEden21-Jun-02 7:16 
GeneralRe: Send Message WM_CLOSE Pin
21-Jun-02 9:34
suss21-Jun-02 9:34 
GeneralRe: Send Message WM_CLOSE Pin
MyEden21-Jun-02 22:01
MyEden21-Jun-02 22:01 
GeneralMySql++ Pin
klawipo21-Jun-02 6:37
klawipo21-Jun-02 6:37 
GeneralA printing problem Pin
Vincent Ye21-Jun-02 6:08
Vincent Ye21-Jun-02 6:08 
Hi, all,

I want to print a snapshot of the activated window, I'v written some codes.
It works well if the printer is directly connected the computer, but if it
outputs to a network printer, it doesn't work, a paper is exported from the
printer, but nothing on it.

here is the code:

void CBaseTabSheet::OnFilePrint()
{
// TODO: Add your command handler code here
CRect rectWindow;
CWnd *pWnd;
CDC memDC;

if (GetParent()->IsZoomed()) {
pWnd = AfxGetMainWnd();
AfxGetMainWnd()->GetWindowRect(rectWindow);
} else {
pWnd = GetParent();
GetParent()->GetWindowRect(rectWindow);
}
CWindowDC dc(pWnd);
int nX = rectWindow.Size().cx;
int nY = rectWindow.Size().cy;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBitmap = new CBitmap();
pBitmap->CreateCompatibleBitmap(&dc, nX, nY);
CBitmap * pOldBitmap = (CBitmap *)memDC.SelectObject(pBitmap);
memDC.BitBlt(0, 0, nX, nY, &dc, 0, 0, SRCCOPY);

CDC prtDC;
CPrintInfo printInfo;
DOCINFO di;

if (AfxGetApp()->GetPrinterDeviceDefaults(&printInfo.m_pPD->m_pd)) {
HDC hDC = printInfo.m_pPD->m_pd.hDC;
if (hDC == NULL) {
hDC = printInfo.m_pPD->CreatePrinterDC();
}
if (hDC != NULL) {
CString strTitle;
strTitle.LoadString(AFX_IDS_APP_TITLE);
prtDC.Attach(hDC);
memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = strTitle;
prtDC.m_bPrinting = TRUE;

if (prtDC.StartDoc(&di) != -1) {
prtDC.StartPage();

int X = prtDC.GetDeviceCaps(LOGPIXELSX);
prtDC.StretchBlt(0, 0, nX * X / 96, nY * X / 96,
&memDC, 0, 0, nX, nY, SRCCOPY);

prtDC.EndPage();
prtDC.EndDoc();
}

prtDC.Detach();
prtDC.DeleteDC();
}
}
memDC.SelectObject(pOldBitmap);
delete pBitmap;
memDC.DeleteDC();
}

Any suggestion? Thanks in advance

Vincent
GeneralRe: A printing problem Pin
Carlos Antollini21-Jun-02 6:23
Carlos Antollini21-Jun-02 6:23 
GeneralRe: A printing problem Pin
Roger Allen21-Jun-02 6:27
Roger Allen21-Jun-02 6:27 
GeneralRe: A printing problem Pin
Vincent Ye21-Jun-02 9:02
Vincent Ye21-Jun-02 9:02 
GeneralPalm Problem.. Pin
Renjith Ramachandran21-Jun-02 5:49
Renjith Ramachandran21-Jun-02 5:49 
GeneralRe: Palm Problem.. Pin
Mike Nordell23-Jun-02 18:05
Mike Nordell23-Jun-02 18:05 
GeneralETSLayoutFormView, scrollbars missing. Pin
aldeba21-Jun-02 5:26
aldeba21-Jun-02 5:26 
GeneralTIP: When your program suddenly stops loading Pin
Jason Hooper21-Jun-02 5:16
Jason Hooper21-Jun-02 5:16 
GeneralRe: TIP: When your program suddenly stops loading Pin
Neville Franks21-Jun-02 11:37
Neville Franks21-Jun-02 11:37 
GeneralRe: TIP: When your program suddenly stops loading Pin
Jason Hooper22-Jun-02 1:33
Jason Hooper22-Jun-02 1:33 
QuestionHow can I tell if an app has shut down? Pin
Paresh Solanki21-Jun-02 5:14
Paresh Solanki21-Jun-02 5:14 
AnswerRe: How can I tell if an app has shut down? Pin
Jeremy Falcon21-Jun-02 5:26
professionalJeremy Falcon21-Jun-02 5:26 
GeneralRe: How can I tell if an app has shut down? Pin
Paresh Solanki21-Jun-02 6:01
Paresh Solanki21-Jun-02 6:01 
GeneralRe: How can I tell if an app has shut down? Pin
Carlos Antollini21-Jun-02 6:12
Carlos Antollini21-Jun-02 6:12 
AnswerRe: How can I tell if an app has shut down? Pin
Martin Ziacek21-Jun-02 5:30
Martin Ziacek21-Jun-02 5:30 
AnswerRe: How can I tell if an app has shut down? Pin
Jason Henderson21-Jun-02 9:48
Jason Henderson21-Jun-02 9:48 
Generalusing bits for program control Pin
21-Jun-02 4:59
suss21-Jun-02 4:59 
GeneralRe: using bits for program control Pin
Martin Ziacek21-Jun-02 5:50
Martin Ziacek21-Jun-02 5:50 

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.