// JP opened flex table

Click to See Complete Forum and Search --> : Customizable toolbar (2) - Stas Levin : Bug causes RIP


Matthew Bond
May 11th, 1998, 12:38 PM
There seems to be a small bug in the otherwise fantastic code ftom Stas Levin


The bug is only in the sample application and does not affect his dll


The bug was causing the toolbars to be incorrectly positioned when the program was started and eventually caused a crash.


The problem is that the control bars are serialized, and read back from the registry. The unique ID for the control bar comes from the Control ID given to it during Creat[e]ion. The implementation of Create has CWnd* Parent, then two default parameters. These are the style and then the control ID.

The sample program adds the standard tool bar and then a User toolbar. The user toolbar is created with .Create(this) which means the default parameters are used, leading to the user toolbar having the same control ID as that of the Standard toolbar. This causes confusion as to which toolbar is which, thus the incorrect positioning of serialized information etc.


The fix is very simple


in MainFrm.cpp line 112


//-------------------------

// Load the "user" toolbar:

//-------------------------

if (!m_wndUserToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, IDR_USERTOOLBAR) || m_wndUserToolBar.SetImages (&m_StandardImages, &m_UserImages))

{

TRACE0("Failed to create user toolbar\n");

return -1; // fail to create

}


now it works fine as we are passing IDR_USERTOOLBAR as the ID (which you still have to define somewhere, making sure it is unique)


Hope this helps


Matt Bond

//JP added flex table