|
Yeah i know the functions to use but....i don`t to use them the "Magnifying Glass" application the URL is :
"http://www.codeproject.com/dialog/magnifyglass.asp"
can any one help me ....
-- modified at 11:52 Tuesday 7th March, 2006
|
|
|
|
|
I'm writing and reading formatted io to a file using fopen, fscanf, fseek and fprintf. Even though I'm fprintf'ing the same formatted floats and int's each time to line #1, the varying size of the numbers makes it difficult to position the file pointer at the beginning of the next line, line #2. I'm using only the first 2 lines in the file, the line #1 for status that I write and line #2 for requests that I read and overwrite depending on the data.
My general question is:
How can I reliably position the file pointer at the beginning of the second line for reading (and writing) regardless of the varying length of the first status line.
|
|
|
|
|
ronwurster wrote: Even though I'm fprintf'ing the same formatted floats and int's each time to line #1, the varying size of the numbers...
What does the fprintf() statement look like?
ronwurster wrote: How can I reliably position the file pointer at the beginning of the second line for reading (and writing) regardless of the varying length of the first status line.
Read the first line, and then the file pointer will be positioned at the beginning of the second line.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I would like to explain that I haven't used formatted file io much with C. Hence my ignorance about the different methods for doing this sort of thing.
I've changed the printf to use explicit formatting characters which allow me to maintain a fixed length line. So, I can now predictably "fseek" the position of the 2nd line. My fprintf line now looks like:
fprintf (stream,"%8.3f %8.3f %c %c %8.3f 4d", floatvar1, floatvar2,
charvar1, charvar2, intvar1);
However, I tried reading the first line (using fscanf) and the pointer was NOT positioned at the beginning of the second line. In fact it was not on the 2nd line at all. Did you mean I should use "fread"? Can you explain please.
Thanks for your help
|
|
|
|
|
ronwurster wrote: However, I tried reading the first line (using fscanf) and the pointer was NOT positioned at the beginning of the second line. In fact it was not on the 2nd line at all. Did you mean I should use "fread"? Can you explain please.
char szLine[128];
fscanf(pFile, "%[^\n]\n", szLine); You can also use fgets() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Dumb ideea..but here goes:
for getting the second line start position
1. do a fseek to SEEK_SET
2.do a read the entire first line (fgets )
you are now at the end of first line->beginning of the first.
I don't know if this will work for you (it gets you to the seccond line but i don't know it it is suitable for your code).
Another ideea is to use predefined spaces for your numbers: fprintf(file,"%7d",24)uses 7 spaces(don't know if spaces is the appropiate word) to print the number 24 and alings it to the right. So, if you know how many numbers you have on the first line and you use enough spaces so they don't overflow...you will know the length of the first line which enables you to reposition to the begining of the second line.
Don't know if this helps (sorry for my english...it is not what i hoped it to be )
|
|
|
|
|
pad is a file for submiting software.
I have tested for several, but all are ugly.
which pad file creator do u use now? which one is better?
thx
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
Even though this is not C++ related, I always created them by hand...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
hands are the best.
by the way, what sites (forums) do u use to submit ur software for free? (not paid sites, such as www.downlod.com etc)
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
I no longer use shareware sites - my key algorithms were never even touched until I put the software up on shareware sites. Check Favorites had a keygen within 3 days after I put it up on ~5 sites, and static keys started appearing for Delete FXP Files within 5 days or so (no keygen, though).
So, never again...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL).
Thanx in Advance ,
Regards,
FarPointer
|
|
|
|
|
OpenGL is very special, I think u should post ur Q on a OpenGL forum.
good luck.
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
Hi,
I couldnt Find OpenGL Forum in CodeProject you got a better idea were i can .
Regards,
FarPointer
|
|
|
|
|
This really isn't OpenGL specific but is just trigonometry. Decide on how many points you want to use in your rotation. For each point on the line you want to rotate it 360 degress around the z-axis. Decide what your delta theta is. For each point you will loop from 0 to the number of points and create a vertex as follows:
glBegin( GL_QUADS );
for each point on line
for each delta theta
x1 = x * cos(theta);
y1 = y * sin(theta);
z1 = z1;
glVertex3f( x1, y1, z1 );
glEnd();
I hope this helps you get started.
Deus caritas est
|
|
|
|
|
FarPointer wrote: How can we rotate a 2d line in 3d to get a cone or can anyone point me to any useful resource on this (Open GL).
actually, you are making it too difficult. OpenGL relative to order of operations. So assuming you want to rotate a line 30 degrees you go from this:
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(50.0f, 50.0f, 50.0f);
glEnd();
to this:
glPushMatrix();
glRotatef(30.0,0.0f,1.0f,0.0f);
glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(50.0f, 50.0f, 50.0f);
glEnd();
glPopMatrix();
although the glPushMatrix() and glPopMatrix() are not required operations if you draw another primitive it is relative to the last rotate, push and pop operations restores the rotation matrix to prior to the rotate so that another primitive is relative to the original scene-view not the last rotation.
see this tutorial over at Nehe: Nehe OpenGL tutorial on Rotations[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Might be a little late for this reply, but...
If you want to display a cone in wire or solid form, include glaux.h, and call either auxWireCone(radius, height) or auxSolidCone(radius, height).
If you want to construct a cone on your own, you'll need the mathematical formula for a cone and some code to draw the triangles that form the cone (GL_TRIANGLE_STRIP), and the base of the cone (if desired, also GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN).
In either case, you can call glRotate before drawing the cone, to get the desired orientation of the cone.
delete this;
* poof! *
|
|
|
|
|
Does anyone know an easy way to overcome the problem with the SRT_MAX limit of scrollbars?
-- modified at 12:08 Tuesday 7th March, 2006
|
|
|
|
|
|
This is my code:
void CEditor::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)<br />
{<br />
SCROLLINFO ScrollInfo;<br />
<br />
ScrollInfo.cbSize = sizeof(SCROLLINFO);<br />
ScrollInfo.fMask = SIF_POS | SIF_RANGE;<br />
<br />
GetScrollInfo(SB_VERT, &ScrollInfo);<br />
<br />
switch(nSBCode){<br />
<br />
...<br />
<br />
case SB_THUMBPOSITION:<br />
ScrollInfo.nPos = nPos;<br />
break;<br />
<br />
case SB_THUMBTRACK:<br />
ScrollInfo.nPos = nPos;<br />
break;<br />
}<br />
<br />
SetVScroll(ScrollInfo.nPos);<br />
<br />
CWnd::OnVScroll(nSBCode, nPos, pScrollBar);<br />
}
The problem is that nPos does not become bigger than SRT_MAX. This is because nPos comes from the high-order word of the wParam of the message WM_VSCROLL. So it is just a short value that is casted to an integer. Is there another way to get the current position of the scroll box?
Thanks
|
|
|
|
|
You have to initialize the scroll bar at some point with a call to SetScrollInfo . My guess would be you want to do this in your CEditor::OnCreate handler.
The nPos value you are seeing in your OnVScroll handler varies between the values of nMin and nMax in the SCROLLINFO structure.
Software Zen: delete this;
|
|
|
|
|
Thank you for your help, but I think I have to describe the problem more detailed.
The scrollbar works fine when I move the scroll box with SB_PAGEDOWN or SB_LINEDOWN because in this case I do not need nPos. But when I react on SB_THUMBTRACK or SB_THUMBPOSITION I need nPos. So when I move the scroll box with the mouse to a position that is bigger than SRT_MAX nPos becomes zero and the scroll box jumps back to the top. Again: this is only the case if the scroll box is directly moved with the mouse. When I click on the scroll arrows everything works fine.
So what I need is a way to find out where the user has moved the scroll box when it is above SRT_MAX.
Thanks
|
|
|
|
|
When handling SB_THUMBTRACK , you need to look at the nTrackPos member of the SCROLLINFO structure, not nPos .
Software Zen: delete this;
|
|
|
|
|
Thank you very much. It works.
MSDN is such a great thing, but it happens the you do not to see the wood for the trees.
|
|
|
|
|
I need a refresher...
Are there any circumstances where using a pointer to an unsigned __int64 value could cause problems for an API expecting a PULARGE_INTEGER? For example, GetDiskFreeSpaceEx()...
If it matters...I'm using VC6 to compile an x86 EXE.
|
|
|
|
|
I had the same problem recently using GetFileSizeEx. Turns out LARGE_INTEGER is a struct.
MSDN says...
The ULARGE_INTEGER structure is actually a union. If your compiler has built-in support for 64-bit integers, use the QuadPart member to store the 64-bit integer. Otherwise, use the LowPart and HighPart members to store the 64-bit integer.
<br />
LARGE_INTEGER nTemp;<br />
::GetFileSizeEx(hFile, &nTemp);<br />
<br />
unsigned __int64 nFileSize = nTemp.QuadPart;<br />
"My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
|
|
|
|