xinxirong 发表于 2014-9-12 16:04:00

objectarx 2013 WM_ACAD_KEEPFOCUS无效

vs2010,其它的消息映射可以正确映射,调试的时候也能正确中断在函数开头。
这里Myedit.cpp文件
// MyCEdit
IMPLEMENT_DYNAMIC(MyCEdit, CEdit)
MyCEdit::MyCEdit()
{
}
MyCEdit::~MyCEdit()
{
}
BEGIN_MESSAGE_MAP(MyCEdit, CEdit)
      ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
      ON_CONTROL_REFLECT(EN_CHANGE, OnEnChange)
END_MESSAGE_MAP()
void MyCEdit::OnEnChange()
{
      CString str;
      int len;
      GetWindowText(str);
      //len=str.GetLength();
      //len=GetStringLength(str);
      //this->SetWindowPos(NULL,0,0,13*len,20,SWP_NOMOVE);//这句
      CDC* pDC = this->GetDC();
    CSize size = pDC->GetTextExtent(str);
    this->ReleaseDC(pDC);
    CRect rc;
    this->GetWindowRect(&rc);
    ScreenToClient(&rc);
    //rc.right = rc.left + size.cx;
    this->SetWindowPos(NULL,0,0,size.cx+50,20,SWP_NOMOVE);//这句
}
这里MyEdit.h文件
#include "StdAfx.h"
// MyCEdit
class MyCEdit : public CEdit
{
      DECLARE_DYNAMIC(MyCEdit)
public:
      MyCEdit();
      virtual ~MyCEdit();
      LRESULT onAcadKeepFocus(WPARAM wPara,LPARAM lPara)      //(UINT, LONG)
      {
                return TRUE;//在这里按F9设置断点,不能正确中断
      }
      
      int GetStringLength(CString& strTest)
      {
                int iLength = 0;
                for( int i = 0; i255 )
                        {// 汉字
                              iLength += 2;
                        }
                        else
                        {// 非汉字
                              iLength += 1;
                        }
                }
                return iLength;
      }
protected:
      DECLARE_MESSAGE_MAP()
public:
      afx_msg void OnEnChange();
};
有人说WM_ACAD_KEEPFOCUS应该定义为0x1001,但系统是这样定义的:
#define WM_ACAD_KEEPFOCUS (0x0400+0x6D01)
即0x7101才对

xinxirong 发表于 2014-9-12 16:08:00

同样的代码在cad2008里可以正常用

urings 发表于 2020-3-2 13:56:00


请问最后是怎么解决的?
页: [1]
查看完整版本: objectarx 2013 WM_ACAD_KEEPFOCUS无效