following is the code which shows and hide a toolbar...the problem is that it does not displays the toolbar..and the showcontrolbar()does not work either.plz help... Is there any other way round??? I am using visual studio 5.0...
#include<afxwin.h>
#include<afxext.h>
#include<stdafx.h>
#include"resource.h"
class myframe: public CFrameWnd
{
private:
CToolBar t1;
int visible;
public:
myframe() {
Create ( 0, TEXT ( "Toolbar" ) );
}
int OnCreate ( LPCREATESTRUCT l ) {
t1.Create ( this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM );
t1.LoadToolBar ( IDR_TOOLBAR1 );
visible = 1;
return 0;
}
void drawline() {
MessageBox ( TEXT ( "Line" ), TEXT ( "drawline" ) );
}
void drawrectangle() {
MessageBox ( TEXT ( "Rectangle" ), TEXT ( "drawrectangle" ) );
}
void drawcircle() {
MessageBox ( TEXT ( "Circle" ), TEXT ( "drawlcircle" ) );
}
void drawtriangle() {
MessageBox ( TEXT ( "Triangle" ), TEXT ( "drawtriangle" ) );
}
void showtoolbar() {
if ( visible == 1 )
MessageBox ( TEXT ( "Toolbar is already visible" ) );
else {
ShowControlBar ( &t1, TRUE, FALSE );
visible = 1;
}
}
void hidetoolbar() {
if ( visible == 0 )
MessageBox ( TEXT ( "Toolbar is already hidden" ) );
else {
ShowControlBar ( &t1, FALSE, FALSE );
visible = 0;
}
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP ( myframe, CFrameWnd )
ON_WM_CREATE()
ON_COMMAND ( 101, drawline )
ON_COMMAND ( 102, drawrectangle )
ON_COMMAND ( 103, drawcircle )
ON_COMMAND ( 104, drawtriangle )
ON_COMMAND ( 1001, showtoolbar )
ON_COMMAND ( 1002, hidetoolbar )
END_MESSAGE_MAP()
class myapp: public CWinApp
{
public:
int InitInstance() {
myframe *p;
p = new myframe;
p->ShowWindow ( 3 );
m_pMainWnd = p;
return 1;
}
};
myapp a;