OLE控件z-order在Excel 2010中不稳定 [英] OLE control z-order unstable in Excel 2010

查看:88
本文介绍了OLE控件z-order在Excel 2010中不稳定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel 2010工作表中嵌入了多个实例的堆栈顺序时遇到问题。在打印预览中呈现控件的顺序与常规视图中的顺序不同。

I have a problem with the stacking order of a particular OLE control when several instances of it are embedded in an Excel 2010 sheet. The order in which the controls are rendered in the print preview is different from the order in the regular view.

OLE控件是在Visual Studio 2008中使用MFC开发的。控件使用以下内容代码将自己移到z订单的前面:

The OLE control is developed with MFC in Visual Studio 2008. The control uses the following code to move itself to the front of the z-order:

    IOleContainerPtr pIContainer;

    m_pClientSite-> GetContainer(& pIContainer);

    Excel :: _ WorkbookPtr wb = pIContainer;

    Excel :: _ WorksheetPtr工作表= wb-> ActiveSheet;

    Excel :: ShapesPtr oleobjects = worksheet->形状;

    Excel :: ShapePtr ob = oleobjects-> Item(LPCTSTR(m_Name));  // m_Name包含正确的名称

    ob-> ZOrder(Office :: msoBringToFront);

    IOleContainerPtr pIContainer;
    m_pClientSite->GetContainer(&pIContainer);
    Excel::_WorkbookPtr wb = pIContainer;
    Excel::_WorksheetPtr worksheet = wb->ActiveSheet;
    Excel::ShapesPtr oleobjects = worksheet->Shapes;
    Excel::ShapePtr ob = oleobjects->Item(LPCTSTR(m_Name));  // m_Name contains the correct name
    ob->ZOrder(Office::msoBringToFront);

收到WM_LBUTTONDOWN时调用此方法。在常规工作表视图中,这显示没有效果,即,如果控件在另一个控件后面,则它保持在该位置。但是它确实正确地改变了打印预览中的堆叠顺序,并且
ZOrderPosition也被更改以指示控件现在位于顶部。

This is called when a WM_LBUTTONDOWN is received. In the regular sheet view, this shows no effect, i.e., if the control is behind another one, it remains at that position. It does however change the stacking order in the print preview correctly, and the ZOrderPosition is changed as well to indicate that the control is now on top.

我也尝试过

    Excel :: OLEObjectsPtr oleobjects = worksheet-> OLEObjects();

    Excel :: _ OLEObjectPtr ob = oleobjects->项目(LPCTSTR(m_Name));

    ob-> BringToFront();
$


但它没有什么区别。

    Excel::OLEObjectsPtr oleobjects = worksheet->OLEObjects();
    Excel::_OLEObjectPtr ob = oleobjects->Item(LPCTSTR(m_Name));
    ob->BringToFront();

but it does not make a difference.

还有一件事很奇怪:当我加载一个带有4个控件实例的文件时,再次保存它而不尝试更改堆叠顺序,然后在下次加载时,控件在常规视图中以相反的顺序显示(print
预览保持不变且正确。)

One more thing is very strange: When I load a file with, say, 4 instances of the controls, save it again without trying to change the stacking order, then upon the next load, the controls appear exactly in the reverse order in the regular view (the print preview remains unchanged and correct).

我将文件保存为.xlsx,这是Office 2010"Home and Student"。

I am saving the file as .xlsx, and this is Office 2010 "Home and Student".

如何强制OLE控件位于堆栈的顶部?保存和加载后如何避免订单被撤消?

How do I force an OLE control to be at the top of the stack? How do I avoid that the order is reversed after save and load?

推荐答案

Hello Hannes-0815,

请回答几个问题。

1。       
这是否会在所有机器上发生?

1.       Does this happen on all machines?

2。       
您看到此问题的机器是多功能的处理器系统?

2.       Is the machine where you see this problem a multi-processor system?

3. 您使用的是什么版本和Widows版本?

3.       What version and build of Widows are you using?

4。       
如果您在Excel 2007上测试或Excel 2003?

4.       Does this happen if you test on Excel 2007 or Excel 2003?

5.        ;
您是否更改了控件的任何特性在运行时,例如更改了属性的值?

5.       Have you changed any of the characteristics of the control at run-time, e.g. changed the value of a property?

6.      ;  
堆叠控件是否为同一控件或除了m_Name之外总是相同 -

6.       Are the stacked controls variations of the same control or always identical to one-another except for m_Name?

7.        
它们如何堆叠?每次会话总是相同的4个控件?

7.       How do they get stacked? Always the same 4 controls at every session?

8.      ;   
控件是否覆盖工作表上的相同空间?这个模糊不清吗?

8.       Do the controls cover the same space on the worksheet? Do the obscure one-another?

9.       ;  
您对样本控件或某些操作的行为是否相同?使用测试控件的四个实例时的其他测试控件?

9.       Do you same behavior with a sample control or some other test control when you use four instances of the test control?

10.   ; 
您能提供重现内容的步骤列表吗?您是否看到其他论坛用户可以获得相同的体验并可能给您一个答案?

10.   Can you provide a list of steps to reproduce what you see so other Forum users can get the same experience and perhaps give you an answer?

感谢您的耐心和考虑。

Chris Jensen

高级技术支持主管


这篇关于OLE控件z-order在Excel 2010中不稳定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆