|
本帖最后由 ghjnwk@163.com 于 2018-6-15 16:42 编辑
我现在在开发一个功能,是将“产品代号”与“模型”关联,通过选中“产品代号”,点击响应按钮,可以打开保存的“模型”。问题是,当我从“当前模型”切换到别的“模型”时,效果不是覆盖,而是打开一个新的窗口,让我很困扰,没有找到好的办法。下面是代码。
- // 这行代码初始化路径,在我的项目里边,是从数据库中读取
- CString path = _T("D:\\vs2015_project\\Proe_Develop\\creo4\\prt0005.prt.9");
- // 这几行代码对字符的格式进行转换 从char*转到wchar_t*
- std::string string_path = CT2A(path.GetBuffer());
- char* pCStrKey = (char*)(string_path).c_str();
- int pSize = MultiByteToWideChar(CP_UTF8, 0, pCStrKey, strlen(pCStrKey) + 1, NULL, 0);
- wchar_t *pWCStrKey = new wchar_t[pSize];
- MultiByteToWideChar(CP_UTF8, 0, pCStrKey, strlen(pCStrKey) + 1, pWCStrKey, pSize);
- ProMdl model;
- ProMdlFiletypeLoad(pWCStrKey, PRO_MDLFILE_PART, PRO_B_FALSE, &model); // 将模型加载到内存中
- delete[] pWCStrKey; // 管理内存
- ProObjectwindowMdlnameCreate(L"prt0005", PRO_PART, NULL); // 创建一个窗口
- ProObjectwindowMdlnameCreate(L"prt0005", PRO_PART, &window_id); // 获取window id
- ProMdlDisplay(model); // 显示模型
- ProWindowCurrentSet(window_id); // 将模型设为当前窗口
- ProWindowActivate(window_id); // 激活窗口(不激活的化按钮是灰色的)
复制代码
希望达到的效果是“覆盖”原来窗口,而不是“新建”一个窗口
求大佬解答
|
|