|
herbert_chow wrote:
However, just wondering if there is such thing as floating point divide by zero? I can't seem to find such an exception and coudlnt' generate it myself for testing. Do FLOATs work differently than integers?
A floating-point divide-by-zero doesn't generate an exception - even at the FPU level. FPU's know that anything divided by 0 is infinite, so they actually return a result of infinity (which is a valid number in the IEEE floating point formats, BTW). They don't flag an error condition, so the only way you can check is to determine if the result is infinity.
However, a much better way is to make sure it never happens in the first place...
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"
|
|
|
|
|
Just to point out.. that anonymous user was me, I forgot to log in.
Thanks for the great tips everyone! The SIGFPE handler interrupt is something I will need to look into as although I've worked with SIGFPE at the C level for an operating systems course. Im not quite sure how to incorporate it into Visual C++ though.
But I guess I got the main point which is to always check that I'm not dividing by zero.
Well... time to start checking EVERY division in my code.
|
|
|
|
|
Hello,
I'm working on a dialog based application. I need some sort of Panel (like in Delphi) in the main window.
I figured that a panel is nothing more than a modeless child window without any borders.
I derived a class from CDialog and I put some controls on it (edit boxes and such). It all works fine, the window hides and appears when I want it to, the controls work fine (button's get pushed, data moves from and to edit controls), BUT when I try to move the child window, it stays put.
I move the child window like this:
<br />
if(((CMyDialog*) m_pdlg)->SetWindowPos(this, 200, 50, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW))<br />
AfxMessageBox("test");<br />
The messagebox appears, so the window should be moved, but it doesn't...
I'm all out of clues and fried by my monitor and manuals...
Does anybody know a solution?
Thanks in advance.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Interesting.
Are you passing in a coordinate that is different than the current one?
Kuphryn
|
|
|
|
|
Hello,
I didn't pass the same coordinates, but I solved the problem now
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
There's always MoveWindow, if you are having problems and make sure that the coordinates are in the parent window coordinates.
|
|
|
|
|
Hello,
I solved the problem now . I don't know why it didn't work before, but it's solved now..
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hello,
I solved the problem. When I don't typecast the m_pdlg to CMyDialog* everything works fine...
I don't know why I can't typecast m_pdlg to CMyDialog*, but it works fine now
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
When building CodeProject examples (and other source code), I have noticed that the file size of the Release executables that I create, are larger than the Release executables created by the authors of the examples. I couldn't figure out why, but after re-installing XP and VC++6, I forgot to install SP5, and noticed that the Release executables produced were a different size to the ones created when SP 5 had been installed. Sometimes they were larger, sometimes smaller.
For example, if I install VC++6, without the service pack, I end up with a Release executable size of 528KB. With Service Pack 5 installed, this reduces to 444KB.
I've noticed this peculiarity before when compiling the QCD (Great media
player) Monkey's Audio input plugin - My plugin is 202KB, compared to the
official plugin which is 153KB. Everybody else I've spoken to can compile it
and produce a plugin of 153KB. It seems I'm the only one with the problem (
Also, when compiling a viewer plugin for the Directory Opus file manager, the dll produced is 32KB without SP5, and 44KB with SP5.
What's going on ?
|
|
|
|
|
Hmmm! It is a service pack! This implies that some bugs where probably fixed and or some of the code was changed to be more efficient. A bug fix might increase the code size generated by the compliler, why an improvement in efficiency might result in a smaller or larger code size.
In either case the amount of code generated has changed, and is hopefully better than is was without the service pack.
INTP
|
|
|
|
|
Thanks for the reply.
I don't understand why other people can compile the QCD plugin with VC++6 SP5 and produce a dll of size 153KB, and mine is 202KB, using exactly the same settings.
The same is true with the ToDoList project on CodeProject, where the official Release executable is 340KB, but mine is 444KB, again using the supplied project settings.
Any ideas ?
|
|
|
|
|
Maybe your settings are not exactly the same, or maybe the code version is different.
Version 1.9.0: 160KB (ToDoList.exe downloaded from CP)
Version 3.5.1: 324KB (ToDoList.exe downloaded from CP)
When I open the project for version 3.5.1 and compile as release the size is 324KB. (VC++ 6.0 SP5)
I have no idea why it would not produce the same program size on you machine.
If you find out, please post the answer.
INTP
|
|
|
|
|
I finished the 3d editor and I have released
the full C++ code for the 3d scene viewer.
Is a good start for learning 3D using C++.
http://getic.njoydeco.com
|
|
|
|
|
wow thanx for the releasing the code.
great job
|
|
|
|
|
So, when do we see the article?
Iain.
|
|
|
|
|
It is considered good form to include links in a clickable form : http://getic.njoydeco.com[^]
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
I have err : error spawning cl.exe What that's means? How should i do? That's in VS7, when i want to compile VS6 project.
|
|
|
|
|
Cl.exe is the actual compiler. It's a console application. Msdev.exe is the IDE that spawns cl.exe when it needs to. It sounds like the environment variables are not quite right. How long has this been happening (i.e., have you ever compiled successfully)?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
that's first time this message appears. I ryed to compile glut-3.7.6.
|
|
|
|
|
I am trying to print what looks like a ruler in mirror image. Using SetWorldTransform, everything works out fine on the display, but when performing print or print-preview, the mirror image text is simply rendered as upside-down rather than mirrored.
Simple testcode follows that simply creates a triangle with the word test.
I've tried different fonts as well. The only way it appears to work correctly outputting to the printer is if you use MM_TEXT mapping.
Any ideas out there?
TIA
Eric
<br />
void CTransformView::OnDraw(CDC* pDC)<br />
{<br />
pDC->SetMapMode(MM_LOENGLISH);<br />
SetGraphicsMode(pDC->m_hDC, GM_ADVANCED);<br />
XFORM XForm;<br />
::ZeroMemory(&XForm, sizeof(XFORM));<br />
XForm.eM21 = 0;
XForm.eM12 = 0;
<br />
XForm.eM11 = -1;<br />
XForm.eM22 = 1;<br />
XForm.eDx = 200;<br />
XForm.eDy = 0;<br />
SetWorldTransform(pDC->m_hDC, &XForm);<br />
<br />
pDC->MoveTo(50, -30);<br />
pDC->LineTo(160, -10);<br />
pDC->LineTo(160, -120);<br />
pDC->LineTo(50, -30);<br />
pDC->SetTextColor(RGB(0,0,0));<br />
<br />
CFont num_font_upper;<br />
num_font_upper.CreatePointFont(4, "Arial"); <br />
CFont *pFont = pDC->SelectObject(&num_font_upper);<br />
pDC->TextOut(50,-30, CString("test"));<br />
pDC->SelectObject(pFont);<br />
}<br />
|
|
|
|
|
It appears that simply calling
SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED) Will cause this bug to appear, even without any tranformations. This renders theword 'test' upright on screen and upside-down on print-preview or printout.
Am I missing something here?
TIA
ERic
<br />
void CTransformView::OnDraw(CDC* pDC)<br />
{<br />
pDC->SetMapMode(MM_LOMETRIC);<br />
SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED);<br />
<br />
CFont num_font_upper;<br />
num_font_upper.CreateFont(.4 , 0, 0,0, FW_NORMAL, FALSE, FALSE, 0,<br />
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS | CLIP_LH_ANGLES,<br />
PROOF_QUALITY, VARIABLE_PITCH |TMPF_TRUETYPE|FF_DONTCARE, "Ariel"); <br />
<br />
CFont *pFont = pDC->SelectObject(&num_font_upper);<br />
pDC->TextOut(100,-400, "Test");<br />
pDC->SelectObject(pFont);<br />
<br />
return;<br />
}
|
|
|
|
|
please show me the way to change the text color in the button.
thanks...
|
|
|
|
|
It might not be possible. MSDN states that it must have the BS_OWNERDRAW style. At that point, the button's owner can handle the WM_CTLCOLORBTN message. However, the text color of a push button applies only to its focus rectangle; it does not affect the color of the text. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I've got this program that has a box that lists all the available serial ports on a computer. Right now, it is listing COM1, COM2, COM3, and COM4. The computer actually only has COM1 and COM2. I looked at the code a little and noticed that it is getting the available serial ports from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" in the registry.
I can easily get the program to build a list from "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM" instead.
My question is... why are COM3 and COM4 listed in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports"? WHat is the purpose of this key?
Also, is there another way you guys would construct a list of available serial ports?
Freiheit ist von Gott, Freiheiten vom Teufel.
|
|
|
|
|
waffleman wrote:
Also, is there another way you guys would construct a list of available serial ports?
I would be inclined to use the Win32_SerialPort class.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|