Archive for January, 2007

Published by alax on 21 Jan 2007

Extending life of Correct Identity Mozilla addon for Mozilla Thunderbird

Correct Identity is a beautiful addon for Mozilla Thunderbird, the major problem is that Dennis Verspuij has not been having time or desire to keep it up to date and the goody became incompatible with the email client starting version 1.5.

To extend addon’s life a bit it is possible to adjust compatibility information so that the same addon, as it is, could be recognized by Thunderbird version 1.5.

To do this, it is required to locate addon’s RDF file, I have it in:

$(SystemDrive):\Documents and Settings\$(UserName)\Application Data\Thunderbird\Profiles\$(ProfileName)\extensions\{47ef7cc0-2201-11da-8cd6-0800200c9a66}\install.rdf

This is a text file in XML format, openable by text editor, it contains text:

< RDF:Description RDF:about="rdf:#$dZX88"
em:id=”{3550f703-e582-4d05-9a08-453d09bdfdc6}”
em:minVersion=”1.0″
em:maxVersion=”1.4″ / >

which needs to e replaced with, for example:

< RDF:Description RDF:about="rdf:#$dZX88"
em:id=”{3550f703-e582-4d05-9a08-453d09bdfdc6}”
em:minVersion=”1.0″
em:original-maxVersion=”1.4″
em:maxVersion=”1.5″
/ >

and after Thunderbird 1.5 restart it will recognize and start the addon. It seems the addon works with Thunderbird 1.5, no problems so far.

Published by alax on 21 Jan 2007

Smart ATL/WTL combo box and list view classes to cast and optionally manage typed control item data

Inspired by the post on Yahoo’s WTL group (actually, I have been going to post on this topic for a couple of weeks already).

Standard Windows controls (including common controls) that have multiple items (list box, combo box, list view, tree view etc.) have an option to attach user defined value of type DWORD_PTR (LPARAM) to each item. This is quite sufficient when using controls, however type cast to and from DWORD_PTR is required with most control item data operations.

CAiComboBoxT and CAiListViewT classes templates redefine GetItemData/SetItemData methods to perform automatic type casts. An optional template class CAiListControlDataTraitsT does even more: it manages per-item definted item data class in contained CAtlList collection and attached a pointer to item data class to each control item.

The classes may be used as follows:

CAiComboBoxT < CComboBoxItemData* > m_ComboBox;
CAiListViewT < CListViewItemData, CAiListControlDataTraitsT > m_ListView;

m_ComboBox is a combo box window class (CComboBox descendant) with CComboBoxItemData pointer defined as control item data.

m_ListView is a list view class (CListViewCtrl descendant) with CListViewItemData defined as control item data. CListViewItemData instances are managed by control class using CAtlList collection (and a position in the collection is actually casted to DWORD_PTR and set as lower level control item data).

20-image001.png

Continue Reading »

Published by alax on 20 Jan 2007

Automated Resource Updater updated (1.0.2)

An update is inspired by necessity to strip DS_FIXEDSYS dialog style which Visual Studio adds to the dialog template once it is modified in resource editor.
What’s new in this build?

  • Fixed: Failure accessing STRINGTABLE values with identifiers such that ((IDS & 0×0F) == 0×0F)
  • New: Unicode build
  • New: Static link to C runtime, smaller binary and download
  • New: Dialogs property and accessor to resource dialog templates, dialogs collection exposes enumerator and individual resource accessor of type Dialog. Dialog object has a read/write Style property

Continue Reading »

Published by alax on 17 Jan 2007

CAutoHideScrollBarsEdit: a multiline edit control which shows and hides scroll bars automatically in ATL and WTL

The idea is not new, to say the least, the interested ones may check this topic at codeguru.com. This sample demonstrate a most simple (and straightforward) method how to do the task and is basically a demo for a simple custom control, which is based on existing control.

17-image001.png

Continue Reading »

Published by alax on 14 Jan 2007

How to obtain call stack programmatically in ATL and WTL (actually, ATL only)

While debugging, obtaining call stack at a certain [problematic] point of execution, such as especially deadlock condition or on assert, is an invaluable help. Debugger shows it, however it is possible to get the call stack programmatically and even more: having program database along with the executable it is even possible to resolve symbols and source code position. All this programmatically, without debugger running!

14-image001.png

Continue Reading »

Published by alax on 11 Jan 2007

WTL style notification message cracking macros for common control notifications

Windows Template Library contains atlcrack.h header file with macros to reinterpret window message parameters: split if required and cast to proper type. For instance, instead of:

MESSAGE_HANDLER_EX(WM_SIZE, OnSize)

LRESULT OnSize(UINT, WPARAM wParam, LPARAM lParam)
{
UINT nType = (UINT) wParam;
CSize Extent(LOWORD(lParam), HIWORD(lParam));

it allows to make things simpler and in a more reliable fashion:

MSG_WM_SIZE(OnSize)

LRESULT OnSize(UINT nType, CSize Extent)
{

However, WTL’s macros only crack messages. WM_NOTIFY notifications are to be handled using MSG_WM_NOTIFY macro and the parameters are to be casted in each hander.

An aiwtlcrack.h header file included into project below defines macros to crack notifications for common controls (commctrl.h defined in header file in Platform SDK). The header defines, for example, macros: MSG_NM_DBLCLK, MSG_LVN_ITEMCHANGED, MSG_TVN_CUSTOMDRAW etc. Some of the notifications are duplicated to be able to use specific of the control class. For example, NM_CUSTOMDRAW notification message for a list view can be handled with both MSG_NM_CUSTOMDRAW and MSG_LVN_CUSTOMDRAW. In the latter case the argument will be casted to NMLVCUSTOMDRAW.

Continue Reading »

Published by alax on 11 Jan 2007

Regular Expression bug in Visual Studio 2005

I already encountered similar issue once before but did not write down the details.

Text:

#define TBN_GETBUTTONINFO (TBN_FIRST-0)
#define TBN_BEGINDRAG (TBN_FIRST-1)
#define TBN_ENDDRAG (TBN_FIRST-2)
#define TBN_BEGINADJUST (TBN_FIRST-3)
#define TBN_ENDADJUST (TBN_FIRST-4)
#define TBN_RESET (TBN_FIRST-5)
#define TBN_QUERYINSERT (TBN_FIRST-6)
#define TBN_QUERYDELETE (TBN_FIRST-7)
#define TBN_TOOLBARCHANGE (TBN_FIRST-8)
#define TBN_CUSTHELP (TBN_FIRST-9)

Find What (using regular expressions):

^\#define:b+({([A-z\_])+}):b+.+$

Replace With:

#define MSG_\1(nIdentifier, Function) CC_MSG_WM_NOTIFY(\1, NMHDR, nIdentifier, Function)

Visual Studio C++.NET 2003 (correct):

#define MSG_TBN_GETBUTTONINFO(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_GETBUTTONINFO, NMHDR, nIdentifier, Function)
#define MSG_TBN_BEGINDRAG(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_BEGINDRAG, NMHDR, nIdentifier, Function)
#define MSG_TBN_ENDDRAG(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_ENDDRAG, NMHDR, nIdentifier, Function)
#define MSG_TBN_BEGINADJUST(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_BEGINADJUST, NMHDR, nIdentifier, Function)
#define MSG_TBN_ENDADJUST(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_ENDADJUST, NMHDR, nIdentifier, Function)
#define MSG_TBN_RESET(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_RESET, NMHDR, nIdentifier, Function)
#define MSG_TBN_QUERYINSERT(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_QUERYINSERT, NMHDR, nIdentifier, Function)
#define MSG_TBN_QUERYDELETE(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_QUERYDELETE, NMHDR, nIdentifier, Function)
#define MSG_TBN_TOOLBARCHANGE(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_TOOLBARCHANGE, NMHDR, nIdentifier, Function)

Visual Studio C++.NET 2005 (wrong):

#define TBN_GETBUTTONINFO (TBN_FIRST-0)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)

« Prev - Next »