Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Transparent OCX controls

Posted on 1997-10-03
6
Medium Priority
?
884 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

876 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