|
Open the file using CreateFile . Now use SetFilePointer with the FILE_END flag. Now call SetFilePointer with FILE_CURRENT and use -8 as the lDistanceToMove value. Thus it moves back 8 bytes (</log>\r\n). If you have only a \n, then put -7 as lDistanceToMove . Now write your stuff and close the file.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
i think a slightly more robust way would be to read the last 100 bytes into memory and find the string and calc its offset and use that when seeking the file position ... unicode chars and whatnots might screw u up if u hard code the sizes into the algorithm
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
hi,
If you're keen on using the C++ library, u could do this with fstream's ::seekg to seek to the end(ios::end) minus the offset which is calculated. The offset would be calculated using sizeof(string). Specify the offset in (-)ve. Now you can write the present contents from this location.
P.S. Open the file in binary mode.
hope this helps,
Sharad
In C you write your own bugs, in C++ you inherit them !
- Anonymous
|
|
|
|
|
So I've got this nifty CFileDialog-extended class that doesn't use the OFN_EXPLORER flag. I need to check the extension the user selected, so to do that, I look at the "cmb1" control (well, also some other Explorer-style control identifiers)
So everything was going well and good, until I found an article on how to allow CFileDialog-derived classes to use the OFN_EXPLORER flag (basically make the OPENFILENAME size 12bytes larger). And now the ASSERT fails.
CWnd* pComboBox = GetParent()->GetDlgItem(cmb1);
ASSERT_VALID(pComboBox);
So, if anyone can point me in the right direction, or just outright solve this problem, that would be great! (I'd rather not have to use Win32 to solve this though)
Thanks in advance.
|
|
|
|
|
Hello all,
I am writing a little vector animation program and want to add rotation to my basic shapes. I have an algorithm that works ok... other than the fact that is shrinks the shape as it rotates! It works much better in OpenGL since its points are floating point. As far as I can tell, the shrinking is due to round off error, going from double to int. I am using the GDI in this case so I can't really do much about it. I am also programming this to run on both 9X and XP so no world transformations. I intend to make this method work for all gdi type basic shapes it is only working (appropriately) with the shapes that are invariant under rotation, the Polyxxxx shapes.
So, can anyone verify my diagnosis or point out other problems? Moreover, can anyone suggest a... less destructive way to rotate?
Thanks alot
////////////////////////////////////////////////////////////////////
int CShape::Rotate(int nAngle) // thar she be!
{
double dAngle = -nAngle * DEG_TO_RAD,
tX, tY, tX2, tY2;
for(int i = 0; i < m_aSourcePoints.GetSize(); i++)
{
tX = m_aPoints[i].x - m_ptRotate.x;
tY = m_aPoints[i].y - m_ptRotate.y;
tX2 = (int)((tX*cos(dAngle))-(tY*sin(dAngle)))+m_ptRotate.x;
tY2 = (int)((tX*sin(dAngle))+(tY*cos(dAngle)))+m_ptRotate.y;
//round the rotates point values
if((tX2 - floor(tX2)) >= 0.5) tX2 = ceil(tX2);
else tX2 = floor(tX2);
if((tY2 - floor(tY2)) >= 0.5) tY2 = ceil(tY2);
else tY2 = floor(tY2);
m_aPoints[i].x = tX2;
m_aPoints[i].y = tY2;
}
return ANI_OK;
}
jon brown
|
|
|
|
|
I want to color a text in Static box on a dialog box with color of the static box same as the dialog box .
Can Anyone suggest a sololution for it.
Samir Sood
|
|
|
|
|
if you want to color statics you can either use one of the enhanced static controls here (norm almonds is a good one mostly) or you can override the OnCtlColor() function in your dialog box (the WM_CTLCOLOR message)
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
I want to dispose tiff image file format .
and I have downloaded some source program ,but I find that this source code have a problem which it doesn't decode CMYK color mode TIFF file . then display CMYK tiff file is error .
do you know how to resolve it ?
thank you
|
|
|
|
|
I want to read CMYK color mode TIFF file
and save CMYK color mode TIFF file
if I transform CMYK TIFF file to RGB file .
then color information will change .
(I use photoshop for testing)
So I want to dispose CMYK TIFF file in CMYK color mode .
no transform .
|
|
|
|
|
get yourself a copy of LibTiff. with it, you can read and write the TIFF data directly.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Yes ,I have used Libtiff .
but it has the same quesiton .
Don't dispose correctly CMYK color mode Tiff Image
I need read and write CMYK color mode Tiff image .
and I have tested CXimage class that downloaded from http://www.codeproject.com/bitmap/cximage.asp
It supports Tiff file ,but there is a problem that It supports CMYK color mode tiff image.
and FreeImage Library ,download from
http://www.codetools.com/bitmap/graphicsuite.asp
it uses Libtiff library .but I find that there is the same problem of supporting CMYK color mode tiff file .
I don't know how to do
help me
Thank you
|
|
|
|
|
thank you
|
|
|
|
|
Why nobody?
|
|
|
|
|
I want to get width and height of richedit control how to get it!
thanks
|
|
|
|
|
Is there a getclientrect() member function? Just a guess....
-Ken Mazaika
|
|
|
|
|
GetClientRect returns just the client area. GetWindowRect returns the area of the entire CWnd object. See API docs for CWnd.
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
#define RectWidth(lprc) ((lprc)->right-(lprc)->left)
#define RectHeight(lprc) ((lprc)->bottom-(lprc)->top)
RECT rc;
int width,height;
GetWindowRect(hwndRichEdit,&rc);
width=RectWidth(&rc);
height=RectHeight(&rc);
Peter O.
|
|
|
|
|
I'm curious as to why you would do it that way. This is not a criticism, just a curiosity.
Why couldn't you just use CRect instead? Also, why are you using the globally scoped GetWindowRect rather than the CWnd GetWindowRect? Is there a benefit to doing it that way?
Here's the way I would do it:
int width = 0, height = 0;
CRect rect;
GetWindowRect( rect );
width = rect.Width();
height = rect.Height();
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Maybe he isn't using MFC/WTL or doesn't want to force that dependency on others.
Tim Smith
"Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution."
Hoare - 1980 ACM Turing Award Lecture
|
|
|
|
|
I'm writing a Winsock application, and I heard that the only way to learn how is browse through the mucky muck of Winsock code. So that's what I did. I'm writing a program based upon Essam Mohammed El-nagar's and I got my program to interact with his server.
Trying to re-write his server is more difficult than I expected though. I've done everything noticable that he had, however whenever I run it, it gets a binding error. His does not. Is there some stupid little line of code that could fix this?
If you care enough to look into my source code I'll upload it on request. Thanks a bunch.
-Ken Mazaika
|
|
|
|
|
I have been trying to write a function in VC++ 6.0 on setting
the setprecision and setw in a function. This is roughly how I intend to do ..
my_set_function(int precision,int width)
{
setprecision(precision);
setwidth(width);
}
fstream io("abc.dat",ios::out);
.
.
double abc=1.234566,bcd=2.3456;
.
io << my_set_function(3,5) << abc << my_set_function(2,4) << bcd;
Since I want to set it for every variable, I hope to do it in a
neater and shorter manner.I know this code is not a functional one , hope someone have some idea of what I am trying to do?
THanks a million!
|
|
|
|
|
If you want to write a manipulator that works for all types, including those that you did not define, then you'll need it to work in tandem with a stream of your own writing, which can very well be simply a stream that uses a normal stream, but applies your manipulator.
Read my articles here on CP in the STL section for info on parameters in manipulators, and writing custom streams.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Thought of playing around abit with OpenGL. Checked codeproject and found some examples.
The annoying thing though is that for some reason I have some lib clash:
a __ftol2 refernce is in one of the opengl libs and can't be found.
I'm using VS6SP5 and latest SDK
Any ideas?
Niklas
|
|
|
|
|
Hi,
I'm currently writing a method that is supposed to shape a region according to a color pattern in a supplied image. To do so I iterate through all the pixels in the image, but when I'm nearing the end, no matter the size of the image, I get an "First-chance exception in ImageRegion.exe (GDIPLUS.DLL): 0xC00000FD: Stack Overflow." exception. I'm new to GDI+ and I can't figure out what I'm doing wrong...
The method looks like this:
HRGN CRegionFromImage::FromFile( const WCHAR* filename, Color color )
{
HDC hDC = ::GetDC( NULL );
Graphics g( hDC );
Bitmap* bitmap = Bitmap::FromFile( filename, FALSE );
if ( bitmap == NULL ) return NULL;
Rect rect( 0, 0, bitmap->GetWidth(), bitmap->GetHeight() );
Region region( rect );
BitmapData* bitmapdata = new BitmapData;
bitmap->LockBits( &rect, ImageLockModeRead, PixelFormat32bppARGB, bitmapdata );
UINT* pixels = (UINT*)bitmapdata->Scan0;
for ( UINT y = 0; y < bitmap->GetHeight(); y++ )
{
for ( UINT x = 0; x < bitmap->GetWidth(); x++ )
{
Color pixelcolor( pixels[y * bitmapdata->Stride / 4 + x] );
if ( color.GetR() == pixelcolor.GetR() && color.GetG() == pixelcolor.GetG() &&
color.GetB() == pixelcolor.GetB() )
{
Rect xorrect( x, y, 1, 1 );
region.Xor( xorrect );
}
}
}
bitmap->UnlockBits( bitmapdata );
delete bitmapdata;
return region.GetHRGN( &g );
}
Thanks,
biff
|
|
|
|
|
I have my own CListCtrl derivied class. It works fine, but I could`n subclass CListCtrl in CListView. Can you help me?????
|
|
|
|