找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 542|回复: 2

[求助]:ObjectARX中为何不能向ComboBox控件加字符串?

[复制链接]
发表于 2004-1-28 22:49:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我编写的基于MFC的ObjectARX程序中,不能够像一般的MFC程序一样用AddString和
InsertString向ComboBox种添加字符串,请高手指教。

IMPLEMENT_DYNAMIC(CComboDlg, CDialog)
CComboDlg::CComboDlg(CWnd* pParent /*=NULL*/)
        : CDialog(CComboDlg::IDD, pParent)
        , m_ComboDlg(0)
{
}

CComboDlg::~CComboDlg()
{
}

void CComboDlg::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);
        DDX_Control(pDX, IDC_COMBO1, m_ComboBox);
}


BEGIN_MESSAGE_MAP(CComboDlg, CDialog)
END_MESSAGE_MAP()


// CComboDlg 消息处理程序

BOOL CComboDlg::OnInitDialog()
{
        CDialog::OnInitDialog();

    m_ComboBox.AddString("123");
    m_ComboBox.AddString("456");
    m_ComboBox.AddString("789");
       
        return TRUE;  // return TRUE  unless you set the focus to a control
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-1-29 19:37:50 | 显示全部楼层
多半你将其设置为自绘制的了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-2-1 12:12:10 | 显示全部楼层
这个问题已经解决,发出来与大家共享!
1。在AutoDesk的网上是这样讨论的:
Posted by: Rizzo, Jon
Date: Sep/09/02 - 09:46 (GMT)   
I am having a problem with an owner drawn combo box.

In my OnInitDialog(), I am adding code to an instance of my combo box class.
When I call AddString(), the function executes, but it appears to store a
garbage string, instead of the string that is passed.. The same garbage
string can be retrieved using GetLBText(), so the problem appears to be in
storing the string, rather than displaying it.

What I am trying to do is not complicated, and I tested the code outside of
AutoCAD (in a dialog based application) & did not have the same problem. I
added a CAcModuleResourceOverride object to the command that calls this
dialog, but that did not help.

Any ideas what could be causing this problem, or how to fix it?

Thanks in advance,

Jon Rizzo
Langan Engineering and Environmental Services, Inc.
-----------------------------------------------------------------------------------
Reply From: Blattel, Byron
Date: Sep/09/02 - 09:53 (GMT)
   
    Re: Problem with owner drawn combo box
If you are creating it via CComboBox::Create() don't forget to use
CBS_HASSTRINGS...

|
----+---------------------------------------------- ------------------------------------------------

实际上的做法是要确保你的对话框中ComboBox控件设置
CBS_OwnerDraw 选“否“,CBS_HasString选“false".

2。经过本人认真研究ObjectARX的例题,在VStudio.net中用
Wizard后,加入的ComboBox的默认高度是12,这个值太小了,
在OnInitDialog后根本显不出来,修改如下。

打开*.rc文件,找到如下代码
COMBOBOX        IDC_COMBO1,48,12,27,12,CBS_DROPDOWN |     WS_VSCROLL |  WS_TABSTOP
将其中的后一个 12 改写为大一些的值,100就行!这四个数分
别代表了起点的x坐标,y坐标,长度和高度。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 11:03 , Processed in 0.304185 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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