Hi everyone:
I'm making OCX control using ATL & MFC. I'm new to all this, so maybe the answer is really simple. Does anybody know how to make ActiveX control transparent?
Printable View
Hi everyone:
I'm making OCX control using ATL & MFC. I'm new to all this, so maybe the answer is really simple. Does anybody know how to make ActiveX control transparent?
What do you mean? Are you talking about rendering it as transparent? Or, windowless? Can you provide a little more detail?Quote:
Does anybody know how to make ActiveX control transparent?
Thank you for reply. As I said I've never programmed ActiveX before, although I have an extensive experience in C++/MFC.
Yes, I guess, it should be rendered as transparent. I do not completely understand how it could be windowless though, as I still need to display (attach) it to the form.
Ok, so, you've got an ActiveX control you want to use on a form. What is its purpose? (ie. display a chart, bitmap, etc.?)
Yes, I'm trying to make an ActiveX control. It is some sort of a simple JavaScript obfuscator that takes JavaScript and outputs scrambled code. As I come to think about it now, maybe windowless OCX will work too. My initial idea was to have program's logo displayed in its Window, along with the Help and About buttons. The problem I encountered is that I cannot make background of the ActiveX window box transparent, which will let this control to blend into the form.
I'm not really strong in VB. I don't know the way how my client will use this control as maybe there is a way to set up background color/rendering of an ActiveX in Visual Basic, so that maybe I don't even have to worry about it?
Thanks for your response.
In any ActiveX control, you are responsible for rendering (ie. painting) the appearance of the control. This typically happens in OnDraw(). Rendering a transparent background should not be an issue. However, without knowing the specifics of what you will be rendering, it's hard to guess at what your problems are. Can you post a bitmap that shows the control on a form?
So, do you want to make the OCX in VB and not in VC++?Quote:
Originally Posted by ted_b
No. I'm making OCX using MFC & ATL to be used in VB.
Not sure if your control is a windowless control or not.
Also not sure for what OS you are developing.
If it is for Win2k+, try the UpdateLayeredWindow method
and also look at dilascia's article
http://msdn.microsoft.com/msdnmag/is...k/default.aspx
This will make the entire window transparent.
If however you want only your windowless control to be transparent, (showing the parent window in the background) you will need to use GDI+ (Which is available from WinXP+)
In this case you will need to create a GDI+ graphics object based on your DC, and then draw using a brush / lineargradientbrush, setting the appropriate alpha blends. You can look this up in MSDN, there are several examples on how to go about doing this.
P.S. If you need to support Win NT / 9X / ME as well, your in a world of trouble!!! :)
All the best, and be sure to publish it if you get it working on those platforms! :thumb: