|
本帖最后由 土豆囝囝 于 2013-10-12 17:24 编辑
问题其实不复杂:
我做了一个ActiveX的osgearth,加了一个可点击的LabelControl,然后继承了一个ControlEventHandler类并重载其 OnClick() 函数来弹出一个模态对话框(自己做的对话框),但是 DoModal() 没有弹出对话框。
Tips1:测试时在ActiveX的 OnDraw() 函数里弹出该对话框是正常的 !
Tips2:构造对话框类也应该没问题,我之前试过new对话框,指针非0 !
下面是代码:
////AddViewpointEventHandler.h
class AddViewpointEventHandler : public osgEarth::Util::Controls::ControlEventHandler
{
private:
ViewpointVBox* m_pViewpointVBox;
osgEarth::Util::EarthManipulator* m_pManipulator;
HWND m_hwnd;
public:
AddViewpointEventHandler(HWND hwnd, ViewpointVBox* pViewpointVBox, osgEarth::Util::EarthManipulator* pManipulator);
~AddViewpointEventHandler();
virtual void onClick( class osgEarth::Util::Controls::Control* control );
};
////AddViewpointEventHandler.cpp
AddViewpointEventHandler::AddViewpointEventHandler(HWND hwnd, ViewpointVBox* pViewpointVBox, osgEarth::Util::EarthManipulator* pManipulator) :
m_hwnd(hwnd),
m_pViewpointVBox(pViewpointVBox),
m_pManipulator(pManipulator)
{}
AddViewpointEventHandler::~AddViewpointEventHandler()
{}
void AddViewpointEventHandler:: onClick( class osgEarth::Util::Controls::Control* control )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); //高人指点加入的,但暂无效果
::MessageBox(NULL, "domodal", "Debugging", 1); //可以进入
ViewpointNameDlg NameDlg((CWnd*)m_hwnd);
//!!!!下面这句无法弹出窗口!!!!
NameDlg.DoModal();
if (NameDlg.m_sName != "")
{
::MessageBox(NULL, "开始添加Viewpoint", "Debugging", 1); //没有进入
m_pViewpointVBox->addViewpoint(NameDlg.m_sName.GetString(), new osgEarth::Util::Viewpoint(m_pManipulator->getViewpoint()));
}
::MessageBox(NULL, "完成添加viewpoint", "Debugging", 1); //可以进入
} |
|