Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to draw filled boxes on dialog.

Posted on 1999-09-17
Medium Priority
Last Modified: 2010-04-01
== working with VC++ 6. ==

I need to draw an array of filled boxes on a dialog (each one should have its own color).

Those boxes should be "on top" of every control on this dialog.

Example would be thankful.

Question by:msoft
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
  • 3
  • 3
LVL 22

Accepted Solution

nietod earned 200 total points
ID: 2054243
I would not recommend drawing this in the dialog itself.  While that can be done, it is a little more tricky and it is hard to draw on top of everythig else.

A better solution is to define a child window class for this and use this window class in the dialog.  You might want to use 1 window for each box or a single window that displays all the boxes, I'm not sure which, it depends on your needs.  Then these windows can be kept on top of their siblings, as you requested.

Let me know if you have any questions.

Author Comment

ID: 2054969
OK, my problem is the following:

I want to define an object using Grid control.
Object is defined by 2 Colors and about 20 other parameters.

I`m using Sheridan Grid Control that has checkbox,listbox etc. bind into the grid
but is is not possible to set color of individual cell
so I want to add a functionality of setting color using this grid.
 I mean that on top of this Grid I`ll draw colorful rectangles and when user clicks on it I`ll show Color Dialog Box.



Author Comment

ID: 2054974
PS: Please send me an example/ details  of how should I do it.

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 22

Expert Comment

ID: 2055156
I really can't there are too many details.  You need to create a window of a new class.  Do you know how to do that?

Author Comment

ID: 2055274
please post as much as you can

LVL 22

Expert Comment

ID: 2055383
Its better if I only post what you need!

Do you know how to create a new window class?

You will need to register a window class using RegisterClass.  For this case you probably want to fill in the WNDCLASS so that the background brush is NULL.  You'll probalby want something like

WNDCLASS WndCls = {0,WndPrc,0,0,InsHnd,NULL,NULL,NULL,NULL,"ClassName"};
You will need to write a window procedure.  The procedure should be pretty simple.  It will probably call the default window procedure for all messages except the WM_PAINT message.  You will have to paint the window in that message.  How, you paint it I can't say as I don't know what it is supposed to look like.

   case WM_PAINT:
      HDC DCHnd = BeginPaint(hwnd,&Ps);
      RECT ClpRec;
      return DefWindowProc(hwnd,uMsg,wParam,lParam);

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

705 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