明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: xiaotina

急,求救:AutoCad框架上停靠工具条遇到问题

  [复制链接]
 楼主| 发表于 2004-8-3 10:56:00 | 显示全部楼层
#include "stdafx.h"
#include "BarTest.h" #include "ToolbarCal.h"
#include "ToolbarHandler.h" #ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif static AFX_EXTENSION_MODULE BarTestDLL = { NULL, NULL }; CToolbarCal *pToolbar;
CToolbarHandler *pToolbarHandler; extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("BARTEST.DLL 初始化...\n");

// Extension DLL one-time initialization
if (!AfxInitExtensionModule(BarTestDLL, hInstance))
return 0; // Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.
CTemporaryResourceOverride::SetDefaultResource(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("BARTEST.DLL 退出...\n");

DeleteBar(); // Terminate the library before destructors are called
AfxTermExtensionModule(BarTestDLL);
}
return 1; // ok
} BOOL InitBarTest()
{
new CDynLinkLibrary(BarTestDLL);

return CreateBar();
}
BOOL CreateBar()
{
CMDIFrameWnd *pAcadFrame = acedGetAcadFrame(); CTemporaryResourceOverride mrs; pToolbar = new CToolbarCal;
if(!pToolbar){
AfxMessageBox(IDS_ERR_CREATETOOLBAR);
return FALSE;
} // Enable AutoCAD's mainframe for docking
pAcadFrame->EnableDocking(CBRS_ALIGN_ANY);
// need this step to force some MFC initialization
pAcadFrame->RecalcLayout(); BOOL s1 = pToolbar->CreateEx(pAcadFrame,TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |
CBRS_SIZE_DYNAMIC | CBRS_FLYBY | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS); if(!s1){
AfxMessageBox(IDS_ERR_CREATETOOLBAR);
delete pToolbar;
pToolbar = NULL;
return FALSE;
} pToolbar->SetBorders(5,2,5,2);
BOOL s2 = pToolbar->LoadToolBar(IDR_TOOLBAR_DEBUG); if(!s2){
AfxMessageBox(IDS_ERR_CREATETOOLBAR);
delete pToolbar;
pToolbar = NULL;
return FALSE;
} // create toolbar handler
pToolbarHandler = new CToolbarHandler; if(!pToolbarHandler){
AfxMessageBox(IDS_ERR_CREATETOOLBAR);
delete pToolbar;
pToolbar = NULL;
return FALSE;
}
BOOL s3 = pToolbarHandler->Create(NULL, NULL, WS_CHILD, //| WS_MINIMIZE,
CRect(0,0,1,1), pAcadFrame, IDW_TOOLBARHANDLER);
if(!s3){
AfxMessageBox(IDS_ERR_CREATETOOLBAR);
delete pToolbarHandler;
pToolbarHandler = NULL;
delete pToolbar;
pToolbar = NULL;
return FALSE;
} CString s;
s.LoadString(IDS_STR_TOOLBARTITLE);
pToolbar->SetWindowText(s);
pToolbar->EnableDocking(CBRS_ALIGN_ANY);
CToolBarCtrl *pTbc=&pToolbar->GetToolBarCtrl();
pTbc->SetOwner(pToolbarHandler);
// pTbc->RestoreState(m_regkey, "辅助制图", "ToolBar");
// pTbc->EnableButton(ID_PGDM);
pAcadFrame->DockControlBar(pToolbar, AFX_IDW_DOCKBAR_TOP, CRect(500,300,600,400));
pAcadFrame->ShowControlBar(pToolbar, TRUE, TRUE);
pAcadFrame->FloatControlBar(pToolbar,CPoint(600,80)); return TRUE;
} void DeleteBar()
{
if ( pToolbar )
delete pToolbar;
if ( pToolbarHandler )
delete pToolbarHandler;
}
 楼主| 发表于 2004-8-3 12:49:00 | 显示全部楼层
再试一次
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:52 , Processed in 0.137016 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表