CSofAndy 发表于 2018-7-18 10:42:49

创建可停靠窗体问题

Win7 64位系统,64位 CAD 2012,程序编译通过,运行时SetWindowText报错,如下图:

CSofAndy 发表于 2018-7-18 10:47:31

docBar是创建成功的。

xinxirong 发表于 2018-7-18 18:05:58

应该要show一下,等对话框调用了oninitialdlg才能setwindowtext

edata 发表于 2018-7-18 18:49:52

给你参考一下。。
CAcModuleResourceOverride resOverride;
if (g_pDlgBar == NULL){
g_pDlgBar = new CMyDockControlBar();
g_pDlgBar->Create(acedGetAcadFrame(), _T("DockBar"));
g_pDlgBar->SetWindowText(_T("MyControlBar"));
g_pDlgBar->EnableDocking(CBRS_ALIGN_ANY);
}
acedGetAcadFrame()->FloatControlBar(g_pDlgBar, CPoint(100, 100),CBRS_ALIGN_TOP);// 初始位置
acedGetAcadFrame()->ShowControlBar(g_pDlgBar, TRUE, TRUE);

CSofAndy 发表于 2018-7-19 18:23:21

我改用VS2008写的代码运行不报错,但是VS2010还是报这个错,VS2008、VS2010应该都可以啊,不知道怎么回事。

CSofAndy 发表于 2018-7-19 18:24:56

VS2010我也重装了,还是不行,难道我vs2010安装包有问题?

gzxl 发表于 2018-7-19 18:52:46

CSofAndy 发表于 2018-7-19 18:24
VS2010我也重装了,还是不行,难道我vs2010安装包有问题?

应该不是,最好将你的MyDockControlBar代码让大家看看。

CSofAndy 发表于 2018-7-20 09:16:42

在VS2010工程里,编译的时候选择2008的编译器(V90)可以,选择2010的编译器(V100)就不行。

CSofAndy 发表于 2018-7-20 09:20:36

//-----------------------------------------------------------------------------
//----- dockBar.h : Declaration of the dockBar
//-----------------------------------------------------------------------------
#pragma once

//-----------------------------------------------------------------------------
#include "acui.h"

//-----------------------------------------------------------------------------
class dockBar : public CAcUiDockControlBar {
        DECLARE_DYNAMIC (dockBar)

public:

public:
        dockBar ();
        virtual ~dockBar ();

        virtual BOOL Create (CWnd *pParent, LPCSTR lpszTitle) ;
        protected:
        virtual void SizeChanged (CRect *lpRect, BOOL bFloating, int flags) ;

        afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct) ;

        DECLARE_MESSAGE_MAP()
} ;


//-----------------------------------------------------------------------------
//----- dockBar.cpp : Implementation of dockBar
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include "dockBar.h"

//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC (dockBar, CAcUiDockControlBar)

BEGIN_MESSAGE_MAP(dockBar, CAcUiDockControlBar)
        ON_WM_CREATE()
END_MESSAGE_MAP()

//-----------------------------------------------------------------------------
//----- dockBar *pInstance = new dockBar;
//----- pInstance->Create (acedGetAcadFrame (), "My title bar") ;
//----- pInstance->EnableDocking (CBRS_ALIGN_ANY) ;
//----- pInstance->RestoreControlBar () ;

//-----------------------------------------------------------------------------
static CLSID clsdockBar = {0xeab78c04, 0x2194, 0x47ad, {0xa4, 0xf2, 0xad, 0xca, 0x3e, 0x3b, 0xb6, 0x3c}} ;


//-----------------------------------------------------------------------------
dockBar::dockBar () : CAcUiDockControlBar() {
}

//-----------------------------------------------------------------------------
dockBar::~dockBar () {
}

//-----------------------------------------------------------------------------
#ifdef _DEBUG
//- Please uncomment the 2 following lines to avoid linker error when compiling
//- in release mode. But make sure to uncomment these lines only once per project
//- if you derive multiple times from CAdUiDockControlBar/CAcUiDockControlBar
//- classes.

//void CAdUiDockControlBar::AssertValid () const {
//}
#endif

//-----------------------------------------------------------------------------
BOOL dockBar::Create(CWnd *pParent, LPCSTR lpszTitle) {
        CString strWndClass ;
        strWndClass =AfxRegisterWndClass (CS_DBLCLKS, LoadCursor (NULL, IDC_ARROW)) ;
        CRect rect (0, 0, 250, 200) ;
        if (!CAcUiDockControlBar::Create(
                        strWndClass,(LPCTSTR)lpszTitle, WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
                        rect, pParent, 0
                )
        )
       
                return (FALSE) ;

        SetToolID (&clsdockBar) ;

        // TODO: Add your code here
       
        return (TRUE) ;
}

//-----------------------------------------------------------------------------
//----- This member function is called when an application requests the window be
//----- created by calling the Create or CreateEx member function
int dockBar::OnCreate (LPCREATESTRUCT lpCreateStruct) {
        if ( CAcUiDockControlBar::OnCreate (lpCreateStruct) == -1 )
                return (-1) ;

        return (0) ;
}

//-----------------------------------------------------------------------------
void dockBar::SizeChanged (CRect *lpRect, BOOL bFloating, int flags) {
}


//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("Andy")
dockBar* dockBar1 = NULL;   
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CArxProject11App : public AcRxArxApp {

public:
        CArxProject11App () : AcRxArxApp () {}

        virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
                // TODO: Load dependencies here

                // You *must* call On_kInitAppMsg here
                AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
               
                // TODO: Add your initialization code here

                // Redirect the resource override   
                CAcModuleResourceOverride res;   

                // Check to see if the dock bar is not already up   
                if (dockBar1 == NULL)   
                {   
                        // Create the dock ctrl bar   
                        dockBar1 = new dockBar;   
                        // Now display it   
                        dockBar1->Create(acedGetAcadFrame(),"DockControlBar");   
                        dockBar1->EnableDocking(CBRS_ALIGN_ANY);   
                        dockBar1->SetWindowText(LPCTSTR("Dock Tool"));   
                }   
                if (dockBar1)   
                {   
                        acedGetAcadFrame()->FloatControlBar(dockBar1, CPoint(750, 150), CBRS_ALIGN_RIGHT);    // FloatControBar(...)   
                        //acedGetAcadFrame()->DockControlBar(dockBar, AFX_IDW_DOCKBAR_RIGHT, NULL);          // DockControlBar(...)   
                        acedGetAcadFrame()->ShowControlBar(dockBar1, TRUE, FALSE);   
                }

                return (retCode) ;
        }

        virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
                // TODO: Add your code here

                // You *must* call On_kUnloadAppMsg here
                AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

                // TODO: Unload dependencies here

                return (retCode) ;
        }

        virtual void RegisterServerComponents () {
        }

} ;

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CArxProject11App)

CSofAndy 发表于 2018-7-20 09:22:27

dockBar是通过向导建的。
页: [1] 2
查看完整版本: 创建可停靠窗体问题