Creating a Round Dialog

Environment: The code in this article was developed using Visual C++ 4.0

This code is used to make a round dialog for various Apps. This could be good for use with an MP3 or CDPLAYER or any other. Surprisingly it's not that hard! [I looked but nobody had written anything for a round dialog. I had been trying to shape a dialog for some time. Then after playing with the Microsoft CD for a SetWindowRgn() for a window I tried to use it for a dialog. Viola! After Jumping around a few times after it compiled I sent it to the Code Guru.



[CRgn m_rgn;  // This is for the dialog area: It goes in your h. file


// This Gets the size of the Dialog: This goes under the OnInitDialog Function 
Crect rcDialog
GetClientRect(rcDialog);


// This Creates area assigned to Dialog: This goes directly below the above in OnInitDialog
m_rgn.CreateEllipticRgn(0, 0, rcDialog.Width(), rcDialogHeight());
SetWindowRgn(GetSafeHwnd(), (HRGN) m_rgn, TRUE);]



Download demo project - 17 KB

Download source - 3 KB

Date Last Updated: April 18, 1999



Comments

  • Very Very Good; Life Saver

    Posted by Legacy on 02/03/2003 12:00am

    Originally posted by: Bradford Powers

    This was exactly what i was looking for. Thank You!!!!!!
    P.S Minus a few typos, but i can understand the excitment :)

    Brad
    Sk8kloud Software

    Reply
  • Hey

    Posted by Legacy on 08/27/2002 12:00am

    Originally posted by: ravi

    It works ...looks really great ...

    Reply
  • Good - but I have a question about the CAPTION.

    Posted by Legacy on 04/12/2000 12:00am

    Originally posted by: Charlie Roche

    I've been making non rectangular dialogs lately, and there are a few different ways to do this. Yours is a good one, but I'm still confused as to how to create a DIALOG with it's icon and title in the task bar but setting it such that the dialog doesnt draw itself a caption. You can do it with a CWnd, by using the CreateEx(...) function, and setting the title string in one of it's parameters, but I havent got this working for a dialog. Can anyone shed some light on this for me?

    Thanks in advance,

    Charlie

    Reply
  • How to avoid blink on the dialog

    Posted by Legacy on 11/29/1999 12:00am

    Originally posted by: VICTOR CARRE�O


    When I use a dialog box, in the OnPaint function i draw different color rectangles.

    How can i do, to avoid blink the screen when i move another window on my dialog.

    I save CRect objects in a CObArray.

    Thanks You.

    Reply
  • redraw problem...

    Posted by Legacy on 11/16/1999 12:00am

    Originally posted by: scott

    When the round dialog is moved, there is a slight redraw problem. There is a slight lag in the redraw. Is there any way to have this lag taken out?

    Scott.
    sb@nh.ca

    Reply
  • Border?

    Posted by Legacy on 10/26/1999 12:00am

    Originally posted by: Johannes Str�mberg

    Great tip, however it
    could use a border, does anyone know how to make one?

    /Johannes

    Reply
  • ROUNDED DIALOG

    Posted by Legacy on 09/26/1999 12:00am

    Originally posted by: sudi

    Hi there, great work
    helped me..
    cheers
    sudarshan

    Reply
  • Any Shape Dialog Box

    Posted by Legacy on 05/23/1999 12:00am

    Originally posted by: Jon Woolman

    If you use CreatePolygonRgn() as in the previous examples, you can create dialog boxes of any shape. It is also possible to use CreatePolyPolygonRgn() to create dialog boxes that are separated into several different shapes.

    Reply
  • slight changes

    Posted by Legacy on 04/23/1999 12:00am

    Originally posted by: Andrew Bryan

    I was unable to get rid of the remains of the dialog frame using the resource editor, however, it you change the create for the region from 0,0 to 2,2 , the frame goes bye bye.

    This make it all look a bit more tidy. By the way, is there another way to centre the caption without using spaces??

    // This Creates area assigned to Dialog
    m_rgn.CreateEllipticRgn(2, 2, rcDialog.Width(), rcDialog.Height());
    ::SetWindowRgn(GetSafeHwnd(), (HRGN)m_rgn, TRUE);


    Andrew

    Reply
  • kool

    Posted by Legacy on 04/20/1999 12:00am

    Originally posted by: KlangenFarben

    i think i've seen this tried a few times some years back
    
    --Windows Developer's Journal, probably when it was
    Win/Dos Dev Journal--but it always tastes better when
    you just surf right into it.

    look forward to playing with src klang

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date