Friday, October 31, 2008

Windows Mobile API ToolBar

Today I'd like to make some suggestion about CCommandBar class for Windows Mobile 5.0.
You can use MFC menu wrapper class or you can use Windows WINAPI function to get access to the ToolBar

MFC class CCommandBar class has no API to access to menu items and doesn't know how to control the menu. After a brief investigation and experiments with the menu I have got a working code:
 ::SendMessage(m_oCommandBar.GetSafeHwnd(),     TB_GETBUTTON, 1, (LPARAM)&tbb);
 HMENU hMenu=HMENU(tbb.dwData);

     ::InsertMenu(hMenu,0,MF_BYPOSITION, ID_MENU_FR_SHOWDETAILS, L"Show Details");

Here m_oCommandBar is an instance of CCommandBar. By using windows messages you can access to WINAPI menu and create a dynamic menus :-)

Thursday, October 9, 2008

WMI database

Hi there !
I'd like to tell you about WMI
It's a pretty huge database with common API to access to the hardware/software information
It contains different information about operating system and hardware. For example computer name, TCP/IP address, DNS, and DHCP information and many other keys that are necessary for normal working.
Also, I notice that it builds as a COM service and it is available from different languages C++, C, Pascal, Visual Basic and scripts such as VBScript.
According to C++ to invoke a method we need to do a lot of work. So I show you how to use:
I have created two classes: first is for reading properties, second to invoke methods.
WMI divided to several groups and each group contain classes:
For example Network group contains NetworkAdapter, NetworkAdapterConfigurator
It's not a c++ classes. Actually, it is a description of the class which you can use with not C++ languages.

Tuesday, September 23, 2008

small annoying bugs :-(

Sometimes when you debugging a code, You don't expect a bug in project settings and you may spend hours to find it.

Here is some suggestions that may help you with it.
This is applicable to mobile development:

1. All resources line memory allocation, files, etc., you need to put in a wrapper: shared_ptr myPointer(rawPointer)

2. All unexpected behavior line "low memory" should throw an exception and exit.

class MyDataBlock
   char* mData;
   MyDataBlock():mData(int size)
      ASSERT(size>0,"wrong size");
      mData = new char[size];
      ASSERT(mData,"low memory");

      delete[] mData;

3. Logs
  • developer logs - you must have them if there is no way to run application in debug mode. This is more applicable to OS driver development or other specific domain development.
  • when exception happen try to log stack. When application crashes it is very useful to have function calls stack. 

Thursday, July 31, 2008

Factorial calculation

Hello everyone!
Yesterday, I have implemented program that calculates 2347!.
That is the same as 1*2*...*2347
It is  really big number that holds 10000 digits
I will publish it in the next posts. One thing I observed is: I like creating really compact programs...

Tuesday, July 22, 2008

User activity

I'd like to create a user activity driver

It will have two modes:

  • in the first mode, it collects data from the user (mouse and keyboard) and store them to a local file
  • in the second mode, it reproduces data from the file so we could have a very small sized video demonstration.

Thursday, July 17, 2008

Folder monitor

I'd like to implement folder monitor. I think it should be easy because there is a Win32 API to do this.

Also, I could do this via driver...

Wednesday, July 16, 2008

Internet browser

I am going to use internet Browser in
my own application

In this case I'll have different GUI with minor changes in the code

Thursday, July 10, 2008


I'd like to implement TimeLogger. It's a program to log your working time

Compiler for STOLL

Actually now I can explain only expression analyzer but I am working to understand whole compilation process