Solved

Transparent OCX controls

Posted on 1997-10-03
6
864 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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