How to convert CString to char* or LPTSTR?

17 12 2008


Without a second thought, I can say that it will be one of the first problems that beginners face – How to convert a CString to LPTSTR. I’ve seen this question several times in forums. Well, i think the CString to LPTSTR conversion is just like this picture. πŸ˜‰

cstringtolptstr


Well, you can use CString::GetBuffer() to access the internal buffer of CString. But one thing to take care is that – you should release the buffer by calling CString::ReleaseBuffer() after use. Check the code snippet below,

// Our CString object.
CString String = "HelloWorld";

// Get the internal buffer pointer of CString.
LPTSTR pString = String.GetBuffer( 0 );
...

// Use the pString and then release it.
String.ReleaseBuffer();


Now get rid of that nasty error message – error C2664: ‘Hello’ : cannot convert parameter 1 from ‘class CString’ to ‘char *’. πŸ˜‰


Targeted Audience – Beginners.





How to reduce the size of Microsoft Word files?

7 12 2008


Documentation is inevitable for developers. Mostly we use Microsoft Word for documentation and you’ve already noticed the huge file size of word files. It often gets several megabytes in size. Its mostly when you copy paste images to document. While pasting, the images are embedded as bitmaps and hence the huge size. Well if you zip it, then it will drastically reduce the size. Well, is there any other method to reduce the size without zipping?

reducewordfilesize


Microsoft Word have built in feature for compressing images. Follow the steps below.

1. Right click any of the pictures in your word document and select “Format Picture”
reducewordfilesize1

2. Now takeΒ  “Picture tab” and click Compress” button.
reducewordfilesize2

3. Now in the compression options, you could select accordingly. For optimal file size, select resolution as “Web/screen” and apply for “All Pictures in document”.
reducewordfilesize3

Now check the file size! Amazing. isn’t it? πŸ˜‰


Well, no more zipping head aches, no more email bouncing due to attachment size. Complete Peace for Mind πŸ˜‰


Targeted Audience – Beginners.