ActiveX Programming Unleashed 2nd Edition - Ebook download as PDF File (.pdf), Text file (.txt) or read book online. Hand-picked favorites from our editors. What kind of errors are you getting when you paste the EVENT MAP Stuff?? I think you might have missed DECLARE_EVENTSINK_MAP() in.H file which might be causing the. > Can anyone point me to an ABC of using an ActiveX control using VC++/MFC. Programming with ATL is somewhat more difficult than programming with MFC, but the resulting ActiveX controls are usually faster, smaller, and can eliminate dependencies on corpulent DLLs..
Transparent ATL Controls. Introduction. Implementing transparent Active. X controls seems to be one of those programming tasks that is rapidly approaching FAQ status. The ability to display transparent GIF files in most popular Web browsers has apparently put quite a few developers into "me- too" mode. Unfortunately for programmers, Windows 9.
Implementing transparent ActiveX controls seems to be one of those programming tasks that is rapidly approaching FAQ status. Programming with the ATL is somewhat more difficult than with MFC, but the resulting ActiveX controls are usually faster.
Microsoft Windows SDK, MFC, Visual C++, Active-X, Multithreading and Synchronization Unix/Linux software build/testing & socket programming. . (MFC), which do not support containment of windowless controls. The Active Template Library (ATL). 'If ActiveX defines a containment relation, what is the abstract data type for that relation?' The Montage answer is to factor out all interaction, layout etc. Visual C++ 6.0 MFC DLLs not backward compatible with Visual C++ 5.0 programs Showing 1-25 of 25 messages. In MFC 4.2x, there was no support for containment of ActiveX DocObj server objects, just OLE 2 objects. Support was added in MFC 6.0 (the. Iphone activex activex containment manual houses for sale in langhorne gables taskbarrepairtoolplus needs activex control quilted chain for christmas tree.
NT don’t provide much native support for the display of graphical images with transparent components. In this article, we provide a fairly simple set of steps that can be used to work around the shortcomings in the O/S. Using Microsoft’s Active Template Library (ATL) we develop an Active. X control that will display a bitmap with a single transparent color.
The control can be used with current and some past versions of Internet Explorer, Netscape Navigator (with the Script. Active plug- in), Visual Basic, and most other Active. X containers. Transparency under Windows. When referring to bitmapped images, the term transparency has a straightforward meaning. A given image has an arbitrary number of transparent areas. When the image is drawn, the transparent areas don’t obscure the area behind the image in the Z- order. In the simplest case, we've all seen this used to good effect on the Web, producing images of complex objects that appear to be floating on top of a background.
Figure 1 shows a pair of transparent GIF files that float nicely above a background on a typical Web page. Figure 1 - Screen capture of a pair of transparent GIF files used in a banner. Sites such as Mr.
Showbiz typically have a standard background pattern that shows up on many or all of their pages. In Figure 1, the GIF on the left side has navigation bars that are used in an image map. A GIF file with the site logo is shown on the right. Both images feature transparent areas that let them blend in nicely with the background.
How do they do that? After seeing this esthetically pleasing effect on the Web, we set ourselves to the task of duplicating it in an Active.
X control. For Windows programmers, encapsulation of a feature in an Active. X control is definitely the method of choice. Research turned up a couple of different ways to implement transparency in a control. The most straightforward of these methods requires the programmer to set up a windows HRGN object, used to define a non- rectangular drawing area. Figure 2 shows a simple example of a drawing region. As long as you can define your region as a path connecting a series of points (or elliptical regions), you can create a drawing region that Windows understands.
Figure 2 - A Windows Drawing Region. Once you have a drawing region defined, transparency is easy. In the simplest case, you can take advantage of an existing Windows 9.
Once that's done, you simply draw the window as you normally would. The areas outside the region will be drawn by whatever resides behind the window. Defining a drawing region works well with containers that implement the OCX 9.
Microsoft (shipping with the Active. X SDK). In the best case, you can implement two pass drawing, which lets you draw the foreground part of your control first, then lets the container draw the background. This provides fast and flicker- free drawing of controls. Ointment ready, enter fly. Defining drawing regions is great for some applications, but it might not be the best general purpose technique.
We wanted to be able to draw any type of image with randomly configured transparent areas. This means having transparency controlled on a pixel by pixel basis.
Attempting to define a region for any arbitrary bitmap is simply asking for a headache! For our control, we instead used a masking technique that is described by Ron Gery in an MSDN article. This technique uses a simple masking technique that makes it trivial to use arbitrarily complex transparent regions. The Gery algorithm assumes that you have a bitmap with a single color that defines the transparent area. Given that, the drawing portion of your code needs to execute the following steps: Create a monochrome bitmap the same size as the bitmap you are going to draw. Set all the transparent pixels in the monochrome bitmap to 1, and all the opaque pixels to 0. XOR the screen region with the bits in your image bitmap.
AND the screen with your monochrome bitmap. This has the effect of leaving all the transparent areas unchanged, and setting the opaque areas to be black. XOR the screen region with the image bits again.
This sets all the transparent areas back to their original color, since the two XOR operations cancel one another. The opaque areas now contain the desired image bits, since XORing with solid black is the same as simply setting the bits. This drawing algorithm is simple to implement using standard Windows raster operations. If you step through it and watch the effects when using the debugger, it will even start to make sense after a few passes. Background checks.
This drawing scheme works pretty well with containers that adhere to the OCX 9. The XOR/Mask sequence preserves the background behind transparent areas, but only if the background has already been drawn. To programs like Internet Explorer 3. Active. X control is simply a child window that is responsible for drawing its entire rectangular area. So when IE3 is drawing the background for a Web Page, it will exclude the areas occupied by child windows, allowing them to draw their own background. So if I've set up a pleasing (or not!) background GIF, IE3 won't bother to draw it in any areas covered by my control, making any attempt at transparent drawing doomed from the start.
Microsoft has documented a way around this problem in Knowledge Base article Q1. This article gives a code snippet that you can drop into a control's WM_ERASEBKGND handler. MFC code similar to that in the Knowledge Base article is shown in Figure 3. C++: BOOL CTrans. Ctrl: :On. Erase. Bkgnd(CDC* p. DC){ CWnd* p. Wnd. Parent = Get.
Parent(); POINT pt; pt. Map. Window. Points(p. Wnd. Parent, & pt, 1); Offset.
Window. Org. Ex(p. DC- > m_h. DC, pt.
Send. Message( p. Wnd. Parent- > m_h.
Wnd, WM_ERASEBKGND, (WPARAM)p. DC- > m_h. DC, 0); Set. Window. Org. Ex( p. DC- > m_h. DC, pt.
NULL); return. Figure 3 - The Transparency Kludge for IE3. In a nutshell, this code sends a WM_ERASEBKGND message to Internet Explorer, along with the device context for the Active. X control. This convinces Internet Explorer to draw the background behind the control as if it didn't belong to a child window. This code doesn't cause any trouble for more sophisticated containers, such as IE4, because the WM_ERASEBKGND never gets sent to controls. Newer containers that implement the OCX '9.
Instead, each control renders itself directly on the container's device context. Putting it together using ATLTo demonstrate the concepts discussed here, we created an Active. X control called Trans. Ctl that displays an eight bit BMP file, and treats all solid white areas ( RGB(2. To keep things simple, the control doesn’t do any palette management, so if you are using it on 2. The system colors are generally always going to be present, regardless of the remaining 2.
We created this control using Visual C++ 5. Microsoft's framework of the month, the Active Template Library. Programming with the ATL is somewhat more difficult than with MFC, but the resulting Active. X controls are usually faster, smaller, and can eliminate dependencies on corpulent DLLs. Working with the ATL is a Wizard- driven process, which means that programming isn’t just typing in code, it also involves quite a few menu selections and button depressions. The next section of this article will walk you through the process from start to finish.
Follow the bouncing ball. In the old days of command line compilers, we could have just included a single C file that held all the source code for this project. Things aren't so easy for authors using IDEs that feature Wizard- based development. The instructions for building this project with Visual C++ look more like a recipe in a cookbook, with an interesting mixture of dialog boxes, button presses, menu options and code snippets. To build any ATL project using Visual C++, you select File New Project ATL COM App. Wizard. The dialog box asks you for a Project Name, which we set to Transparent. Control, and a Location, which we filled in with C: .
We selected the default values on the next dialog, creating a DLL with no MFC support, and no merging of proxy/stub code. The Wizard provides the following dialog to confirm what you’ve just done: Figure 4 - ATL COM App.
Wizard output. At this point we need to create the actual Active. X control that will display our BMP files. To do this, we use Insert New ATL Object, which brings up the ATL Object Wizard, shown in Figure 4.
We select Controls Full Control and click the Next button, which brings up a tabbed properties dialog. In the edit box asking for a short name, we entered Trans. Ctl. In the Miscellaneous sheet of the properties dialog, we turned off the Opaque option. The Stock Properties tab allows you to specify which stock properties your control will support. Our control needs the Ready.
State stock property, which is completely supported by the ATL, but for some reason is absent from the Stock Properties tab. So, to include it in our control’s implementation we have to add the code ourselves, which we discuss later.
Figure 5 - The ATL Object Wizard. Clicking the OK button at this point generates all the files necessary to create the basic Active. X control. You can build the control at this point, and insert it into Microsoft’s Active.
X Control Test Container (accessible from the Tools menu item.) But before it can do anything interesting, we need to add the code that assigns an image file to the control, loads the image file into memory, and draws it on the screen. Dealing with the image file. Since the goal of the Trans. Ctl is to display an image file, we clearly need a property that gives the name of the file.