Click here to Skip to main content
15,913,939 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: whats the difference between these three? Pin
Scott H. Settlemier27-Jun-02 8:16
Scott H. Settlemier27-Jun-02 8:16 
GeneralMore info (wierd !!) Pin
Still learning how to code27-Jun-02 2:55
Still learning how to code27-Jun-02 2:55 
GeneralRe: More info (wierd !!) Pin
Still learning how to code27-Jun-02 2:58
Still learning how to code27-Jun-02 2:58 
GeneralEject of PCMCIA card Pin
Josef Schroettle27-Jun-02 2:06
Josef Schroettle27-Jun-02 2:06 
GeneralProblem with creating a toolbar in a DLL Pin
Mohit Khanna27-Jun-02 1:55
Mohit Khanna27-Jun-02 1:55 
GeneralRe: Problem with creating a toolbar in a DLL Pin
Roger Allen27-Jun-02 3:43
Roger Allen27-Jun-02 3:43 
GeneralRe: Problem with creating a toolbar in a DLL Pin
Mohit Khanna27-Jun-02 22:56
Mohit Khanna27-Jun-02 22:56 
GeneralRe: Problem with creating a toolbar in a DLL Pin
Roger Allen27-Jun-02 23:08
Roger Allen27-Jun-02 23:08 
I tackled this problem in one of my own apps. Here is the code I had to load the toolbars from the main program and dock them. Note that you may need to call ShowControlBar() to cause the toolbar(s) to be displayed the first time you run your code.

// in header file
	CToolBar		**m_pTB ;
	int				m_ToolbarCount ;

void CMainFrame::LoadDLLToolbars()
{
	CToolBar	*last = &m_wndMainToolBar ;
	int			count = 0 ;
	// get and create the additional toolbars provided by the DLL's
	for (int DLL_index = 0 ; DLL_index < refineDLLs ; DLL_index++)
		{
		if (refineDLL[DLL_index].DLLGetToolbarCount != 0 && refineDLL[DLL_index].DLLGetToolbar != NULL)
			{
			// functions are present in DLL, get the toolbar count
			count += refineDLL[DLL_index].DLLGetToolbarCount() ;
			}
		}
	if (count > 0)
		{
		m_pTB = new CToolBar*[count] ;		// allocate pointers
		m_DLLIndexes = new int[count] ;		// so we know where to get messages from
		}
	// now load the toolbars
	int		index = 0 ;
	for (DLL_index = 0 ; DLL_index < refineDLLs ; DLL_index++)
		{
		if (refineDLL[DLL_index].DLLGetToolbarCount != 0 && refineDLL[DLL_index].DLLGetToolbar != NULL)
			{
			for (int i = 0 ; i < refineDLL[DLL_index].DLLGetToolbarCount() ; i++)
				{
				m_pTB[index] = refineDLL[DLL_index].DLLGetToolbar(i, this) ;
				//DockControlBarRightOf(m_pTB[index], last);
				DockControlBar(m_pTB[index]) ;//, n, &rect);
				last = m_pTB[index] ;
				m_DLLIndexes[index] = DLL_index ;
				index++ ;
				}
			}
		}
	m_ToolbarCount = count ;
}

CMainFrame::~CMainFrame()
{
	for (int i = 0 ; i < m_ToolbarCount ; i++)
		delete m_pTB[i] ;
	delete []m_pTB ;
	delete []m_DLLIndexes ;
}

// code from a DLL
int DLLGetToolbarCount()
{
	return 1 ;
}

CToolBar*	DLLGetToolbar(int index, CWnd *pMP)
{
	if (index != 0)
		return NULL ;		// we only have the 1 toolbar
	HINSTANCE hInstance = AfxGetResourceHandle();
	// set resource handle to ourselves (the DLL)
	AfxSetResourceHandle(theApp.m_hInstance);

	CToolBar	*pTB = new CToolBar ;
	if (!pTB->CreateEx(pMP, TBSTYLE_FLAT, WS_CHILD | CBRS_ALIGN_TOP, CRect(0, 0, 0, 0), IDR_TRAYTOOLBAR) ||
		!pTB->LoadToolBar(IDR_TRAYTOOLBAR))
		{
		TRACE0("Failed to create toolbar\n");
		// reset resource handle
		AfxSetResourceHandle(hInstance);
		return NULL ;      // fail to create
		}
	pTB->SetBarStyle(pTB->GetBarStyle() | CBRS_BORDER_3D) ;	// lose garnage pixels

	//pTB->SetBarStyle(pTB->GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_GRIPPER);
	pTB->EnableDocking(CBRS_ALIGN_ANY);
	pTB->SetWindowText("TraySetup & Communication");
	pTB->EnableToolTips(TRUE) ;

	g_pTraySetupToolbar = pTB ;
	// reset resource handle
	AfxSetResourceHandle(hInstance);
	return pTB ;
}



Hope it helps.

Roger Allen
Sonork 100.10016

If I had a quote, it would be a very good one.
GeneralRe: Problem with creating a toolbar in a DLL Pin
Mohit Khanna27-Jun-02 23:34
Mohit Khanna27-Jun-02 23:34 
GeneralRe: Problem with creating a toolbar in a DLL Pin
Roger Allen28-Jun-02 0:21
Roger Allen28-Jun-02 0:21 
GeneralRe: Problem with creating a toolbar in a DLL Pin
Mohit Khanna28-Jun-02 0:50
Mohit Khanna28-Jun-02 0:50 
Generalconnecting to a remote database Pin
Sam197927-Jun-02 1:50
Sam197927-Jun-02 1:50 
GeneralRe: connecting to a remote database Pin
Le centriste27-Jun-02 5:19
Le centriste27-Jun-02 5:19 
GeneralRe: connecting to a remote database Pin
Mike Nordell28-Jun-02 9:35
Mike Nordell28-Jun-02 9:35 
GeneralAbout memory leaks Pin
Rage27-Jun-02 1:47
professionalRage27-Jun-02 1:47 
GeneralRe: About memory leaks Pin
Ramu Pulipati27-Jun-02 2:01
Ramu Pulipati27-Jun-02 2:01 
GeneralRe: About memory leaks Pin
Rage27-Jun-02 2:19
professionalRage27-Jun-02 2:19 
GeneralRe: About memory leaks Pin
Christian Graus27-Jun-02 2:21
protectorChristian Graus27-Jun-02 2:21 
GeneralRe: About memory leaks Pin
Frank Driesens27-Jun-02 2:40
Frank Driesens27-Jun-02 2:40 
GeneralRe: About memory leaks Pin
Rage27-Jun-02 2:55
professionalRage27-Jun-02 2:55 
GeneralRe: About memory leaks Pin
LittleYellowBird27-Jun-02 4:33
LittleYellowBird27-Jun-02 4:33 
GeneralRe: About memory leaks Pin
Rage27-Jun-02 4:51
professionalRage27-Jun-02 4:51 
GeneralGetting shldisp.h Pin
Ravi Shankar27-Jun-02 1:35
Ravi Shankar27-Jun-02 1:35 
GeneralRe: Getting shldisp.h Pin
Ramu Pulipati27-Jun-02 1:57
Ramu Pulipati27-Jun-02 1:57 
GeneralCRecordset - Retrieving SQL & Parameters on Fail Pin
Henry Kafeman27-Jun-02 1:02
Henry Kafeman27-Jun-02 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.