I want to create, destroy, and recreate a floating CtoolBar palette on the fly. I can get the create function to work the first time used, but after destroying that object, it will not recreate. It seems to get hung up at the LoadBitmap process the second time. I've tried loading the buttons' bitmap once at the program's initiation and then using the SetBitmap function to establish that operation. That worked too, only once. Why? Thank you.
Following are snippets of the code;
BM = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCEA(IDC_PALETTE));//done in CMainFrame::OnCreate
void CMainFrame::MakeToolBar()
{
EnableDocking(CBRS_ALIGN_ANY);
if (!m_wndPaletteBar.Create(this, WS_CHILD | CBRS_GRIPPER | WS_EX_TOOLWINDOW | WS_VISIBLE | CBRS_SIZE_DYNAMIC |
CBRS_TOP | IDW_PALETTE_BAR) ||
/*!m_wndPaletteBar.LoadBitmap(IDC_PALETTE)*/
!m_wndPaletteBar.SetBitmap(BM) ||
!m_wndPaletteBar.SetButtons(PaletteButtons, sizeof(PaletteButtons) / sizeof(UINT)))
{
TRACE0("Failed to create palettebar\n");
}
.......
void CMainFrame::DestroyToolBar()
{
if (m_wndPaletteBar)
{
m_wndPaletteBar.DestroyWindow();
}
}