|
//int result=initspcm ("TestAlertUUT",(PF_SPCMCOMM_CALLBACK)SpcmCallBack);
aha! this is a callback function so the calling convention of both function has to be same
but ",(PF_SPCMCOMM_CALLBACK)SpcmCallBack is _cedel
where as initspcm is _stdcall.
never say die
|
|
|
|
|
Shay Harel wrote: typedef void (__stdcall *PF_SPCMCOMM_CALLBACK)(char *,pack_data *);
Shay Harel wrote: static void __cdecl SpcmCallBack (char *payload,pack_data *pd);
These two must have the same calling convention - __stdcall and __cdecl are not compatible.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
VC6, MFC
I'm trying to print the contents of a CScrollView. The text displays correctly (font and size) in the view, but when I try to print, it's REEEEAL small.
I'm not using the view's built-in procedures (OnBeginPrinting, etc). Instead, I'm displaying the CPrintDlg, retrieving the DC of the selected printer, and managing the printing myself.
Can anyone tell me why the printed text is super-small?
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-- modified at 15:11 Thursday 9th February, 2006
|
|
|
|
|
See if this helps.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Nope.
here's my code:
LRESULT CPatientInfoView::OnCBPrint(WPARAM wParam, LPARAM lParam)
{
CPrintDialog dlg(FALSE);
if (dlg.DoModal() != IDOK)
{
return 1L;
}
HDC hDC = dlg.GetPrinterDC();
if (hDC == NULL)
{
return 1L;
}
CDC printerDC;
printerDC.Attach(hDC);
DOCINFO docinfo;
memset(&docinfo, 0, sizeof(docinfo));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = _T("TRIAD Patient Info Report");
if (printerDC.StartDoc(&docinfo) < 0)
{
AfxMessageBox(_T("Printer wouldn't initalize"));
}
else
{
CalcPrintedPageHeight(&printerDC);
int nLinesPrinted = 0;
do
{
nLinesPrinted = PrintPage(&printerDC, nLinesPrinted);
} while (nLinesPrinted > 0);
printerDC.EndDoc();
}
return 1L;
}
BOOL CPatientInfoView::BuildReportFont(CFont* pFont)
{
int nFontSize = -12;
CString sFontName = _T("Courier");
return pFont->CreateFont(nFontSize, 0,0,0, FW_NORMAL, 0,0,0, DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, sFontName);
}
int CPatientInfoView::PrintPage(CDC* pDC, int nStartLine)
{
if (pDC->StartPage() < 0)
{
MessageBox(_T("Could not start page"));
return pDC->AbortDoc();
}
int nCount = m_saLines.GetSize();
if (nCount <= 0)
{
return -10;
}
if (nStartLine >= nCount)
{
return -11;
}
TRACE("DrawOnDevice()\n");
m_nDocHeight = 0;
CRect screenRect;
CFont* pOldFont = NULL;
CFont docFont;
BuildReportFont(&docFont);
pDC->SelectObject(&docFont);
CString sText = "";
CString sTemp = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int nLineHeight = pDC->GetTextExtent(sTemp).cy + 2;
int nTabWidth = 25;
int nYPos = 5;
int nXPos = 5;
pDC->SetBkColor(RGB(255,255,255));
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
int i = 0;
for (i = nStartLine; i < nCount; i++)
{
nYPos += (DrawLine(pDC, nXPos, nYPos, m_saLines.GetAt(i)) * nLineHeight);
if (nYPos > m_nPageHeight - nLineHeight)
{
break;
}
}
pDC->SelectObject(pOldFont);
pDC->EndPage();
if (i >= nCount -1)
{
return -12;
}
return i;
}
void CPatientInfoView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
TRACE("OnPrepareDC()\n");
if (!pDC->IsPrinting())
{
SetScrollSizes(MM_TEXT, CSize(1000, m_nDocHeight));
CScrollView::OnPrepareDC(pDC, pInfo);
}
else
{
CScrollView::OnPrepareDC(pDC, pInfo);
}
}
void CPatientInfoView::CalcPrintedPageHeight(CDC* pDC)
{
CDC *pCurrentDC = GetDC();
if (!pCurrentDC)
{
return;
}
pDC->SetMapMode(MM_TEXT);
CSize szPaperPPI (pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY));
CSize szScreenPPI(pCurrentDC->GetDeviceCaps(LOGPIXELSX), pCurrentDC->GetDeviceCaps(LOGPIXELSY));
int nLeftMargin = 0;
int nRightMargin = 0;
int nHeaderHeight = 0;
int nFooterHeight = 0;
int nGap = 0;
CFont prnFont;
BuildReportFont(&prnFont);
CFont *pOldFont = pDC->SelectObject(&prnFont);
CSize charSize = pDC->GetTextExtent(_T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSATUVWXYZ"),52);
charSize.cx /= 52;
int nMargins = (nLeftMargin + nRightMargin) * charSize.cx;
CSize szPaperSize = CSize(pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
CSize szLogicalPageSize = CSize(szScreenPPI.cx * szPaperSize.cx / szPaperPPI.cx * 3 / 4,
szScreenPPI.cy * szPaperSize.cy / szPaperPPI.cy * 3 / 4);
m_nPageHeight = szLogicalPageSize.cy -
(nHeaderHeight + nFooterHeight + 2 * nGap) *
charSize.cy;
m_nPageWidth = szLogicalPageSize.cx -
(nLeftMargin + nRightMargin + 2 * nGap);
pDC->SetWindowExt (szLogicalPageSize);
pDC->SetViewportExt(szPaperSize);
pDC->SetWindowOrg (nLeftMargin * charSize.cx, 0);
pDC->SelectObject(pOldFont);
}
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: int nFontSize = -12;
This is gonna make a font that's 12 pixels high on the screen, but twelve ridiculously little dots high on any modern printer.
So, the solution is to down-grade your printer. I'll sell you my old Epson 9-pin, if you can find a ribbon for it...
|
|
|
|
|
That means your DC's mapping mode isn't set correctly. If you try to use the mapping mode you use for the screen, the output comes out smaller because the printer's DPI is a lot higher than the screen's.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
I just don't get it...
I changed the font creation code and it's printing the right siZe text, but now, it's not printing on the whole page.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
As a final act of desperation, I looked on CodeGuru and found a class that works almost perfectly, I had to fix a last-page footer placement problem and add code for breaking long lines on word or character boundaries, but other than that, it was fairly straightforward (despite the fact that the guy used foreign words for some of the variables).
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Petzold introduced a technique for achieving true WYSIWYG printing way back in the late '80s. I used it in about 1993 with good results. Unfortunantly, I no longer have that code, or the book. The technique was called 'logical twips' and involved a formuila for adjusting the mapping mode to work for both the screen and the printer device context.
The "Logical Twips" Mapping Mode [^]
When I discussed mapping modes in Chapter 11, you might have thought the
MM_TWIPS mapping mode would be used by programs that make heavy use of
formatted text. In this mapping mode, logical units are in terms of 1/20
point. However, you probably won't want to use MM_TWIPS for the video
display, because the mapping mode is based on real inches rather than
logical inches. As a result, your program won't be able to equate the
correct point sizes (8, 10, 12, 14, 18, and 24) of the available screen
fonts to their heights in MM_TWIPS units.
You'll be better off if you define your mapping mode based on the
logical-pixels-per-inch dimensions available from GetDeviceCaps. I call this
the "Logical Twips" mapping mode; here's all you need to set it:
SetMapMode (hdc, MM_ANISOTROPIC) ;
SetWindowExt (hdc, 1440, 1440) ;
SetViewportExt (hdc, GetDeviceCaps (hdc, LOGPIXELSX),
GetDeviceCaps (hdc, LOGPIXELSY)) ;
Because the pixels-per-logical-inch values are always divisors of 1440, the
scaling factor for this mapping mode is an integer. With this mapping mode
set, if you want to request a font with 12-point line spacing (as we'll do
shortly), you can specify the height of the font as 240 (12 times 20)
logical units.
If you select a font into your device context and call GetTextMetrics to
obtain the dimensions of the font, you can calculate the type size in points
by using the formula:
(tm.tmHeight - tm.tmInternalLeading) / 20
The line spacing in points is equal to:
tm.tmHeight / 20
For some smaller fonts on low-resolution devices, the size and spacing of
the type might actually involve a fraction of a point--for example, 8-point
type with 8.5-point line spacing. To round to the nearest integer point
size, you might instead want to use the formulas:
(tm.tmHeight - tm.tmInternalLeading + 10) / 20
and:
(tm.tmHeight + 10) / 20
We'll use the "Logical Twips" mapping mode in the JUSTIFY program toward the
end of this chapter.
Once again, remember that the discrepancy between logical inches and real
inches occurs only for the display. If you use the "Logical Twips" mapping
mode with a printer, you'll simply duplicate the MM_TWIPS mapping mode.
"You get that which you tolerate"
-- modified at 19:55 Thursday 9th February, 2006
|
|
|
|
|
I have a modeless dialog with some controls. How to disable this dialog with all controls?
Best regards,
Eugene Pustovoyt
ICQ UIN: 161325180
|
|
|
|
|
Do something like this:
BOOL b = EnumChildWindows( hWndDlg, EnumFunc, NULL );
BOOL CALLBACK EnumFunc( HWND hwnd, LPARAM lParam )
{
EnableWindow( hwnd, FALSE );
}
Andy
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Are you wanting to disable all of the controls on the dialog, or the dialog itself?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Try this:
HWND hwnd = ::GetTopWindow(this->GetSafeHwnd());
while (hwnd)
{
hwnd = ::GetNextWindow(hwnd, GW_HWNDNEXT);
::EnableWindow(hwnd, FALSE);
}
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
If you want to disable the control on this dialog, the MFC-way of doing it would be creating a variable
bool ControlsEnabled;
and use OnCmdUI-Handler on each Control to do
pCmdUI->Enable( ControlsEnabled /*&& other conditions*/);
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Why do multithreaded programs behave differently in DEBUG mode and RELEASE mode?
|
|
|
|
|
Because you use two different libs or dlls. The debug versions contain more information to make it easier to debug the code, and probably also the behaviour is different so that a thread is halted when you debugstep into another one.
~RaGE();
|
|
|
|
|
Does that mean that a program running well in DEBUG mode may not run the same way in RELEASE mode?
|
|
|
|
|
|
hey guys
i'm a novice c++ programmer and i'm currently making a program
everything works fine, but there's one slight problem...
i need to have the program output a text on-screen and i don't know how.
Let me explain, the program i want to make basically displays a text on the screen of your computer.
not the DOS prompt where it executes the program, but the screen itself.
Think of an alert-messenger that does so not by using those windows, but by just displaying the text
it needs to display.
How can I do that?
If it's no trouble, i'm also wondering if the gotoxy(x,y) (using the conio.h file) works with whatever solution to my problem you have. And how can i make that text disappear after a pre-set amount of time?
thanks for your help
regards,
peter
#include borland c++ compiler 5.5
using Windows XP;
int main()
{
cout << "Hi! I'm Peter!\n";
return 0;
}
|
|
|
|
|
Peter Charlesworth wrote: Think of an alert-messenger that does so not by using those windows, but by just displaying the text
it needs to display.
I have no idea how to do it without "those windows", but you could draw your text on a transparent window, giving the impression that the text is displayed "on the screen".
~RaGE();
|
|
|
|
|
I am using the code below
typedef CArray<float, float> INT_PERCENT1;
INT_PERCENT1 arrPercentage1;
INT_PERCENT1 arrPercent1;
arrPercentage1 have a data in the array already added. but arrPercent have not element yet added. I want to copy a data from
arrPercentage1 to arrPercent1
for ( int j = 0 ; j< countloop ; j++)
{
arrPercent1.SetAt(j, m_arrPercentage1.GetAt(j));
m_arrRank1.SetAt( j , 0);
}
at the line arrPercent1.SetAt(j, m_arrPercentage1.GetAt(j));
the program crashes , while debugging i got the error
CXX0030: Error: expression cannot be evaluated
Regards.
|
|
|
|
|
zahid_ash wrote: I want to copy a data from
arrPercentage1 to arrPercent1
So why not just use the Copy() method?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
It crashes because you do not assign memory to your second table.
Three possibilities:
for ( int j = 0 ; j< countloop ; j++)
{
arrPercent1.SetAtGrow(j, m_arrPercentage1.GetAt(j));
m_arrRank1.SetAt( j , 0);
}
or initialize the size before the loop:
arrPercent1.SetSize(m_arrPercentage1.GetSize());
for ...
Or, the best solution:
arrPercent1.Copy(m_arrPercentage1);
~RaGE();
|
|
|
|
|
Hi all,
I am new to VC++.I have developed an "exe" application in VC++.I need to execute some DOS
commands from this application but, the problem is whenever I run the code, it automatically creates a dos window because of the "system" command and covers my dialog window. Is there any funtion that can hide or minimize that DOS window?If so where do i place that part of the code??
Thanks
Sasha
|
|
|
|
|