|
-
September 1st, 1999, 08:17 AM
#1
Invisible ActiveX
I created an ActiveX in VC++6. After loading it in the test-container I saw nothing. The ActiveX was invisible. It appeared as a rectangle with a ellipse inside. What did I forget?
Thanks and regards
Sascha
-
September 1st, 1999, 08:36 AM
#2
Re: Invisible ActiveX
I guess rectangle & ellipse are drawn in your OnDraw-method. Look for
the code there.
What you should do is handle the CREATE-message (use ClassWizard for it, then
make a method OnCreate that handles the message).
Place your own drawing code there, not in OnDraw.
If this doesn't solve it, ask again.
regards,
PUH
-
September 1st, 1999, 08:54 AM
#3
Re: Invisible ActiveX
Yes, the ellipse was created in the OnDraw function, but what code should I write in OnCreate function? I only wanted the existing dialog box visible (IDD_PROPPAGE). My ActiveX is only dialog based (two buttons), so I want it visible!
Thanks and regards
Sascha
-
September 1st, 1999, 08:54 AM
#4
Re: Invisible ActiveX
I forgot:
You also have to handle the ON_SIZE message, e.g. like this:
void MyCtrl::OnSize(UINT nType, int cx, int cy)
{
COleControl::OnSize(nType, cx, cy);
if(pView->GetSafeHwnd())
pView->MoveWindow(0, 0, cx, cy);
}
If you don't have a view, then just:
void MyCtrl::OnSize(UINT nType, int cx, int cy)
{
COleControl::OnSize(nType, cx, cy);
if(GetSafeHwnd())
MoveWindow(0, 0, cx, cy);
}
-
September 1st, 1999, 09:08 AM
#5
Re: Invisible ActiveX
I display another control in my Active X control, and first I
did it in OnDraw, which didn't work. Now I have the code in OnCreate, and all
is well. But I use a class which inherits fron CView, not a dialog.
Can't see what is wrong. Maybe if you give us the code ?
-
September 1st, 1999, 09:50 AM
#6
Re: Invisible ActiveX
I'm sorry,
there is no code which I could give you.
If you create an ActiveX in VC++6 there is already a dialog included in the resources. There I put two buttons inside and give them some action after you click on it. So I thought it would be enough and I compiled the whole thing and run it but the dialog didn't appear.
So I only want to know to get the dialog visible!
Thanks and regards
Sascha
-
September 1st, 1999, 10:14 AM
#7
Re: Invisible ActiveX
Oh, Sorry!
I guess now I know what you mean:
1. include the PropPage - header:
#include "MyAppPpg.h" // Or whatever the headername is
2. where you want to draw the dialog, add:
CMyAppPropPage prop;
prop.DoModal();
Your dialog needs an OK_Button or you can't come back and your app will hang.
Was that the point ?
-
September 1st, 1999, 11:19 AM
#8
Re: Invisible ActiveX
Yes, I think that is the point, but I didn't really get where to put
//CMyAppPropPage prop;
//prop.DoModal();
Thanks and regards
Sascha
-
September 2nd, 1999, 02:42 AM
#9
Re: Invisible ActiveX
I advise you to do as posted before:
Add an OnCreate function by using ClassWizard, selecting "Message Maps",
your ...Ctrl class (not the ...App class), and scroll down under "Messages"
to find the message WM_CREATE. Choose "Add Function"-button, and place
the code there. I tried it, it worked for me.
LMK if this helped.
regards,
PUH
-
September 2nd, 1999, 03:19 AM
#10
Re: Invisible ActiveX
Hi PUH,
thanks, now it works! Excellent!
But how do I know that I have to do so?
Best regards
Sascha
-
September 2nd, 1999, 03:57 AM
#11
Re: Invisible ActiveX
Great! I just did not understand the problem at first.
1. Why use DoModal() etc ?
-> because your Prop-dialog ist represented as a class.
You have to instantiate the class to get an object (like you cannot say
"int = 0, but int i = 0.")
DoModal() is a method that does all the rest for you: brings up the dialog
defined in the Propclass, etc. Every dialog has to be created like this.
(except for non-modal ones.)
2. Why OnCreate and not OnDraw ?
I don't know, ask the gurus. I guess OnDraw is a lowlevel Win-method. You can use
it to draw a simle line or ellipse, but if you create another windows-object
like a dialog or another control, you mess everything up, because only after
OnDraw is done, everything has been properly created.
I *think* that OnDraw is always called if *anything* changes, like if you move
antoher window over your control and back again, OnDraw is used to
redraw what's inside. But your dialog redraws itself automatically,
so you mix things up there.
But as I said, it's pure guesswork, since I'm not an expert.
Anyway, hope works now !
:-)
best regards,
PUH
-
September 2nd, 1999, 04:52 AM
#12
Re: Invisible ActiveX
Thanks for the information!
I would rate you with excellent but it is not possible because you're wirting anonymous!
Regards and untill next time!
Sascha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|