Posts Tagged ‘programming’

Undefined behavior in C and C++

19/08/2010 3 comments

Another great article diving into the mess of standard C/C++ and describing the basic concepts which are often ignored by programmers.

Nonetheless, I have just read part 1. Have no time for this right now. Place it here as a bookmark, read later…


RTF to HTML converter in C++

14/09/2009 1 comment

Download source code (9KB)

Nearly, I used RichEditCtrl in a MFC project, and I want to take formatted RTF text in that control to display on a HTML control. I searched through CodeGuru and found this one. It’s a nice job, but it leaks 2 things:

  • Doesn’t work well with unicode. In fact, it can’t recognize unicode characters.
  • A minor error when calculating font size.

As you maybe known, in RTF format, an unicode character is encoded in two ways:

  • \u6884: 6884 is character code (in decimal) of this letter (it’s “Ấ“) .
  • \’1EA4: 1EA4 is character code (in hexadecimal) of this letter (it’s “Ấ“) .

So I slightly modified Daniel Beutler’s code in order to work around these problems. You can found my code in the following functions: CRTF_HTMLConverter::R2H_CreateHTMLElements and Util::StringToLong.

Serialize and deserialize BITMAP object in MFC/Win32

09/07/2009 5 comments

Download the source code for various platforms: WinCE/WinMobile, Win32 API

Update Feb 10, 2011: The source code I uploaded is for WinMobile platform. Today I have modified and upload the Win32 version. All the source code inside this post is also changed to Win32 version.

Lately, in one of my project, I have to save an BITMAP object into an XML document. The problem is I can only save an CString into the XML document. So I have to find a way to convert BITMAP data (in a HBITMAP) into CString.

It’s pretty easy if I serialize the BITMAP to an byte[] array, and then convert the result byte[] array into CString format. So I will consequently discuss on these 2 problems.

Read more…

MSP Tech Passion

23/02/2009 5 comments

Today I had a presentation about Functional Programming in .NET with C# and F# at Microsoft Vietnam office, according to the MSP Tech Passion conference series. Everything is OK, and I think the audience gets somewhat exciting with my presentation.

I have uploaded the slide and demo source code here. Fell free to comment and discuss about this.

An easy way to make transparent picture control in MFC

28/01/2009 4 comments

I’m going to describe the way to make a transparent picture box control in MFC (Smart Device application). It worked well on Windows CE, and it should also be fine on Win32 application.

The key function is TransparentImage. Using it, you will see that the job is pretty simple…

Read more…

Sending SMS message in Windows CE

15/01/2009 31 comments

Download the source code

Today I will show the way to send SMS message in Windows CE and Windows Mobile, using C++ and P/Invoke in .NET CF. It’s pretty simple…

In Windows CE environment, SMS fuction is handled by “sms.dll”, but in Windows Mobile 2005 and later, it’s handled (in a much more simpler way) by “cemapi.dll”. The “cemapi.dll” is not documented very well, in the other hand, you can find lots of information about “sms.dll” on MSDN.

Read more…

What can you do with MS SmallBasic

I spent my rarely free time before the Lunar New Year holiday by playing with SmallBasic – one of more interesting tools introduced by Microsoft. Just another easy tool for newbies, and at the first sight, I was really skeptical. SmallBasic just has less than 15 keywords, and I can’t imagine anything I can do with it…

Read more…