RTF to HTML converter in C++

14/09/2009

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

Download the source code

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 the rest of this entry »


Easily way to make transparent picture control in MFC

28/01/2009

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 be fine on Win32 application.

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

Read the rest of this entry »


What can you do with MS SmallBasic

11/01/2009

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, but I wonder if “what can I do with it?”. It’s just has less than 15 keywords, and at the 1st sight, I can’t imagine anything I can do with it…

Read the rest of this entry »


“Ruby”, hehe….

08/01/2009

Vô tình đọc dc cái này, học dc cách phỏng vấn nhân sự, hehe…

May mà có người tốt bụng dịch lại, ko thì chắc cũng chả siêng ngồi đọc từ đầu đến cuối :) )

Read the rest of this entry »


Some notes on Intel Nehalem architecture

29/12/2008

Dù chip Core i7 – sản phẩm đầu tiên thuộc dòng Nehalem – vẫn chưa được Intel ra mắt tại VN, nhưng mình đã đọc một số thông tin về nó, và thật sự đó là một thiết kế đáng ngưỡng mộ. Mình ghi lại một số cải tiến của Nehalem so với dòng Core tiền bối…

Read the rest of this entry »


10 Useful Techniques To Improve Your User Interface Designs

17/12/2008

Lại thêm 1 bài báo nữa về UI design, nhưng h thì lười wá, không copy nữa (mà cũng chưa đọc hết dc nó), nên đặt tạm cái link đây vậy:

http://www.smashingmagazine.com/2008/12/15/10-useful-techniques-to-improve-your-user-interface-designs/


Colors and the UI: another good article for UI designers

27/11/2008

As the name suggests, GUIs (Graphical User Interfaces) present their features and functions visually. The human-computer interaction is heavily based on seeing things, looking for things and interacting with graphical UI elements. Color is a main characteristic of any visual scene, not only on computer screens, but in any situation where we see something. Because most of what we see and interact with in our everyday life is colored (as opposed to shades of white-gray-black), we are very familiar with colors – maybe so much that we don’t think about them a lot. On the other hand, it does bother us when we need to read a dark-gray label on a black button. So colors have the potential to boost or wreck the user experience. This article will introduce the concept of user experience and highlight some aspects of colors and color perception together with recommendations for UI design.

Read the rest of this entry »


Funny stuffs

25/11/2008

Đọc được mấy câu hay hay khi đang đi tìm tài liệu, không ghi lại thì thật là phí:

Programs must be written for people to read, and only incidentally for machines to execute.
(Abelson & Sussman, Structure and Interpretation of Computer Programs)

Easier to Ask Forgiveness than Permission

–> tròng vòng lặp, thay vì check bound thì cứ read đại rồi try catch (???)

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
(Brian W. Kernighan, cùng tác giả của The C Programming Language và là chữ “K” trong “AWK”)

Câu này nghe hay nhất :) )


Về “Đi tìm cái tôi đã mất” của Nguyễn Khải

03/11/2008

Mình được nghe phong phanh về tùy bút chính trị cuối cùng này của cố nhà văn Nguyễn Khải. Dù ít đọc văn của ông nhưng mình cũng đã có đôi chút cảm tình với những truyện ngắn giản dị nhưng đầy tính nhân văn. Thế mà đọc xong tùy bút này, chợt có chút gì hụt hẫng dâng lên…

Read the rest of this entry »