Hello,
my problem is that when I enter a panel of a resizable frame the
cursor sometimes does not show the default arrow state, but the state
it has while hovering over the frame border. If I run into this
situation depends strongly on the speed I use to enter my panel.
My code:
import wx
import win32com.client.gencache
class ViewerPanel(wx.Panel):
def __init__(self, *args, **kwargs):
super(ViewerPanel, self).__init__(*args, **kwargs)
self.viewer = None
sizer = wx.BoxSizer(wx.VERTICAL)
control =
win32com.client.gencache.EnsureModule('{DD3BD3FD-8B58-406F-
AA17-714C852F07AD}', 0x0, 1, 0)
ActiveXWrapper = MakeActiveXClass(control.CADdyViewer)
self.SetWindowStyle(wx.WANTS_CHARS)
sizer.Add(self.viewer, 1, wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
wx.EVT_WINDOW_DESTROY(self, self.OnDestroy)
self.Bind(wx.EVT_IDLE, self.OnIdle)
def OnDestroy(self, evt):
if self.viewer:
self.viewer.Cleanup()
self.viewer = None
evt.Skip()
def OnIdle(self, event):
if self.viewer:
self.viewer.OnIdle()
event.Skip()
def main():
app = wx.App(False)
frm = wx.Frame(None, title="ViewerPanel test window")
panel = ViewerPanel(frm)
panel.viewer.Load(r'dinopet.3ds', False, True)
panel.viewer.SetHeadLightState(True)
frm.Show()
app.MainLoop()
if __name__ == '__main__':
main()
As you can see my panel is actually an acitveX wrapped window, which I
have written myself. Basically it is defined by
class CCADdyViewerCtrl : public COleControl
{
DECLARE_DYNCREATE(CCADdyViewerCtrl)
// Constructor
public:
CCADdyViewerCtrl();
// Overrides
public:
virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect&
rcInvalid);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void DoPropExchange(CPropExchange* pPX);
virtual void OnResetState();
virtual DWORD GetControlFlags();
// Implementation
protected:
~CCADdyViewerCtrl();
DECLARE_OLECREATE_EX(CCADdyViewerCtrl) // Class factory and
guid
DECLARE_OLETYPELIB(CCADdyViewerCtrl) // GetTypeInfo
DECLARE_PROPPAGEIDS(CCADdyViewerCtrl) // Property page IDs
DECLARE_OLECTLTYPE(CCADdyViewerCtrl) // Type name and misc
status
//{{AFX_MSG(CCADdyViewerCtrl)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
//{{AFX_DISPATCH(CCADdyViewerCtrl)
afx_msg BOOL Load (LPCTSTR name,
BOOL load_into_current, BOOL deactivate_light);
afx_msg void SetHeadLightState (BOOL flag);
...
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
DECLARE_EVENT_MAP()
private:
// details...
};
with these implementation details
static const DWORD BASED_CODE _dwCADdyViewerOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_IGNOREACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(CCADdyViewerCtrl, IDS_CADDYVIEWER,
_dwCADdyViewerOleMisc)
BOOL CCADdyViewerCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
// these styles are required by OpenGL
cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
if (cs.dwExStyle & WS_EX_NOPARENTNOTIFY)
cs.dwExStyle -= WS_EX_NOPARENTNOTIFY;
// these styles are meant for a use of this class in a MDI
application
cs.lpszClass = AfxRegisterWndClass(CS_OWNDC | CS_HREDRAW |
CS_VREDRAW);
return COleControl::PreCreateWindow(cs);
}
int CCADdyViewerCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
lpCreateStruct->style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
Does anyone has an idea what could be the reason for the failing
cursor update in this scenario? I have tried to goole some information
but could not find anything valuable.
How is the cursor switching handled at all when entering a window?
Should I assume the problem in the wx related code or in my MFC code?
Everything else in my activeX control panel is perfectly working. The
control wrappes an OpenGL viewer, but I have tried to abandon all that
code with the very same result with respect to the cursor.
A last comment, I'm working with wxPython 2.9.1.1 on Python 2.7.1.
Any help is appreciated.
Best,
Johannes