Solved

Transparent OCX controls

Posted on 1997-10-03
6
868 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
string initialization in java 11 122
Trying to run powershell  in a batch file. How do I do this? 8 124
Problem to App 4 145
c++  placing data into a form and an editbox 5 50
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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

751 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