Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am developing an ActiveX Control for a MFC app.

In this app I have a controle class:

class MyControl : public COleControl

and a CWnd class:

class MyCWnd : public CWnd

As well as other classes for the active x and an idl file...

Within the MyControl class I want to open the window MyCWnd as an MFC appartment (a thread where the window runs).

To do so I have an attribute theWnd in MyControl defined as:

MyCWnd theWnd

in a method withing MyControl I want to create the window by calling:

theWnd.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), NULL, AFX_IDW_PANE_FIRST, NULL);

but this line returns false.

How should I initialize then create (start) a CWnd within a COleControl class? If it is not possible is there another class I can inherit from than COleControl for an ActiveX controle?

question from:https://stackoverflow.com/questions/65941779/cant-call-cwndcreate-from-colecontrol-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
610 views
Welcome To Ask or Share your Answers For Others

1 Answer

So I found a solution that seems to me like a hack:

theWnd.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), GetDesktopWindow(), AFX_IDW_PANE_FIRST, NULL)

The parent window is then the desktop. I don't know if it is a clean way to do it...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...