|
Please edit your post so that all "<" and ">" symbols and their contents are visible.
Steve
|
|
|
|
|
I would like to say that I might experiment with that, but I would be lying. Your best bet is to use the strings provided by the STL.
Given that and the fact that you are mixing C++ and C (normal - actually), then internally to your class, use ‘strncmp’ to compare a particular number of characters.
Look if you understand basic programming, then you can write 70% of the C library in a week, including non-standard methods.
int compare(char* s, size_t n)
{
int i;
for( i=0; s[i]; ++i )
if( Data[i] != s[i] )
return(Data[i] - s[i]);
return(0);
}
Or something like that.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
template <unsigned char sz> class MyString : MyStringBase<sz>
{
public:
MyString () { Len = 0; Data[Len] = 0}
MyString (const char* src);
template <unsigned char sz>
bool Compare(const MyString<sz2> &rhs, int len);
};
template <unsigned char sz>
template <unsigned char sz2>
inline bool MyString<sz>::Compare(const MyString<sz2> &rhs, int len)
{
if (len<0)
len = Len;
return ((Len==rhs.Len) && (Len<=len) && (strncmp(Data,rhs.Data,len)==0));
}
I think VC6 will have trouble with this code and you'll need to move the definition of Compare into the class (in which case drop the bits in italic).
Steve
|
|
|
|
|
Does anyone know why the Print function works in DEBUG mode, but not in RELEASE mode (it is blank)? (Visiual C++ 6.0).
Thanks.
mnnca
|
|
|
|
|
what is the difference between debug mode and release mode?
|
|
|
|
|
When I compile it (single document MFC app) in debug mode, the document has the right data (on the view and printer).
When I compile it in release mode, the document is always blank.
mnnca
|
|
|
|
|
What Print function? What "is blank"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I use standard code from MFC examples:
void CDISKVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CDISKVERDoc* pDoc = GetDocument();
CScrollView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_ANISOTROPIC);
CSize sizeDoc = pDoc->GetDocSize();
sizeDoc.cy = -sizeDoc.cy;
pDC->SetWindowExt(sizeDoc);
CSize sizeNum, sizeDenom;
sizeNum.cx=1;
sizeNum.cy=1;
sizeDenom.cx=1;
sizeDenom.cy=1;
//debug mode works ok
//release mode doesnt work !!dont know why
// GetZoomFactor(&sizeNum, &sizeDenom); this is not a valid function, why?
int xLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSX);
int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
long xExt = (long)sizeDoc.cx * xLogPixPerInch * sizeNum.cx;
xExt /= 100 * (long)sizeDenom.cx;
long yExt = (long)sizeDoc.cy * yLogPixPerInch * sizeNum.cy;
yExt /= 100 * (long)sizeDenom.cy;
pDC->SetViewportExt((int)xExt, (int)-yExt);
}
The Print function:
pDC->TextOut(x,y, String1);
When I compile it in debug mode, the output/document is ok.
when I compile it in release mode, the output is a blank page.
Thanks.
Mandy
mnnca
|
|
|
|
|
Hmm...besides rendering to coordinates that don't map to a visible
area of the page, I can't see what would cause the page to be blank.
You could try adding debug info to your release build project
C++ and linker settings and step throu in the debugger and see if
maybe there's an improperly used ASSERT() macro somewhere or
check values in your printing code to see if you're getting what you
expect.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi:
Thanks for the tips.
I inserted lots of debug statements (in release mode) to display the cordinates (x,y), they look ok (within page boundary).
There are differences between the debug and release libraries (MSVCRTD.dll, MFC42D.dll, MFCO42D.dll).
One difference I found is the height of the TEXTMETRIC. I even tried to set it to a fixed value (17, as seen in debug mode), it still doesnt work.
mnnca
mnnca
|
|
|
|
|
That's a tough one.
It looks like all your y coordinates (when drawing) should be negative
to be visible. Is that the case?
You can try using a window DC instead of a printer DC (like print-preview).
Saves time debugging and maybe you'll see something that you're not seeing
on the printed pages.
You may want to go through the project settings and compare ALL
settings between the release and debug. Make sure there's not a
release setting that would obviously change behavior.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I don't know how to use the "window DC" suggested by you.
The blank page is both on preview (monitor display) and on printer output.
Thanks.
mnnca
|
|
|
|
|
I've just tried something else: I use different code (from an old proj) and it works ok now in both debug and release mode.
In a previous post, the OnPrepareDC is from a MFC sample.
void CDISKVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CFormView::OnPrepareDC(pDC, pInfo);
CClientDC dcScreen(NULL); //Get the display's device context
pDC->SetMapMode(MM_ANISOTROPIC); //Map aspect ratio
// map 1 screen logical inch to 1 printer (/output) logical inch
pDC->SetWindowExt(dcScreen.GetDeviceCaps(LOGPIXELSX),
dcScreen.GetDeviceCaps(LOGPIXELSY)); //Window is display
pDC->SetViewportExt((2*pDC->GetDeviceCaps(LOGPIXELSX)),
(2*pDC->GetDeviceCaps(LOGPIXELSY))); //Viewport is printer
}
mnnca
|
|
|
|
|
mnnca wrote: // map 1 screen logical inch to 1 printer (/output) logical inch
Aren't you mapping 1 screen logical inch to 2 printer logical inches?
I'm still not sure why the other one worked in one build mode and not the other...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The comment didnt match the code, however, when I tried 1 to 1 mapping, it works the same (I dont really know why).
When it works with the old code, I was so relieved that I didnt investigate more into the problem.
After reading your post, I went back and traced all the code and found out why it didnt work (in release mode only):
the only code which was missing is the SetMapMode in the OnPrint(...)which made it not work:
void CDISKVERView::OnPrint(CDC* pDC, CPrintInfo* pInfo /*pInfo*/)
{
pDC->SetMapMode(MM_LOENGLISH);
CDISKVERView::PrintPage( pDC, pInfo);
}
when I add that line in the old prj file, it works. I dont understand why though.
mnnca
|
|
|
|
|
mnnca wrote: when I add that line in the old prj file, it works. I dont understand why though.
That's a good sign that OnPrepareDC() wasn't setting up the DC the way the code
doing the printing ( CDISKVERView::PrintPage()) was expecting. That's certainly a
different map mode than OnPrepareDC() is using
So did you get it all working the way you wanted??
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've just read the def of the map modes:
MM_ANISOTROPIC Logical units are converted to arbitrary units with arbitrarily scaled axes.
It didnt work because it was set to that mode (again code is from a sample).
Now it works because right before printing, the mode is re-set to
MM_LOENGLISH Each logical unit is converted to 0.01 inch. Positive x is to the right; positive y is up.
It makes sense.
Thanks for helping.
mnnca
|
|
|
|
|
mnnca wrote: Thanks for helping.
I think I've only provided emotional support LOL
Anyway, OnPrepareDC() is called before OnPrint() is repeatedly called for each page,
so you are overriding any map mode set in OnPrepareDC().
If you want to, you can remove the code you have in OnPrepareDC() and
replace it with the pDC->SetMapMode(MM_LOENGLISH); call.
This should work the same:
void CDISKVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CFormView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_LOENGLISH);
}
void CDISKVERView::OnPrint(CDC* pDC, CPrintInfo* pInfo )
{
CDISKVERView::PrintPage( pDC, pInfo);
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, the scale mode should be set in OnPrepareDC (cleaner).
mnnca
|
|
|
|
|
Which Font are you using? It can be tht the font in your view fits and is visible, but after conversions to the printer is too small. In my project I had a similar problem. The output was just a single point because my font was so dammned small that a complete sentence was not visible. Take a look to the size of your document, the dimension that you are stablishing and create a compatible font to that dimensions/device printer
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I think it's a different and strange problem because it works fine in debug mode.
The font I select is the "default" font which user is using, but I control the height and weight so it should not be the problem:
logFont.lfHeight = 35; // 3/4th inch high in MM_LOENGLISH
logFont.lfWeight = 400;//700;//max bold
CFont font;
if (font.CreateFontIndirect(&logFont))
pOldFont = pDC->SelectObject(&font);
Thanks.
mnnca
|
|
|
|
|
Hello,
I have a read only CEdit control on my dialog, when i run the application and there is always wait cursor
( | - this sign of wait cursor) on the Control, How can we hide the cursor?
thanks
|
|
|
|
|
Cursor or caret?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yeah, i think it is called caret, the sign ( | ) is always flashing on the control
|
|
|
|
|
You could adjust the order of the controls in the dialog
so a different control gets the initial focus.
And/or you can use SetFocus() or WM_NEXTDLGCTL/GotoDlgCtrl()
to move the focus to a different control.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|