Solved

Transparent OCX controls

Posted on 1997-10-03
6
854 Views
Last Modified: 2013-11-19
I want to create a transparent OCX control - one that can be  visible or not visible and I am having trouble getting the background repainted when the transparency property is on, I need the control to respond to button clicks at all times and to display caption text but to be transparent sometimes... Any ideas?
0
Comment
Question by:jeffw100397
6 Comments
 

Author Comment

by:jeffw100397
ID: 1307452
Edited text of question
0
 
LVL 7

Expert Comment

by:faster
ID: 1307453
How did you implement the transparency property?  You must have a function to be called whenever it is set, and inside the function to repaint it.  If you have problem, you can show this part of the code.
0
 

Author Comment

by:jeffw100397
ID: 1307454
In VBXs a property value of "grapics" enabled the background to be shown within the control where no painting occurred, this is not available in OCXs.  I have tried non rectangular windows but I need to be able to hide the painted region and still have it respond to mouse clicks hence have it transparent.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 8

Expert Comment

by:gelbert
ID: 1307455
In OnDraw()
void OcxCtrl::OnDraw(CDC* pDC, const CRect& rcBounds, const CRect& rcInvalid)
{
   int nOldBkMode = pDC->SetBkMode(TRANSPARENT);

// Your Drawing Routine.

// not used OffScreen or CompatableDC

// must be Direct Draw in pDC

    pDC->SetBkMode(nOldBkMode);
}

if your Ocx control move in run time, you must call
InvalidateControl(rcClientRect);
MoveWindow(nX, nY, nWid, nHt, TRUE);

0
 

Author Comment

by:jeffw100397
ID: 1307456
SetBkMode relates to the background of pens when painting text, I need to paint an arbitrary shape in and OCX container but show through the background of the window that the OCX is overlaying!  ie. a coloured shape is painted by the OCX over a containing window that has a bitmap (say of a map). The application will display the coloured shape to highlight a region of the map in alarm. The coloured region must be able to be made invisible (ie. transarent) but the OCX must continue to respond to mouse clicks while transparent!!
0
 
LVL 3

Accepted Solution

by:
jaba earned 100 total points
ID: 1307457
To avoid eraising beckground you should dispatch message WM_ERASIBACKGROUND and dont call base cass method ( dont do anything). But best way to make OCX transparent is add to your vcontrol code somthing like this:

BOOL CDealAvCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
    cs.style -= WS_CLIPSIBLINGS;
    return COleControl::PreCreateWindow(cs);
}

and
DWORD CDealAvCtrl::GetControlFlags()
{
      DWORD dwFlags = COleControl::GetControlFlags();
      dwFlags |= windowlessActivate;
      return dwFlags;
}


0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 64
repeatSeparator  java  challenge 13 56
sum28 challenge 31 96
noX challenge 17 77
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now