|
HI googled and studied about printing and now able to print a string buffer.
the code is as follows:
<br />
<br />
void CPrint_DialogDlg::OnPrintReport() <br />
{<br />
char pbuf[100] = "Hello World.";<br />
HDC hdcPrn ;<br />
<br />
CPrintDialog *printDlg =<br />
new CPrintDialog(FALSE, PD_ALLPAGES | PD_RETURNDC, NULL);<br />
<br />
printDlg->m_pd.nMinPage = printDlg->m_pd.nMaxPage = 1;<br />
printDlg->m_pd.nFromPage = printDlg->m_pd.nToPage = 1;<br />
<br />
printDlg->DoModal();<br />
<br />
hdcPrn = printDlg->GetPrinterDC();<br />
if (hdcPrn != NULL)<br />
{<br />
CDC *pDC = new CDC;<br />
pDC->Attach (hdcPrn);
<br />
pDC->StartDoc("test");
<br />
pDC->StartPage();
SetPrintAlign(pDC, hdcPrn);
pDC->TextOut(10, 10, pbuf);
pDC->EndPage();
<br />
pDC->EndDoc();
<br />
pDC->Detach();
delete pDC;<br />
}<br />
<br />
delete printDlg;<br />
}<br />
<br />
<br />
void CPrint_DialogDlg::SetPrintAlign(CDC *pDC, HDC hdcPrn)<br />
{<br />
short cxPage, cyPage;<br />
<br />
cxPage = ::GetDeviceCaps (hdcPrn, HORZRES) ;<br />
cyPage = ::GetDeviceCaps (hdcPrn, VERTRES) ;<br />
pDC->SetMapMode (MM_ISOTROPIC) ;<br />
pDC->SetWindowExt ( 1000, 1000) ;<br />
pDC->SetViewportExt (cxPage / 2, -cyPage / 2) ;<br />
pDC->SetViewportOrg (cxPage / 2, cyPage / 2) ;<br />
pDC->SetTextAlign (TA_BASELINE | TA_CENTER) ;<br />
}<br />
<br />
Now here What I want to ask is that :
How can I handle if buffer content is of more than one page.
Better if provide some code snippet.
Thanks in advance.
|
|
|
|
|
you need to one StartDoc and EndDoc
and use StartPage EndPage for another pages
<br />
StartDoc (pd.hDC, &di);<br />
StartPage (pd.hDC);<br />
TextOut(pd.hDC,10,10,"This is a sample",16);<br />
EndPage (pd.hDC);<br />
StartPage (pd.hDC);<br />
TextOut(pd.hDC,10,10,"This is a sample",16);<br />
EndPage (pd.hDC);<br />
<br />
EndDoc (pd.hDC);<br />
whitesky
|
|
|
|
|
Thanks WhiteSky for your replies.
Now problem that I am facing is:
in TextOut() method if I have to pass a buffer which consists of some new line (\n) and tab ( \t) characters then this prints ||| for these characters.
So please tell me that how can I handle this problem i.e. when I want to print something in new line.
Thanks
|
|
|
|
|
<br />
it worked for me<br />
<br />
CString str="Is this a Test \n 123 \n yes it is \n 456";<br />
StartDoc (pd.hDC, &di);<br />
StartPage (pd.hDC);<br />
DrawText(pd.hDC,str,str.GetLength(),CRect(0,0,1500,350),DT_EXTERNALLEADING);<br />
EndPage (pd.hDC);<br />
EndDoc (pd.hDC);<br />
<br />
whitesky
|
|
|
|
|
I'm using VC6 and I changed my code into unicode, but when I try to debug some function, I find that I can't see the CString any more, it always shows the first character.
So, how can I see the unicode CString when debugging?
|
|
|
|
|
take
tools->option->
in the debug tab u can find a check box Labeled "Display unicode strings"
Check it.
nave
|
|
|
|
|
Hi,
I want to develop application for internet (client /server) which will send file and data to each other on internet.
What are the Programatic problem that can occur while transfer data on internet ?
(means the difference between the application build for local network transfer and one build for Internet data transfer)
What are the steps to be consider to make it efficient and reliable for Internet ?
Thanks
Regards.
|
|
|
|
|
See:
CInternetSession , HINTERNET, InternetOpenURL,InternetReadFile
Cheers
"Peace of mind through Technology"
|
|
|
|
|
You can also use CSocket and CAsyncSocket for connections
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
-- modified at 2:57 Thursday 18th May, 2006
|
|
|
|
|
zahid_ash wrote: What are the steps to be consider to make it efficient and reliable for Internet ?
remember sliding window protocol!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Could you please refere to any sample application that is using sliding window protocol
Thanks
Regards.
|
|
|
|
|
which tool can create 16 and 32 bits bitmap?
I tried windows-paint, coreldwraw and photoshop, they can not create 16 or 32 bits bitmap.
thx
|
|
|
|
|
Is your question in vc? or applications
if vc see BITMAPINFO bminfo;
switch(bminfo.bmiHeader.biBitCount)->24,16,32
and ...
whitesky
|
|
|
|
|
Hi,
I have used the function DeviceIoControl in my application. One of its parameter is IOCTL_STORAGE_EJECTION_CONTROL, but when i compile the class, error shows : 'IOCTL_STORAGE_EJECTION_CONTROL' : undeclared identifier.
Please respond , which includes or libs , i have to add.
Velayudhan
|
|
|
|
|
Hi raj,
Include the following file
ntddstor.h
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
|
Did you include Winioctl.h and ntddstor.h
whitesky
|
|
|
|
|
thanks for ur reply,
I have included WinioCtl.h
but do u know where ntddstor.h is found ?
|
|
|
|
|
|
The definition of the IOCTL_STORAGE_EJECTION_CONTROL is found in the winioctl.h Header which is provided with PlatformSDK of VS2003
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
Ok guys, thanks for your respone,
I solved it by including winioctl.h in platform SDK 2003
Velayudhan
|
|
|
|
|
Hi,
I need draw a border color to static Frame control,
I have the code as below but it not work with my testing for static Frame and Window Dialog.
Please see the code and help me for this
void CTestDLLDlg::DrawFrameBorder(HWND hWnd,COLORREF refColor)
{
RECT stRect;
::GetWindowRect(hWnd, &stRect);
HDC hDC = ::GetWindowDC(hWnd);
HPEN hPen;
hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), refColor);
HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);
HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
Rectangle(hDC, 0, 0, (stRect.right - stRect.left), (stRect.bottom - stRect.top));
::ReleaseDC(hWnd, hDC);
SelectObject(hDC, hOldPen);
SelectObject(hDC, hOldBrush);
DeleteObject(hPen);
DeleteObject(hDC);
}
At initialize function I called as bellow:
BOOL CTestDLLDlg::OnInitDialog()
{
CWnd* pWnd = GetDlgItem (IDC_AVATAR1);
DrawFrameBorder(pWnd->m_hWnd,RGB(255,0,0))
return true;
}
But it seem to not draw the red border
Please help me
Thank in advance!
|
|
|
|
|
If this is code, it will not work!
I assume that you are talking about the GroupBox...
Because the in OnInitDialog you are trying to draw the border, but do you know that the window is hidden at that time. You have to write the drawing code in OnPaint, which is called every time the window needs to be repainted.
Moreover it is not good practice to draw the control from another window. So I suggest you that you should derive a class from CStatic and write the code to draw the border inside it. Then create the member variable from this new class.
- NS -
|
|
|
|
|
in onpaint it doesnt work
whitesky
|
|
|
|
|
Really? You mean whose OnPaint? CStatic or CDialog?
- NS -
|
|
|
|