|
EXCELLENT!
These fixed a bunch of my problems.
Thanks!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have just upgraded from 6.0 to Visual studio 2005. None of my code from programs written under C++ 6.0 will build. I get all sorts of errors "cannot convert perameters" etc... Is there a way to set my project so I can use my original code?
|
|
|
|
|
You're getting those errors because the compilers in VC 7 and 8 are vastly improved over VC 6, and don't accept code that VC 6 did. You'll need to bite the bullet and fix up the code.
|
|
|
|
|
Thanks for your response. I am able to open the original project with VC 8 and it builds fine but, uses the old visual styles. I would just like to be able to use the new styles without re-writting the whole program. I was hoping there were some depecndancies or something along those lines that would accomplish this. Seems kinda harsh to have re-write the whole thing
Thanks Again,
Terry
|
|
|
|
|
Google for "common controls manifest" - there's info about the visual styles all over the place.
|
|
|
|
|
Anyone know how to change the text color for a particular column in a record list?
I have:
COLORREF crBkColor = (255,0,0);
m_RecordList.SetTextColor(crBkColor);
m_RecordList.SetItemText( m_nSelItem, THE_COLUMN, TEXT("HELLO") );
But i only want to color that record in that specific column and not all records in all columns.
|
|
|
|
|
I hope i could get a view on this .
if i have an STL vector
vector<BYTE> vec[45] ;
Now BYTE * p = reinterpret_cast<BYTE*>&vec[0] ;
some operations
..
p++;
is it safe to assume that the pointer p can be used safely even though its pointing to the address of a vector ?
-- modified at 15:44 Wednesday 11th April, 2007
-- modified at 16:32 Wednesday 11th April, 2007
Engineering is the effort !
|
|
|
|
|
It can be if you intend on accesing bytes of the vector objects.
It doesn't point to the elements contained in the vectors.
*edited*
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Mark Salsbery wrote: It can be if you intend on accesing bytes of the vector object.
You win a free Fish Filet!
led mike
|
|
|
|
|
Thanks man! I'm HUNGRY!
Looking at it again... &vec is the address of the address of the first vector in the array?
Help
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Sorry I intended to use
Now BYTE * p = reinterpret_cast<BYTE*>&vec[0] ;
This is meant to point to the first byte .
however is it safe to do operations such as
p++ and expect it to move to the next vector element( next byte in this case) .
I am asking this since someone gave me this as a solution of creating a block of memory dynamically and not worrying about calling delete ( as one would with doing new) .
Engineering is the effort !
|
|
|
|
|
act_x wrote: Sorry I intended to use
Now BYTE * p = reinterpret_cast<byte*>&vec[0] ;
Cool. That syntax reads better to me Just reinterpret_cast<BYTE*>(vec) "works" too.
act_x wrote: however is it safe to do operations such as
p++ and expect it to move to the next vector element( next byte in this case) .
p points to the first byte of the first vector object, NOT to the elements of the first vector.
So, no.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
act_x wrote: I am asking this since someone gave me this as a solution of creating a block of memory dynamically and not worrying about calling delete ( as one would with doing new) .
A "smart pointer" or similar may be a better solution.
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
The answer is basically no it is not safe, except in certain very resrictive circumstances. In particular if you add elements to the vector, your pointer could very readily be invalidated. A better way to do it is to use itertors.
However, if your concern is simple block of memory, I'd suggest what you need is a change in perspective. A vector is a block of memory, albeit with a type structure imposed on it. Why pretend it is a BYTE*, why not just use a vector?
|
|
|
|
|
you might want to investigate Iterators
led mike
|
|
|
|
|
This line:
vector<byte> vec[45]; </byte> does not declare a vector. It declares an array of vectors. From your description, I don't think that's what you intended.
But if you have a vector, its storage is guaranteed to be contiguous, so taking the address of vec[0] is fine. Last modified: 7hrs 19mins after originally posted --
|
|
|
|
|
act_x wrote: if i have an STL vector
vector<BYTE> vec[45] ;
No you don't: you have an array of 45 vectors!
act_x wrote: BYTE * p = reinterpret_cast<BYTE*>(&vec[0]);
NOTE: Underlined brackets were added by me. They are needed.
This reinterpret_cast is not needed as the type of &vec[0] is already a BYTE* .
act_x wrote: is it safe to assume that the pointer p can be used safely even though its pointing to the address of a vector ?
It isn't pointing to a vector but rather an element contained in the vector.
Steve
|
|
|
|
|
|
|
You can also browse thru the link
http://msdn2.microsoft.com/en-us/library/ms997646.aspx
|
|
|
|
|
Thank you friends for your nice and quick reply.You have solved my problem.Thanks again !!!
Regards
Avinash Gupta
1st Year B-TECH Student(CSE),
ITER India.
|
|
|
|
|
Hi,
Can anybody explain to me how to be able to save and also print the drawing(using GDI) in a CWnd custom control in a dialog box.There are a few custom controls that display different part of the total drawing to be saved and maybe printed and one of them has a scrollbar. Is there any article that i can refer to?
|
|
|
|
|
Hi there,
I have a .txt file and characters was read from it and was put into character arrays. However, for example if the int 22 and 4 is read from the file and was put into an array of integers, how can I write it in a file using fstream.write(). As far as i know, to use this function, the output should be in character format. Therefore, may i know how to change the integer into character array of '22' and '4' and put into fstream.write().
Thanks for any suggestions!
|
|
|
|
|
I hope this help
Streams were originally designed for text, so the default output mode is text. In text mode, the newline character (hexadecimal 10) expands to a carriage return–linefeed (16-bit only). The expansion can cause problems, as shown here:
#include <fstream.h>
int iarray[2] = { 99, 10 };
void main()
{
ofstream os( "test.dat" );
os.write( (char *) iarray, sizeof( iarray ) );
}
You might expect this program to output the byte sequence { 99, 0, 10, 0 }; instead, it outputs { 99, 0, 13, 10, 0 }, which causes problems for a program expecting binary input. If you need true binary output, in which characters are written untranslated, you have several choices:
Construct a stream as usual, then use the setmode member function, which changes the mode after the file is opened:
ofstream ofs ( "test.dat" );
ofs.setmode( filebuf::binary );
ofs.write( char*iarray, 4 ); // Exactly 4 bytes written
Specify binary output by using the ofstream constuctor mode argument:
#include <fstream.h>
#include <fcntl.h>
#include <io.h>
int iarray[2] = { 99, 10 };
void main()
{
ofstream os( "test.dat", ios::binary );
ofs.write( iarray, 4 ); // Exactly 4 bytes written
}
Use the binary manipulator instead of the setmode member function:
ofs << binary;
Use the text manipulator to switch the stream to text translation mode.
Open the file using the run-time _open function with a binary mode flag:
filedesc fd = _open( "test.dat",
_O_BINARY | _O_CREAT | _O_WRONLY );
ofstream ofs( fd );
ofs.write( ( char* ) iarray, 4 ); // Exactly 4 bytes written
|
|
|
|
|
I'm not exactly sure what you are asking, but
<br />
#include <fstream><br />
using namespace std;<br />
<br />
ofstream out("x.txt");<br />
<br />
int n = 22;<br />
int m = 4;<br />
<br />
out << n << endl;
out << m << endl;
out << "n = " << n << ", m = " << m << endl;
<br />
results in the following three lines of output:
<br />
22<br />
4<br />
n = 22, m = 4<br />
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|