I am updating an application that used a much older version of the CodeJock libraries.
The application has a complicated class that is derived from CButton used in a toolbar, so I would like to just use this class with CXTPControlCustom.
While the toolbar buttons appear fine, there is no response when they are clicked.
So I modified the Samples\CommandBars\CommonControls sample to add a CButton to the CommandBar using CXTPControlCustom to try to understand the problem. I am unable to get any action out of clicking the CXTPControlCustom CButton in the modified sample, either.
Seems like I am missing something obvious and I hope some CodeJock experts can help out.
Here is the code from the modified sample application, where I create the custom control.
int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
int iID = lpCreateControl->nID;
// Create the Button control
if (lpCreateControl->nID == ID_TVTOOLBAR_BMP2)
{
// Get the ID of the control currently being created
UINT nID = lpCreateControl->nID;
m_wndTVButton1.Create( "TVButton1",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
CRect(0, 0, 70, 20), this, ID_TVTOOLBAR_BMP2);
m_wndTVButton1.SetFocus();
// Use m_wndTVButton1 to create a CXTPControlCustom* control
CXTPControlCustom* pCustomButton = CXTPControlCustom::CreateControlCustom(&m_wndTVButton1);
// Set the ID of the custom control to the ID of the radio button
pCustomButton->SetID(nID);
lpCreateControl->pControl = pCustomButton;
return TRUE;
}
Here is the code from the MESSAGE_MAP where I tried to catch the button click event (I tried various methods, none worked).
ON_COMMAND(ID_TVTOOLBAR_BMP2, OnTVButtonClicked)
ON_BN_CLICKED(ID_TVTOOLBAR_BMP2,OnTVButtonClicked)
ON_XTP_EXECUTE(ID_TVTOOLBAR_BMP2, OnTVButtonExecute)
and the simple functions that never get called are below.
void CMainFrame::OnTVButtonClicked()
{
AfxMessageBox( "TV Button Clicked Msg");
}
void CMainFrame::OnTVButtonExecute(NMHDR *pNMHDR,LRESULT *pResult)
{
AfxMessageBox( "TV Button Clicked Execute Msg");
}
Thanks for the help,
Tom
|