Solved

Transparent OCX controls

Posted on 1997-10-03
6
860 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
move a line in eclipse 3 103
countEvens challenge 2 100
Execute multiple curl cmds with sleep and send output to file 10 97
Way to decrease size of apk file 9 69
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 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