Code Library

Free Source Code and Program Tips

How to retrieve the authenticode information

Chinese verion author: Quaful@newsmth.net. When an ActiveX will be installed in IE, the authenticode information will be showed out. And how to get the information by programming? In microsoft KB323809: HOWTO: Get Information from Authenticode Signed Executables, there is a full example code. But it’s not very easy to use in your program directly. So [...]

We often need to create an Enhanced Meta File(EMF) or Bitmap(bmp) from an existed DC draw code. It’s not very difficult but it’s boring to code again and again. The following is a simple solution, what you need to do is only to implement an IPicDrawer and call DrawEnhMeta or DrawBitmap function.

How to change the row height of CListCtrl

When you want to change the height of CListCtrl, you need to use an owner-draw version of CListCtrl and change the font of the control. But when you change the font of the CListCtrl, the control or its parent window does not get a chance to respecify the height of the rows and the effect will not be [...]

Moving selection of CListCtrl

tag: CListCtrl, SetItemState, SetSelectionMark When you try to move the item selection of a CListCtrl object, you should remember to call SetSelectionMark. If not, the program will not work as you think. It will only work once and won’t work any longer. The reason is that even you have called SetItemState and the selection was [...]

How to get a fixed code for serial number

We often look for some fixed serial numbers as an universal id. Usually we can use WMI class to retrieve  some hardware ID as following: Win32_BaseBoard Win32_Processor: ProcessorId Win32_BIOS: SerialNumber, ReleaseDate Win32_MotherboardDevice: InstallDate Win32_DiskDrive We can refer to MSDN WMI C++ Application Examples for some VC++ samples for the usage.But not all of the above WMI [...]

A powerful math function parser(zz)

by Andreas Jdger The inspiration to write this code was to have an easy-to-use parser for functions given as string. You have a string like cos(x)-7*x/(1+x) and you want to compute some values, maybe for displaying the graph of the function. You can write code like this: CFunction* fkt = CFunction::Parse(“cos(x)-7*x/(1+x)”); long double y = [...]

We often meet such case: I have an application with a modeless dialog. The dialog comes up perfectly in DEBUG build, But in RELEASE build, it crashed. Such problem often occures because of incorrect signature of message handle functions, that included into MFC message map for your CWnd based class.We should very carefully check signatures [...]

Here is only a short introduction of the article, if you are interested, please goto the author’s website for the full text. Most people have heard of the standard auto_ptr smart pointer facility, but not everyone uses it daily. That’s a shame, because it turns out that auto_ptr neatly solves common C++ design and coding [...]

Question I have a text file with a lot of lines, and in each line, there are several columns divided by space character, but the number of columns in each line varies. For example, here is a sample ——————– abc 123 234 456 bsc 3 5 7 9 10 123 yyt 23 ——————– I want [...]

What is the usage of WM_NULL?

Alex Rest found the WM_NULL message and was curious where somebody would need to use that. I have found a strange Windows message. It is described in MSDN so: WM_NULL: The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore. [...]