Results 1 to 4 of 4

Thread: How do i manually draw to a transparent dialog

  1. #1
    Join Date
    Dec 2008
    Posts
    94

    idea How do i manually draw to a transparent dialog

    Hello Friends,

    I would like to know that how do i manually draw a transparent dialog which is configured to be borderless & has nothing on it. I'm trying to draw a graphic file with an image on it and trying to frame it with a skin made of several PNG files. But some how i'm unable to draw the bitmap image on it. Can any body help me out to get the above issue solved? Any kind of information on the above issue would be appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How do i manually draw to a transparent dialog

    • Images should be uploaded in PNG or SVG format. PNG images should be around 600-720 dpi. A transparent background should be used. Images should still be readable when scaled down to 450 pixels to prevent conflicts with the Chembox.
    • SVG images are desirable because they are infinitely scalable, while remaining compact. However, support for SVG images among common molecule editors is limited, and may not be rendered correctly on Wikipedia.
    • Scanned images tend to be of poor quality. Scanned images of books or journals may violate copyright. Do not upload them.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How do i manually draw to a transparent dialog

    This example implements a PropertySheet based wizard. The same techniques would apply to a Dialog.

    To change the CStatic text behavior to transparent drawing requires adding one message handler with four lines of code.

    I create a sub-class of CPropertyPage (for a regular dialog, you would create a sub-class of CDialog). Then I use ClassWizard to create a handler for WM_CTLCOLOR. In that handler, OnCtlColor, I check the nCtlColor parameter, and if it shows that we are about to draw a Static control (CTLCOLOR_STATIC) then I call SetBkMode to change the DC mode to TRANSPARENT. I also get a handle to the stock NULL_BRUSH object and return that as the function result. Then Windows takes care of all the text drawing itself.

    You can change a number of things about the DC in OnCtlColor. All of the various CDC functions are available such as SetTextColor which allows you to change the text color. Of special note is the ability to use CDC: SelectObject which allows you to change the Pen, Brush, Font, Bitmap and Region. The ability to modify the font here is especially useful in working with PropertySheets because there is no way to set the face, size, or style of the font used (PropertySheets always use MS Shell).

    This example also implements using a bitmap for the dialog background. This is done by using ClassWizard to create a handler for WM_ERASEBKGND in the CPropertyPage (CDialog) sub-class. The OnEraseBkgrnd routine then fills the window with the bitmap instead of painting with the background brush.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How do i manually draw to a transparent dialog

    The most tricky part of creating the bitmap is finding a simple file format that has an embedded alpha channel.

    The selected file format for the first incarnation of this article was PSP (Paint Shop Pro™ from Jasc®), but now the recommended file format has been changed to PNG (Portable Network Graphics).

    For loading PNG files I use the paintlib library. This library can also load files from PCX, TGA and TIFF formats.

    This demo application does not use paintlib directly; instead it uses a paintlib wrapper dll, ImgDecoder.Dll.

    For loading PSP files I've created a function called LoadPSPFileToDIB(PSPLoader.h/cpp).

Similar Threads

  1. Draw a rectangle using VB.NET
    By MACE in forum Software Development
    Replies: 3
    Last Post: 04-11-2009, 10:17 PM
  2. How to Draw & Color in lotus 123
    By FADILA in forum Windows Software
    Replies: 3
    Last Post: 31-08-2009, 11:34 AM
  3. How to Draw An Arrow in Photoshop
    By AlienKing in forum Software Development
    Replies: 3
    Last Post: 14-08-2009, 11:40 AM
  4. How to draw a circle using TI 89
    By Bilal in forum Windows Software
    Replies: 3
    Last Post: 20-06-2009, 11:55 AM
  5. Corel Draw problem
    By MACYN in forum Windows Software
    Replies: 4
    Last Post: 02-12-2008, 01:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,456,766.15156 seconds with 17 queries