|
|
Technically, decimal means base-10 (deca is Greek for ten). So, rather than using a float type, are you wanting to use an int type?
If you simply need more precision, you might try the DECIMAL type. However, I suspect you are not having precision problems. Most beginners assume you can compare floating-point numbers just like you can non floating-point numbers. For example, this would never produce the desired result:
float a = 0.1;
if (a == 0.1)
... because a is stored internally as 0.0999999999, give or take a few 9s.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am trying to read the entire content of a text file with the following code:
File.seekg(0, ios::end);<br />
<br />
long lFileSize = File.tellg();<br />
<br />
szFileBuffer = new char[lFileSize + 1];<br />
<br />
if ( szFileBuffer == NULL )<br />
{<br />
MessageBox(NULL, "There is not enough memory to run this application",<br />
NULL, MB_ICONERROR | MB_OK);<br />
<br />
return 1;<br />
}<br />
<br />
File.seekg(0, ios::beg);<br />
<br />
File.get(szFileBuffer, lFileSize + 1, EOF);<br />
<br />
File.close();
The actual filesize is 715KB but the program is only reading 540KB...tellg gives the correct filesize yet get seems to only be getting 540KB...are there any workarounds for this...in general, are there buffer size limitations as far as istream::get is concerned?
|
|
|
|
|
Hi,
Think having some prob with EOF state. Have a look @ msdn for basic_istream::seekg.
This may help you
Sujan
|
|
|
|
|
Hi
For reading entire file content, try use block (not stream) i/o.
<br />
FILE *pFile = fopen(fname, fmode);
fseek(pFile, 0, SEEK_END);<br />
long len = ftell(pFile);<br />
char *data = new char[len];<br />
fseek(pFile, 0, SEEK_SET);<br />
long rest = len;<br />
long tpos = 0;<br />
while(rest)<br />
{<br />
long rd = fread(data+tpos, 1, rest, pFile);<br />
if (!rd)<br />
{<br />
}<br />
else<br />
{<br />
rest -= rd;<br />
tpos += rd;<br />
}<br />
fclose(pFile)
|
|
|
|
|
How are you opening the file? If the file is opened as "text" then any EOF character encountered before the last one will cause the get() call to end prematurely.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for the replies...yes the file is being opened as text...there shouldn't be a premature EOF character in there...but in general, what are my options while keeping this file open as text?
|
|
|
|
|
Dear friends,
I am giving "&" symbol to menu items, but at runtime, the Menu item is not underlined. Its only when i press "Alt" key it becomes underlined. I want the "short Key" character to be visible at runtime, just like Visual C++ 6.0 IDE or MS Office. How can i do so ?
Imtiaz
|
|
|
|
|
This is by settings in XP - Screen properties/Appearance - then Effects button and uncheck Hide underlined...
|
|
|
|
|
Yes, but how Visual Studio and MS-WORD are showing underline symbol when the option is either selected or not selected ??
Imtiaz
|
|
|
|
|
Because they have their menu ownerdraw and decided for whatever reason to ignore this system setting.
The setting for the system can be retrieved by
function SystemParametersInfo , using flag SPI_GETKEYBOARDCUES .
You can change the setting for the system by using SPI_SETKEYBOARDCUES flag with the mentioned function.
Hope that helps.
|
|
|
|
|
Hi all,
can anybody gimme the program with code to create a anolog clock.
thanks in advance.
Mr.Dayala
ThomasKennedyBose
|
|
|
|
|
search for analog clock in c++ section at http://www.planetsourcecode.com
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
hi alok,
thanks for quick reply..I found it in planetsource bit it is on general C++.I want it in VC++..can help me out?? my problem is with time, otherwise I can manage by wriitng myself.
thanks in advance.
ThomasKennedyBose
|
|
|
|
|
could you eloborate you problem or mail me at thatsalok@gmail.com
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Mr Bose Dayala wrote:
can anybody gimme the program with code to create a anolog clock.
Probably, but nobody will. Why don't you write it yourself and if you run into any problems, ask a question about how to do a particular thing. You're much more likely to get a useful response that way.
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"
|
|
|
|
|
I found one some months ago here on CP. have you looked here in the articles?
besides I don't think it should be so dificult to make.
think of what parts a clock consists (circle, lines, pointers,...) All of them are static accept the pointers, the base is static (center of the circle) while the point moves, it moves (for the seconds) 360/60 of the circle every second.
The only thing you need to do is to redraw this pointer every second on the right place.
Just know your geometry.;)
hope this helps...
[EDIT]
Oh by the way, I did analog meters for a car once, which worked perfectly, the one thing you may want to consider is buffering to reduce flicker. I did it as described above, but I don't have the code anymore
[/EDIT]
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I am calling Form2 from Form1, and depending on the input in Form2, I want to enable/disable buttons in Form1 when I exit. However, because I need to call Form2 header before I define class Form1, Form1 is not defined when the compiler sees my call to it. If I therefore call Form1 header in Form2 header, then the compiler will see my call to Form2 before Form2 is defined!!.
Basically therefore, I wanna be able to call each form from each form, but have to define and make the call in one first.
This seems to me a very obvious thing to want to do, but I can't figure out myself how to do it, as you can't declare an extern class, or see any examples on the net of how to do it in Visual C++.net.
Any help appreciated, as is a real stumbling block for me.
UltimateNewbie
|
|
|
|
|
Hi,
In any case one form will be the parent of the other form. So in the 2nd form use the GetParent() function to get the pointer cast it to the parent parentclass, set the parent's values using the currently got value
Have a look @ the following code,
CParentDlg *pParent = (CParentDlg *) GetParent();
pParent->m_iNewValue = m_iGotValue;
Hope this will help you.
Sujan
|
|
|
|
|
Your question is a little confusing, but I think you need to a forward declaration of one of your classes.
class Form1; in your Form2.h
or
class Form2; in your Form1.h
A lot depends on how the classes are referencing each other.
Michael
CP Blog [^]
|
|
|
|
|
Hi
I am creating a class derived from CListBox so I can control the fonts, color, etc2. I also want to control the background color of the listbox (not the text's background color, but the whole listbox' background color), and I am doing it by handling WM_ERASEBKGND message in OnEraseBkgnd() function.
The OnEraseBkgnd() implementation is very simple, basically I just obtain the client rect and the use CDC::FillSolidRect to fill it with the background color of my choice.
The problem is, the background color is correctly drawn if there is at least one item in the listbox, but when the listbox is empty, the background color is always displayed as white, even though I have stepped in the debugger and make sure that the FillSolidRect function is executed.
Could someone tell me what the possible cause for this is? Thanks!
|
|
|
|
|
Hi
this is from MSDN :
<br />
The WM_CTLCOLORLISTBOX message is sent to the parent window of a list box before the system draws the list box. By responding to this message, the parent window can set the text and background colors of the list box by using the specified display device context handle.<br />
|
|
|
|
|
Are you calling the base class OnEraseBkgnd() ?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I need to make my application non-resizable. how do i do that?
Single Doc Interface, CFormView (all set up through MFC App Wizard).
|
|
|
|
|
Hi,
Add the following code to CMainFrame's PreCreateWindow
cs.style = WS_OVERLAPPED | WS_SYSMENU | WS_BORDER;
Sujan
|
|
|
|