Link to home
Start Free TrialLog in
Avatar of msoft
msoft

asked on

How to draw filled boxes on dialog.

== 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.

Michael.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msoft
msoft

ASKER

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.

Thanks.

Avatar of msoft

ASKER

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

thanks.
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?
Avatar of msoft

ASKER

please post as much as you can

thanks.
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"};
RegisterClass(&WndCls);
   
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.

LRESULT WndPrc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
   switch(uMsg)
   {
   case WM_PAINT:
   {
      PAINTSTRUCT Ps;
      HDC DCHnd = BeginPaint(hwnd,&Ps);
      RECT ClpRec;
      GetClipBox(DCHnd,&ClpRec);
      FillRect(DCHnd,&ClpRec,GetStockObject(BLACK_BRUSH));
      EndPaint(hwnd,&Ps)
   }
   default:
      return DefWindowProc(hwnd,uMsg,wParam,lParam);
   }
}