CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2005
    Posts
    12

    Make OCX control transparent?

    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?

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Make OCX control transparent?

    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?
    Gort...Klaatu, Barada Nikto!

  3. #3
    Join Date
    Aug 2005
    Posts
    12

    Re: Make OCX 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.

  4. #4
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Make OCX control transparent?

    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.?)
    Gort...Klaatu, Barada Nikto!

  5. #5
    Join Date
    Aug 2005
    Posts
    12

    Re: Make OCX control transparent?

    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.
    Last edited by ted_b; November 16th, 2005 at 04:45 PM.

  6. #6
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Make OCX control transparent?

    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?
    Gort...Klaatu, Barada Nikto!

  7. #7
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Make OCX control transparent?

    Quote Originally Posted by ted_b
    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?
    So, do you want to make the OCX in VB and not in VC++?
    Last edited by Siddhartha; November 16th, 2005 at 04:58 PM.

  8. #8
    Join Date
    Aug 2005
    Posts
    12

    Re: Make OCX control transparent?

    No. I'm making OCX using MFC & ATL to be used in VB.

  9. #9
    Join Date
    May 2002
    Location
    Phoenix, AZ
    Posts
    95

    Re: Make OCX control transparent?

    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.

  10. #10
    Join Date
    May 2002
    Location
    Phoenix, AZ
    Posts
    95

    Re: Make OCX control transparent?

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured