Solved

Changing My Dialog's Color

Posted on 1998-11-12
70
513 Views
Last Modified: 2008-03-06
Hi, Im making a new app abviously :) But I'd like to change the colour of it from that boring grey, but, instead of just changing the color to something different, I'd like to make it similar to Winamp's Interface Color(s) (v2.03 I Have).
It would take me ages to explain how it looks etc, most of you would have seen it anyway, if not, its at http://www.winamp.com - I love the effect it uses, so plz, some1 help, I think im giving away more than enough credits :)

Dark Light
0
Comment
Question by:darklight
  • 27
  • 19
  • 17
  • +4
70 Comments
 
LVL 1

Expert Comment

by:Booth882
ID: 1177744
void CWinApp::SetDialogBkColor(COLORREF clrCtlBk, COLORREF clrCtlText);

let me know if you have any questions.
0
 
LVL 1

Expert Comment

by:Booth882
ID: 1177745
call this from InitInstance to set default color and text for dialog boxes and message boxes within your application.
0
 
LVL 1

Expert Comment

by:Booth882
ID: 1177746
the color effect acheived by the winamp box is not something that can be done with dialog boxes.  dialog boxes can be any color but must remain one solid color, due to limitations imposed by windows.  sorry...
0
 

Expert Comment

by:dimavs
ID: 1177747
You can rewrite
 BOOL CYourDlg::OnEraseBkgnd(CDC* pDC)

0
 
LVL 22

Expert Comment

by:nietod
ID: 1177748
>> the color effect acheived by the winamp box is not something that can be
>> done with dialog boxes.  dialog boxes can be any color but must remain
>> one solid color, due to limitations imposed by windows.  sorry...
A dialog box is just a window.  If you don't want a solid color, just paint it however you want it to look.   You would do that in the WIM_PAINT message handle or in the onPaint() member, if you are in MFC.
0
 

Author Comment

by:darklight
ID: 1177749
People saying its impossible and possible :(

nietod, could you possibly send some sample code to better explain ? If it works, the points are yours. :)

Thanx
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177750
Try something simple... Create yourself a bitmap in your resource file exactly how you want your background to look.  Then create yourself a CStatic control and set the ID to your bitmap in the resources.  Now when displaying the dialog, the bitmap will appear as your background.

Now you can place your controls on your dialog where you want to display/accept data.

For something a little more difficult, override the WM_ERASEBKGROUND message and return false only (this will eliminate the flicker).  Override the WM_PAINT and the first line is

CPaintDC dc( this )   // I hope you're using MFC... :)

now draw your bitmaps/graphics manually with your CDC.  Lines are drawn with MoveTo and LineTo.  Bitmaps and bitmap sections are done with BitBlt and StretchBlt.

Your biggest drawback is if the user has changed their standard font sizes.  It is sometimes hard to make a bitmapped dialog fit all window settings, but good luck.

Do you have a more specific question that we can help you with?

Phillip
0
 

Author Comment

by:darklight
ID: 1177751
I have already tried something similar to this psdavis, using an ActiveX control, it didnt give the effect I was hoping for. Winamp's effect changes the background colour for all the controls, including the progross bar. Which is what Im looking to do (including the column headers of the listview control I am using, the pull down arrow of the combo box's etc). The best part of winamp's effect is that it doesnt (seem to) be a a complete set of images joined together to make a background, it seems to be a single image spanned over the entire background, including the background of all the controls (which I think looks great!) :)

I know this is a real pain, so ill up the points another 100, I appreciate all of your help on this :)

Dark Light
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177752
This isn't that hard.

The default window procedure for a dialog will just paint the window with its background brush.  You can overide that and do it yourself.  No big deal.  

This has no effect on the controls however.  but most controls "reflect" messages to the dialog to have the dialog set the colors. Look at WM_CTLCOLOREDIT, WM_CTLCOLORSTATIC. etc.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177753
Wait a second.  You don't even have to handle the WM_PAINT for the dialog.  Handle the WM_CTLCOLORDLG message instead.  When the default dialog procedure needs to paint the window, it sends this message to the dialog to find out the colors to paint in.  This might be the only message you need to handle (hopefully) because it might automatically return this information to the controls when they ask using the WM_CTLCOLORxxxx messages.   (Maybe.  You'll just have to try and see.)
0
 

Author Comment

by:darklight
ID: 1177754
Great, I think thats what Im looking for....but the help in VC++ is kind of pathetic...

WM_CTLCOLORDLG hdcDlg = (HDC) wParam;   // handle of dialog box display context
hwndDlg = (HWND) lParam; // handle of dialog box

Could you maybe tell me where to put this, where I specify which colours and any additional information you think might be helpfull please? :) thanx
0
 

Author Comment

by:darklight
ID: 1177755
See above.
I want to make sure this works before I give 500 points away, thanx.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177756
wParam;   // handle of dialog box display context

You would pass the dc of the dialog box.  For example, if you had created a CPaintDC or a CDC, then you will want to send the HDC

wParam = pDC->GetSafeHdc( );

hwndDlg = (HWND) lParam; // handle of dialog box

This would be the dialog box itself.

lParam = GetSafeHwnd( );

Phillip

0
 
LVL 1

Expert Comment

by:saneesh100
ID: 1177757
Hi,
  You can chage it in two ways
1) In Vc on app's initinstance use setdlgbkcolor .But u can change it during runtmie

2) To change it run time map on wm_ctl color message . there will get the type of contorl reqestig and u have to return a brush. there check for dilaog and make brush of u'r own . You can change it runtime .it's very easy and useful

 if any doughts please mail to saneesh@fnmail.com
0
 

Author Comment

by:darklight
ID: 1177758
Sorry saneesh100, this has already been suggested. I am after a more complex design, Sorry.

Dark Light
0
 

Author Comment

by:darklight
ID: 1177759
Hmmm...I must be coding this wrong somehow, or putting it in the wrong place :(

void SetDlgBkColor( COLORREF clrCtlBk = RGB(0, 128, 255), COLORREF clrCtlText = RGB(0, 0, 0) );

I am putting this in the "My ProjectDlg.cpp" in the OnInitDialog()

Perhaps someone could shed some light on why its not changing the colour of my dialog? If I get this working, I'll accept it :) I guess I wont get the same effect as winamp, no problem tho :). Ill paste the exact code in the .cpp file for reference, you should see where I have added the "void SetDlgBkColor( COLORREF clrCtlBk = RGB(0, 128, 255), COLORREF clrCtlText = RGB(0, 0, 0) );" Line..:

/////////////////////////////////////////////////////////////////////////////
// CMyProjectDlg message handlers

BOOL CMyProjectDlg::OnInitDialog()
{
      CDialog::OnInitDialog();

      // Add "About..." menu item to system menu.

      // IDM_ABOUTBOX must be in the system command range.
      ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
      ASSERT(IDM_ABOUTBOX < 0xF000);

      CMenu* pSysMenu = GetSystemMenu(FALSE);
      if (pSysMenu != NULL)
      {
            CString strAboutMenu;
            strAboutMenu.LoadString(IDS_ABOUTBOX);
            if (!strAboutMenu.IsEmpty())
            {
                  pSysMenu->AppendMenu(MF_SEPARATOR);
                  pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
            }
      }

      // Set the icon for this dialog.  The framework does this automatically
      //  when the application's main window is not a dialog
      SetIcon(m_hIcon, TRUE);                  // Set big icon
      SetIcon(m_hIcon, FALSE);            // Set small icon
      
      // TODO: Add extra initialization here

void SetDlgBkColor( COLORREF clrCtlBk = RGB(0, 128, 255), COLORREF clrCtlText = RGB(0, 0, 0) );

      return TRUE;  // return TRUE  unless you set the focus to a control
}


// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMyProjectDlg::OnPaint()
{
      if (IsIconic())
      {
            CPaintDC dc(this); // device context for painting

            SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

            // Center icon in client rectangle
            int cxIcon = GetSystemMetrics(SM_CXICON);
            int cyIcon = GetSystemMetrics(SM_CYICON);
            CRect rect;
            GetClientRect(&rect);
            int x = (rect.Width() - cxIcon + 1) / 2;
            int y = (rect.Height() - cyIcon + 1) / 2;

            // Draw the icon
            dc.DrawIcon(x, y, m_hIcon);
      }
      else
      {
            CDialog::OnPaint();
      }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CLiquidFXPDlg::OnQueryDragIcon()
{
      return (HCURSOR) m_hIcon;
}

void CMyProjectDlg::OnButtonAddrecord()
{
      // TODO: Add your control notification handler code here

    m_addrecorddlg.DoModal();

}
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177760
Do you still want to use the WM_CTLCOLORDLG?  If so, you should not have rejected my answer.  I could help you with it....

The cooooresponding MFC procedure name is onCtlColor().  You need to override that for your dialog class.  I can provide more details if that is the way you want to go.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177761
You've got the name slightly wrong...

void SetDialogBkColor( COLORREF clrCtlBk = RGB(192, 192, 192),
COLORREF clrCtlText = RGB(0, 0, 0) );

is a CWinApp member.  Make sure you put it in your application's .cpp file in your InitInstance.

Phillip


0
 
LVL 22

Expert Comment

by:nietod
ID: 1177762
That's a good solution too.  Note that this is a function you call, not one you write.  This will change the background color of all the dialogs and all the "regular" windows in your application.  (i.e. it sets the color that windows have when nothign else is drawn on top of them.)  This is the solution to use if you want all the windows in the app to have the same background color.  If you want different dialogs to have different colors or all dialogs to have colors that are different than other windows, then override the OnCtlColor(0 procedure as I suggested.  If you want even more complex behavior--like wild backgrounds etc.  Then you have to override the onPaint procedures.
0
 

Author Comment

by:darklight
ID: 1177763
Ok, sorry nietod...if you post another answer ill accept it. I just didnt want to accept anything in case someone took the points and ran, and me left with nothing :(

I would like to have the "wild backgrounds" ;) So could you tell me how to override the onPaint procedures. Ive only done only made small applications in C++ before, I have never played around with colours, so if you could, please explain how to do this in detail, thanx :)

psdavis, I still cant get that method to work, it compiles fine, but when I run the app, its still grey. Its in my application's cpp file, in InitInstance.

Thanx everyone for your help...

Dark Light
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1177764
I think nietod is on the right track. Maybe some sample code will help.
0
 
LVL 22

Accepted Solution

by:
nietod earned 500 total points
ID: 1177765
The following fills the dialog with red and draws a green elipse on it    Use this as a model as you obviously don't want that.  You don't have to (actually, should not) accept the answer until you have a working solution.  

SomeDialogClass::OnPaint()
{
   PAINTSTRUCT PntStr;
   CDC *DCPtr = BeginPaint(&PntStr);
   CBrush GrnBrh(RGB(0,255,0));
   RECT CltRct;

   GetClientRect(&CltRct);
   DCPtr->FillSolidRect(&CltRct,RGB(255,0,0));
   CBrush *OldBrh = DCPtr->SelectObject(&GrnBrh);
   DCPtr->Ellipse(CltRct);
   DCPtr->SelectObject(OldBrh);
   EndPaint(PntStr);
}

let me kow if you have questions.
0
 

Author Comment

by:darklight
ID: 1177766
Thankyou nietod, but I get 2 errors when I try to build it :(

C:\My Project\My ProjectDlg.cpp(169) : error C2664: 'int CDC::Ellipse(const struct tagRECT *)' : cannot convert parameter 1 from 'struct tagRECT' to 'const struct tagRECT *'

And,

C:\My Project\My ProjectDlg.cpp(171) : error C2664: 'EndPaint' : cannot convert parameter 1 from 'struct tagPAINTSTRUCT' to 'struct tagPAINTSTRUCT *'

Any idea's?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177767
When you get errors like this, look up the functions in the docs and see if you can figure out that the problems are.  It canl save you some time waiting for me.  In this case both errors are the same, I passed a stucture by value when I should have passed a pointer to it.  In

   DCPtr->Ellipse(CltRct);

is should be

   DCPtr->Ellipse(&CltRct);

and in

   EndPaint(PntStr);

it should be

   EndPaint(&PntStr);

Now the code that pants the rectangle and elipse was just a "placeholder".  That should be replaced with the code that draws what you want.  Do you know what you want?  Do you know how to draw it?
0
 

Author Comment

by:darklight
ID: 1177768
Ok great :) got it working, THANX!
Now, to help make my app's effect more like winamp's, could the ellipse be made into a rectangle, but instead of going from the mid-left of the screen to the mid-right of the screen, could it be made to go from the bottom left, to the top right ?
Also, I have a menu bar at the top of my dialog...the colours do not extend onto the menu bar...is it possible to make it do this ?
Lastly, could a fade effect be used on the colours, so they 'merge' into on another evenly ?
I know this is asking alot, but I am trying to get my dialog as closly resembeling winamp's, as stated in my original question.

Thanx again nietod :)

Dark Light
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1177769
Well done, nietod! Keep it going.

0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177770
> could the ellipse be made into a rectangle?

Sure, there's FrameRect and Rectangle.

> bottom left, to the top right

CRect rcClient;
GetClientRect( rcClient );
DCPtr->Rectangle( &rcClient );

> Also, I have a menu bar at the top of my dialog...the colours do not extend onto the menu bar...is it possible to make it do this ?

Now you would be drawing in the 'Non-Client' area of the dialog and that's a whole 'nother can of worms...

> Lastly, could a fade effect be used on the colours, so they 'merge' into on another evenly ?

Although you have brushes you can create to try to simulate this effect, simple painting functions probably won't help you out.  You would probably have to create a bitmap segment of the fade and use StretchBlt to draw them to scale.

Phillip
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177771
>> Also, I have a menu bar at the top of my dialog...the colours do
>> not extend onto the menu bar...is it possible to make it do this ?

>> Now you would be drawing in the 'Non-Client' area of the dialog
>> and that's a whole 'nother can of worms...

It can, but depending on what you need that can be an enormous amoutn of work.  I do a lot of Non-client drawing, so I can provide some help there, but it is still likely to be a lot of work.  (It depends, some times its not too bad.)  

Can you describe what the window should look like?  what are the colors, where are they?  Client area?, frame?, caption?

> Lastly, could a fade effect be used on the colours, so they 'merge' into on another evenly ?

>> Although you have brushes you can create to try to simulate this
>> effect, simple painting functions probably won't help you out.  You
>> would probably have to create a bitmap segment of the fade and
>> use StretchBlt to draw them to scale.
You can also do this by painting a bunch of small rectangulare strips that each have slightly different colors.  However Phillip's suggestion is probably better.  To elaborate on that, all you need to do is to use a paint program that gives you control over the palette (cheap ones might not)  create a bitmap that is 1 row hight and the number of columns across that you want to have shades of colors for (I would do 256).  Adjust the pallette  so it specifies all the colors you want.  Then "fill in" the bitmap by making each pixel a different color in the sequence.  
To draw with this you will  use StretchBlt() to scale the I row bitmap up to the number of rows you need.  If the destination is not the same width as the bitmap, that is not a problem, it will scale that way too.  If the destination is wider than the bitmap (which is likely) it will make some of the color sections more than 1 pixel wide, which will still look fine.  If the destination is smaller, it will remove some of the colors so that the gradient will fit.  That will look okay too.

If you don't want to bother with the non-client area drawing (and I wouldn't recommend it unless you are really dedicated) Why not consider having the gradient run the other direction?  ie. it fades up and down rather than left and right.  That will look better with a single color menu.  I think anyways.
psdavis, thanks.

0
 

Author Comment

by:darklight
ID: 1177772
>> Can you describe what the window should look like?  what are >> the colors, where are they?  Client area?, frame?, caption?

Ok, Im making an FTP client, with a similar interface to CuteFTP. So it has 2 listview controls (1 for local, 1 for remote - ie. the FTP site your logged into). Above the listview controls are 2 combo box's (1 each), to display the current working directory, the directory can be changed easily with the combo box's by pulling down the combo box, which displays a list of previously viewed directories. above each of the combo box's is a control called: Microsoft Forms 2.0 Label...which is what ill use to display the name of the site the user has logged into.
above that is the menu bar.
Now below the listview controls I have a text box, which ill use for showing the current status (commands sent, recieved etc to/from the site).
I would like to have a colourful user-interface, which is why im trying to get the effect winamp uses. which fades from a dark grey to a light grey towards the center of its dialog, then fades back to dark grey as it reaches the opposite corner. The effect starts from the top left and finishes at the bottom right.

The 2 colours I want to use instead of dark grey/light grey are:
1. RGB = 45,45,45 as the outer colour and,
2. RGB = 0,103,206 as the inner colour.
Preferably going in a diagonal direction (from top left to bottom right - I mixed it up yesterday, I didnt mean bottom left to top right...sorry). The window is takes the full screen (btw, I'd appreciate it if you told me how to make the app start maximised).

Im not making this app to make money, rather to learn...Ive made several apps just to do this, this time id like to learn to use colours in my app using a different effect instead of just a single colour. So just leaving out the colours would make this app kind of pointless ;) So yeah, I guess im dedicated...the time it takes to get this working properly doesnt worry me at all. The colour doesnt have to extend into the controls at this point...I will be just using black as a background, and a light blue for the text inside the controls.

Well, I hope thats enough info to work with for now, any other questions id be happy to answer.

When giving me some sample code, could you please be specific as where to put it etc :)

Thanx psdavis and nietod! You have no idea how much this is appreciated :)

Dark Light
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177773
> which fades from a dark grey to a light grey towards the center of its dialog, then fades back to dark grey as it reaches the opposite corner.

I would definitely create yourself a bitmap using paintshop or something similar.  Then when you are drawing the bitmap inside of your OnPaint function, use StretchBlt and pass it the dimensions of the dialog.  That should give you that piece of it.

> I'd appreciate it if you told me how to make the app start maximised).

In your app's InitInstance, set this one line

   m_nCmdShow = SW_MAXIMIZE;

And you'll start maximized...

Phillip
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177774
>> So yeah, I guess im dedicated
I assume that means that you want to try to get this working in the non-client area as well  Lets get it working in the client area first.   Then I can send you some code that will get you started in the non-client area.  
0
 

Author Comment

by:darklight
ID: 1177775
psdavis: I get another error when I try to put the line "m_nCmdShow = SW_MAXIMIZE;" in my app..

C:\My Project\My ProjectDlg.cpp(95) : error C2065: 'm_nCmdShow' : undeclared identifier

nietod: Ok sure :) I'll make the bitmap right away, so in the meantime, would either of you like to send some sample code to demonstrate how to use the bitmap in my OnPaint() function plz? :) Thanksagain for all your help :)

Dark Light
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177776
m_nCmdShow is a member of some class, I'm not sure which as I don't use MFC.  But in any case, it might be more direct to specify it using window styles when the dialog is created.  (That is how I do it in non-MFC).  I specify a style that has WS_MAXIMIZE when the window is created and the window will be created maximized.  Do you have an opportunity to specify the window style?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177777
>> would either of you like to send some sample code to
>> demonstrate how to use the bitmap in my OnPaint()
I will i a bit.  I have to go for now.  Take a look at StretchBlt(). (There is a lot more to it than that, but that is a start.)
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177778
C:\My Project\My ProjectDlg.cpp(95) : error C2065: 'm_nCmdShow' : undeclared identifier

Ahhh.. Do you have a dialog based app and not a SDI or MDI, correct?  That's why the m_nCmdShow isn't working, it's based on CWinApp.

> send some sample code to demonstrate how to use the bitmap in my OnPaint()

There are good examples at codeguru if you want to look there.

Phillip
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:darklight
ID: 1177779
Yes I have a dialog based app. Is this a problem if I want the window to start maximised?
Ive created the bitmap, but I saved it as 24 Bit (It was the only option PhotoShop gave me). I hope this is ok.

psdavis: I cant seem to find much on using a bitmap as a background at codeguru (excpet as the background of a listview control).

Dark Light
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177780
OK, I guess I was too specific there.  Here's some code I use to
draw in a mainframe..  It might be a little scattered because I'm putting it together from different sources and I had to take out stuff you didn't need

// header file...
CBitmap m_bmLogo;
CPalette m_palLogo;

CYourDialog::OnPaint( )
{
.
   if( m_bmLogo.GetSafeHandle( ) == NULL )
   {
      HBITMAP hLogoBitmap = (HBITMAP) ::LoadImage( AfxGetInstanceHandle( ), MAKEINTRESOURCE( IDB_CUSTOMS ), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

      if( hLogoBitmap )
         m_bmLogo.Attach( hLogoBitmap );

   // Create the palette to go with our DIB section

      if(( dc.GetDeviceCaps( RASTERCAPS ) & RC_PALETTE ) != 0 )
      {
         DIBSECTION ds;
         m_bmLogo.GetObject( sizeof( DIBSECTION ), &ds );

         int nColors;

         if( ds.dsBmih.biClrUsed != 0 )
            nColors = ds.dsBmih.biClrUsed;
         else
            nColors = 1 << ds.dsBmih.biBitCount;

      // Create a halftone palette if the DIB section contains more than 256 colors

         if( nColors > 256 )
            m_palLogo.CreateHalftonePalette( &dc );

      // Create a custom palette from the DIB section's color table

         else
         {
            RGBQUAD* pRGB = new RGBQUAD[ nColors ];

            CDC memDC;
            memDC.CreateCompatibleDC( &dc );

            CBitmap* pOldBitmap = memDC.SelectObject( &m_bmLogo );
//          CBitmap* pOldBitmap = memDC.SelectObject( &m_bmBackground );
            ::GetDIBColorTable( memDC.GetSafeHdc( ), 0, nColors, pRGB );
            memDC.SelectObject( pOldBitmap );

            UINT uiSize = sizeof( LOGPALETTE ) + ( sizeof( PALETTEENTRY ) * ( nColors - 1 ));
            LOGPALETTE* pLP = (LOGPALETTE*) new BYTE[ uiSize ];

            pLP->palVersion = 0x300;
            pLP->palNumEntries = (unsigned short) nColors;

            for( int iCurrColor = 0; iCurrColor < nColors; iCurrColor ++ )
            {
               pLP->palPalEntry[ iCurrColor ].peRed   = pRGB[ iCurrColor ].rgbRed;
               pLP->palPalEntry[ iCurrColor ].peGreen = pRGB[ iCurrColor ].rgbGreen;
               pLP->palPalEntry[ iCurrColor ].peBlue  = pRGB[ iCurrColor ].rgbBlue;
               pLP->palPalEntry[ iCurrColor ].peFlags = 0;
            }

            m_palLogo.CreatePalette( pLP );
            delete[] pLP;
            delete[] pRGB;
         }
      }
   }

     CRect rcClientRect;
     GetClientRect( &rcClientRect );

      pDC->Rectangle( rcClientRect );

   // BitBlts the Logo on to the background

      if( m_bmLogo.GetSafeHandle( ))
      {
      // Setup the palette for this bitmap

         CPalette* pOldPalette = NULL;
   
         if( m_palLogo.GetSafeHandle( ))
         {
            pOldPalette = pDC->SelectPalette( &m_palLogo, FALSE );
            pDC->RealizePalette( );
         }

      // Create our compatible DC

         DIBSECTION ds;

         CDC memDC;
         memDC.CreateCompatibleDC( pDC );

      // Draw the background in a layered format

         CBitmap* pOldBitmap = NULL;

      // Draw the logo centered on the immge

         m_bmLogo.GetObject( sizeof( DIBSECTION ), &ds );

         pOldBitmap = memDC.SelectObject( &m_bmLogo );

              CPoint ptLogo(( rcClientRect.Width( ) - ds.dsBm.bmWidth ) / 2, ( rcClientRect.Height( ) - ds.dsBm.bmHeight ) / 2 );
         pDC->BitBlt( ptLogo.x, ptLogo.y, ds.dsBm.bmWidth, ds.dsBm.bmHeight, &memDC, 0, 0, SRCCOPY );

      // Now free up the information and restore the DC

         memDC.SelectObject( pOldBitmap );

         if( pOldPalette != NULL )
            pMemDC.SelectPalette( pOldPalette, FALSE );
      }
   }

Phillip
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177781
That's a very good example.  Alot if what it is doing is not directly related to drawing the bitmap,  but is related to manipulating the color palettes.  You would not have to do this, but you will certainly get better results if you do.

Some explanation:
LoadImage() can be used in lots of ways.  In this case it is being used to load a bitmap.  The LR_CREATEDIBSECTION flag is specified to make it load a device independant bitmap.  This means that the bitmap is loaded with the exact colors specified in the resource/file.  It is because of this that all the color pallete stuff is being done.  Without this flag, the procedure would create a device dependant bitmap by mapping the colors to those used by the screen.  this would be a lot simpler, but the results would not be nearly as good.

The dc.GetDeviceCaps( RASTERCAPS ) & RC_PALETTE ) code checks that the device supports palettes.  That is a good idea.  Most programmers would just assume it did.  

next he tries to determine the number of colors used by the bitmap.  As is always true in windows, this is more complex than it should be.  The bitmap specified the number of colors it uses, but if that number is 0 it indicates that the bitmap uses the maximum number of colors that can uses with the bitmap's color format.  (Some windows programmer way back when actually thought that this would make it simpler for us!)  So he uses the code

 if( ds.dsBmih.biClrUsed != 0 )
       nColors = ds.dsBmih.biClrUsed;
 else
       nColors = 1 << ds.dsBmih.biBitCount;

to get the number of colors.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177782
If the bitmap uses more than 256 colors, he then creates a halftone palette for it rather than creating a specific color palette.  When the bitmap is copied to the screen, the halftone palette will use dithering or halftones (that is use adjacent pixels of different colors to "mix" colors that are specified in the bitmap, but are not available on the screen.)  This is very good for your usage, because you are likely to have many colors in your bitmap that won't be availalble on the screen , but dithering will reproduce them very well.

If the bitmap uses less than 256 colors, he creates a palette for it "manually".   He allocates memory for the color table and then gets the color table with GetDIBColorTable().  Then he creates memory for a LOGPALETTE structure and fills in the color information.  (Again a whole process that is far more complex than it should be.  Thankyou microsoft.)  Finally he creates a palette with CreatePalette().

In either case, he then selects the pallete (however it was made) into the destination DC (the screen in your case).  Notice that he saves the original palette that the DC was using, so he can  select it back in in the end.  Then he uses RealizePalette() which makes the DC use the palette.  (makes it do the color mapping etc.).

Mext he creates a compatible memory DC (one for dealing with memory bitmaps, like the one he loaded, rather than hardware images, like a screen or printer DC).  (Compatible means that it has the same color format and other attributes as the destination DC.)

Next he selects the bitmap into the memory DC and again saves the old bitmap that is returned so it can be selected back in when done.  (Very important and often missed).

Finally, he calls BitBlt() the function that actually does what needs to be done, copies the bitmap from the memory DC to the destination DC.  (draws it on the screen.)  This function can be made to do about a million different things but in this case he has specified the SRC_COPY  flag which makes it copy the one bitmap to the other with no changes other than stretching or shrinking to fit.

After than he cleans up.  He selects back the original memory bitmap and original palette.  In your case there may be additional things to clean up (either here or later), such as the bitmap itself.  He is retaining it so it doesn't have to be loaded repeatedly each time the window must be drawn.  (a good idea.)  But eventually it must be deleted.

A good example, much better than what I would have posted.  I'm going out of town in a few hours and will be gone until Tuesday.  Let me know if you have questions before then.  Otherwise, you may have to wait until tuesday (although as you can see there are lots of other experts involved here.)

0
 

Author Comment

by:darklight
ID: 1177783
THANKYOU psdavis :)

Just 1 question (I'm sure this is going to sound really dumb) -

Where do I specify the name of the bitmap I have saved ? (background.bmp)
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177784
HBITMAP hLogoBitmap = (HBITMAP) ::LoadImage( AfxGetInstanceHandle( ), MAKEINTRESOURCE( IDB_CUSTOMS ), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

This is if it is inside of the resource file.  If you wanted to load up an external file, then change MAKEINTRESOURCE to "background.bmp" and add an extra flag to load from file.  Unfortunately, I'm at home and I don't have my documentation all copied over yet.  Take a look at yours, it will be something like LR_CREATEDIBSECTION | LR_LOADFROMFILE.

Phillip
0
 

Author Comment

by:darklight
ID: 1177785
Ok...I replaced MAKEINTRESOURCE with "background.bmp" sp the line is now:
HBITMAP hLogoBitmap = (HBITMAP) ::LoadImage( AfxGetInstanceHandle( ), "background.bmp"( IDB_CUSTOMS ), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

- Just pasting that line so you can make sure I have done it correctly.

Now when trying to build it, I get a massive 10 error's :(

C:\My Project\My ProjectDlg.cpp(150) : error C2065: 'IDB_CUSTOMS' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(157) : error C2065: 'dc' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(157) : error C2228: left of '.GetDeviceCaps' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(212) : error C2065: 'pDC' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(212) : error C2227: left of '->Rectangle' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(224) : error C2227: left of '->SelectPalette' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(225) : error C2227: left of '->RealizePalette' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(246) : error C2227: left of '->BitBlt' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(253) : error C2065: 'pMemDC' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(253) : error C2228: left of '.SelectPalette' must have class/struct/union type

Im sure its something simple...because all 10 errors are so similar...am I forgetting something ?

Dark Light
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177786
> HBITMAP hLogoBitmap = (HBITMAP) ::LoadImage( AfxGetInstanceHandle( ), "background.bmp"( IDB_CUSTOMS ), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

Remove the IDB_CUSTOMS stuff completely.  You've replaced the entire parameter with "background.bmp"

You still have to have that secondary flag to load it from file instead of resource.

> C:\My Project\My ProjectDlg.cpp(157) : error C2065: 'dc' : undeclared identifier

Replace that with pDC->

Remember, this is only segments of code thrown together, you still have to think about what it is doing.

C:\My Project\My ProjectDlg.cpp(212) : error C2065: 'pDC' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(212) : error C2227: left of '->Rectangle' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(224) : error C2227: left of '->SelectPalette' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(225) : error C2227: left of '->RealizePalette' must point to class/struct/union
C:\My Project\My ProjectDlg.cpp(246) : error C2227: left of '->BitBlt' must point to class/struct/union

OK, so the pDC-> isn't valid in your case.  Remember, I can't see your code and how you did it.

If your code looks like CPaintDC dc( this ), then replace all of the pDC-> with dc.  ok?

> C:\My Project\My ProjectDlg.cpp(253) : error C2065: 'pMemDC' : undeclared identifier

Replace the pMemDC with MemDC.

Phillip
0
 

Author Comment

by:darklight
ID: 1177787
Ok, after the changes, im still getting errors :( Only 8 now though.

C:\My Project\My ProjectDlg.cpp(157) : error C2065: 'dc' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(157) : error C2228: left of '.GetDeviceCaps' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(212) : error C2228: left of '.Rectangle' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(224) : error C2228: left of '.SelectPalette' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(225) : error C2228: left of '.RealizePalette' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(246) : error C2228: left of '.BitBlt' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(253) : error C2065: 'MemDC' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(253) : error C2228: left of '.SelectPalette' must have class/struct/union type

Even with the changes, im getting the same erro. eg.
After changing pMemDC to MemDC in line 253 because of the error:

C:\My Project\My ProjectDlg.cpp(253) : error C2065: 'pMemDC' : undeclared identifier

I get the error:

C:\My Project\My ProjectDlg.cpp(253) : error C2065: 'MemDC' : undeclared identifier

Weird huh? :(

Ill paste all the code in my OnPaint() function, to see if I have messed it up anywhere :) Thanx...

void CMyProjectDlg::OnPaint()

{

      if( m_bmLogo.GetSafeHandle( ) == NULL )
      {
            HBITMAP hLogoBitmap = (HBITMAP) ::LoadImage( AfxGetInstanceHandle( ), "background.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

            if( hLogoBitmap )
                  m_bmLogo.Attach( hLogoBitmap );

            // Create the palette to go with our DIB section

            if(( dc.GetDeviceCaps( RASTERCAPS ) & RC_PALETTE ) != 0 )
            {
                  DIBSECTION ds;
                  m_bmLogo.GetObject( sizeof( DIBSECTION ), &ds );

                  int nColors;

                  if( ds.dsBmih.biClrUsed != 0 )
                              nColors = ds.dsBmih.biClrUsed;
                  else
                        nColors = 1 << ds.dsBmih.biBitCount;

                  // Create a halftone palette if the DIB section contains more than 256 colors

                  if( nColors > 256 )
                  m_palLogo.CreateHalftonePalette( &dc );

                  // Create a custom palette from the DIB section's color table

                  else
                  {
                        RGBQUAD* pRGB = new RGBQUAD[ nColors ];

                        CDC memDC;
                        memDC.CreateCompatibleDC( &dc );

                        CBitmap* pOldBitmap = memDC.SelectObject( &m_bmLogo );
                        // CBitmap* pOldBitmap = memDC.SelectObject( &m_bmBackground );
                        ::GetDIBColorTable( memDC.GetSafeHdc( ), 0, nColors, pRGB );
                        memDC.SelectObject( pOldBitmap );

                        UINT uiSize = sizeof( LOGPALETTE ) + ( sizeof( PALETTEENTRY ) * ( nColors - 1 ));
                        LOGPALETTE* pLP = (LOGPALETTE*) new BYTE[ uiSize ];

                        pLP->palVersion = 0x300;
                        pLP->palNumEntries = (unsigned short) nColors;

                        for( int iCurrColor = 0; iCurrColor < nColors; iCurrColor ++ )
                        {
                              pLP->palPalEntry[ iCurrColor ].peRed   = pRGB[ iCurrColor ].rgbRed;
                              pLP->palPalEntry[ iCurrColor ].peGreen = pRGB[ iCurrColor ].rgbGreen;
                              pLP->palPalEntry[ iCurrColor ].peBlue  = pRGB[ iCurrColor ].rgbBlue;
                              pLP->palPalEntry[ iCurrColor ].peFlags = 0;
                        }

                        m_palLogo.CreatePalette( pLP );
                        delete[] pLP;
                        delete[] pRGB;
                  }
            }
      }

      CRect rcClientRect;
      GetClientRect( &rcClientRect );

      dc.Rectangle( rcClientRect );

      // BitBlts the Logo on to the background

      if( m_bmLogo.GetSafeHandle( ))
      {
            // Setup the palette for this bitmap

            CPalette* pOldPalette = NULL;
   
        if( m_palLogo.GetSafeHandle( ))
        {
                  pOldPalette = dc.SelectPalette( &m_palLogo, FALSE );
            dc.RealizePalette( );
        }

            // Create our compatible DC

        DIBSECTION ds;

        CDC memDC;
        memDC.CreateCompatibleDC( dc );

            // Draw the background in a layered format

        CBitmap* pOldBitmap = NULL;

            // Draw the logo centered on the immge

        m_bmLogo.GetObject( sizeof( DIBSECTION ), &ds );

        pOldBitmap = memDC.SelectObject( &m_bmLogo );

        CPoint ptLogo(( rcClientRect.Width( ) - ds.dsBm.bmWidth ) / 2, ( rcClientRect.Height( ) - ds.dsBm.bmHeight ) / 2 );
        dc.BitBlt( ptLogo.x, ptLogo.y, ds.dsBm.bmWidth, ds.dsBm.bmHeight, &memDC, 0, 0, SRCCOPY );

            // Now free up the information and restore the DC

        memDC.SelectObject( pOldBitmap );

        if( pOldPalette != NULL )
                  MemDC.SelectPalette( pOldPalette, FALSE );
      }

//      ----------------------------------------------
//      This is nietod's code
//      ----------------------------------------------
//      PAINTSTRUCT PntStr;
//      CDC *DCPtr = BeginPaint(&PntStr);
//      CBrush GrnBrh(RGB(0,128,255));
//      RECT CltRct;
//
//      GetClientRect(&CltRct);
//      DCPtr->FillSolidRect(&CltRct,RGB(0,0,0));
//      CBrush *OldBrh = DCPtr->SelectObject(&GrnBrh);
//      DCPtr->Ellipse(&CltRct);
//      DCPtr->SelectObject(OldBrh);
//      EndPaint(&PntStr);
//      ----------------------------------------------

      if (IsIconic())
      {
            CPaintDC dc(this); // device context for painting

            SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

            // Center icon in client rectangle
            int cxIcon = GetSystemMetrics(SM_CXICON);
            int cyIcon = GetSystemMetrics(SM_CYICON);
            CRect rect;
            GetClientRect(&rect);
            int x = (rect.Width() - cxIcon + 1) / 2;
            int y = (rect.Height() - cyIcon + 1) / 2;

            // Draw the icon
            dc.DrawIcon(x, y, m_hIcon);

      }
      else
      {
            CDialog::OnPaint();

      }

}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMyProjectDlg::OnQueryDragIcon()
{
      return (HCURSOR) m_hIcon;
}
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177788
You missed the most important line.

void CMyProjectDlg::OnPaint()
{
   CPaintDC dc(this); // device context for painting

   ....

// That will clear up

C:\My Project\My ProjectDlg.cpp(157) : error C2065: 'dc' : undeclared identifier
C:\My Project\My ProjectDlg.cpp(157) : error C2228: left of '.GetDeviceCaps' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(212) : error C2228: left of '.Rectangle' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(224) : error C2228: left of '.SelectPalette' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(225) : error C2228: left of '.RealizePalette' must have class/struct/union type
C:\My Project\My ProjectDlg.cpp(246) : error C2228: left of '.BitBlt' must have class/struct/union type

> MemDC.SelectPalette( pOldPalette, FALSE );

Oops.. memDC

Phillip
0
 

Author Comment

by:darklight
ID: 1177789
Great! Thanx psdavis :) Only 1 error now...

C:\My Project\My ProjectDlg.cpp(235) : error C2664: 'CreateCompatibleDC' : cannot convert parameter 1 from 'class CPaintDC' to 'class CDC *'

Line 234 --> CDC memDC;
Line 235 --> memDC.CreateCompatibleDC( dc );

Any idea's ?

Dark Light
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177790
memDC.CreateCompatibleDC( &dc );


0
 

Author Comment

by:darklight
ID: 1177791
Thanx :)
.
5 errors now :(

My ProjectDlg.obj : error LNK2005: "class CBitmap  m_bmLogo" (?m_bmLogo@@3VCBitmap@@A) already defined in My Project.obj
My ProjectDlg.obj : error LNK2005: "class CPalette  m_palLogo" (?m_palLogo@@3VCPalette@@A) already defined in My Project.obj
My ProjectDlg.obj : error LNK2005: "class CBitmap  m_bmLogo" (?m_bmLogo@@3VCBitmap@@A) already defined in My Project.obj
My ProjectDlg.obj : error LNK2005: "class CPalette  m_palLogo" (?m_palLogo@@3VCPalette@@A) already defined in My Project.obj
Debug/Liquid FXP.exe : fatal error LNK1169: one or more multiply defined symbols found

Sorry for all this hassle :(

Dark Light
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177792
You're including the header file more than once.  I'm not sure how you can be doing it.  If you still get the error after doing the next few things, then send the entire header.

1) Make sure that your header file looks like...

CMyProjectDialog : public ...
.
public:
   CBitmap m_bmLogo;
   CPalette m_palLogo;
.
};

Make sure it's not defined anywhere else.

2) Try adding the following to your entire header

#ifndef CMYPROJECTDIALOG
#define CMYPROJECTDIALOG

.

#endif

Phillip
0
 

Author Comment

by:darklight
ID: 1177793
Ok, no error's now :) excellent! THANKYOU :)

It seems to be sort of working, but my dialog is just white, nothing else...its putting something on top of the dialog, but not the black and blue bitmap I am using.

Dark Light
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177794
You will have to override your OnEraseBkgnd function to make sure that you're not overwriting your graphics with an erase command.  

Drag the edges of your dialog around (if you can) or open/close the window to see if you can see your bitmap flashing before it erases.  If it does, then it's the erase command!

Phillip
0
 

Author Comment

by:darklight
ID: 1177795
Nope...Cant seem to see itat all :( Ive check the main files of my project, and I cant seem to find anything related to erasebackground (or similar) except this:

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

Which seems to be related to my icon, when I comment it out however, the app still runs fine, and I still have an icon, but no background (except for the white).

Dark Light
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177796
I'm back.  I was on vacation.

>> Nope...Cant seem to see itat all
OnEraseBkgnd, like all the other class functions in an MFC class.  Is already defined in a base class.  If you don't overide it--define it yourself--then the base class's version will be called instead.  Thus you may not be able to find an onEraseBkgrd(), but that doesn't mean there isn't one.  There is one, defined somewhere in the depths of MFC and that one is being called.  When you overide the function with your own (define one for your class), then yours will be called instead.

0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177797
Use the class wizard and find WM_ERASEBKGND (or something similar).  Double click on it and you will create a function called OnEraseBkgnd( ).  Change the code inside of it to just return true.

Welcome back nietod, where'd ya go?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177798
Thanks.  Cleveland, OH.  For a wedding.  Its actually good to relax in front of a computer with a huge pile of work.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177799
Were a sick breed, aren't we?
0
 

Author Comment

by:darklight
ID: 1177800
Its not there :(

WM_CANCELMODE ; WM_CAPTURECHANGED ; WM_CHAR ; WM_CHARTOITEM ; WM_CLOSE ; WM_COMPAREITEM ; WM_CONTEXTMENU ; WM_COPYDATA ; WM_CREATE ; WM_CTLCOLOR ; WM_DELETEITEM ; WM_DESTROY ; WM_DRAWITEM ; WM_HELPINFO ; WM_HSCROLL ; WM_INITDIALOG ; WM_KEYDOWN ; WM_KEYUP ; WM_KILLFOCUS ; WM_LBUTTONDBLCLK ; WM_LBUTTONDOWN ; WM_LBUTTONUP ; WM_MEASUREITEM ; WM_MOUSEMOVE ; WM_MOUSEWHEEL ; WM_MOVE ; WM_PAINT ; WM_RBUTTONDBLCLK ; WM_RBUTTONDOWN ; WM_RBUTTONUP ; WM_SETCURSOR ; WM_SHOWWINDOW ; WM_SIZE ; WM_TCARD ; WM_TIMER ; WM_VKEYTOITEM ; WM_VSCROLL

Thats it for the WM's :(


0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177801
Sigh.... Send me your project and I'll look into it.

phillip@afix.net


0
 

Author Comment

by:darklight
ID: 1177802
Oh...Its ok, if its that much of a problem, I wont worry about, after all, its not a crucial piece of work thats due in anytime now...just thought i'd try to learn a bit with graphics. I'll accept nietod's answer if he doesnt have any suggestions with it.
Thanx both of you for all your help on this...much obliged... maybe one day ill have the experience to work through the code and fix it myself :)

Thanx again,
Dark Light
0
 

Author Comment

by:darklight
ID: 1177803
I will repay your efforts with plenty of points psdavis, but earlier today I posted a 200 point question...that was all the points I had...But I will repay you.

BTW...Do either of you have ICQ? I wont bug you with complex questions like this one...only if I get stuck on something simple (eg. Yesterday I couldnt work out how to start a new line in an edit box...\n or \r wouldnt work...So I posted a small question and found it was a combination of the 2 :/) I need to try and save as many points as I can without wasting them on such simple questions. Thanx :)

Dark Light
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177804
darklight, I'm not sure where you got that list of window messages, but there are many more window messages than those.  (100s more).

Its pretty obvious that psdavis is providing most of the help.  Not that I couldn't, I've just had poor timing.  If your low on points, why not reject my answer and let him answer.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1177805
Thanks nietod, it's OK though, C++ points don't mean that much to me, I'm basically in the MFC forum. (OK, so I'm slumming...)

Darklight, go ahead and e-mail me the stuff and let's get it going.  I've got the full thanksgiving holiday to look at it. (Besides, this thread is taking an alfully long time to load.


0
 
LVL 22

Expert Comment

by:nietod
ID: 1177806
I meant to add in mine that (as many people seem to know) my e-mail address is on my expert page  Its nietod@theshop.net.  
0
 

Author Comment

by:darklight
ID: 1177807
Ok then...Ill send it tommorow :) Can't today...gotta go out in a couple minutes..thanx both for your help. :)

BTW nietod: I got the list of WM's from the Class Wizard list box...and thats all it had...where do I see the rest of them ?

Dark Light
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177808
I don't use the class wizzard, but I was just fooling with it.  I got a very short list of window messages myself, although I don't think it was the same as the one you got.  I don't know why.  

Personally, I don't like the class wizzard, so I would just add member functions "manually"  The member function that corresponds to WM_ERASEBKGND is OnEraseBkGrd().  
0
 

Author Comment

by:darklight
ID: 1177809
Ok...Sorry for no comments lately, been a really busy week for me actually :( And sorry for not posting the project psdavis...I'd like to work on it myself when I know the language a lot better (probably not for a while ;) ). Ill keep the code and look at it later, thankyou both for all your help, much appreciated!

nietod, ill adjust the points to 250, and accept your answer, psdavis, ill create a new question in C++ for 250 points. Is that ok?

Thanx again, I learnt plenty through question (some new WM's, and lots of new functions that I understand now).

Dark Light
0
 

Author Comment

by:darklight
ID: 1177810
Hmmm...ok, I cant decrease the points (fair enough I guess). So ill accept your answer nietod and maybe you could give psdavis 250 ?

Thanx

Dark Light
0
 

Author Comment

by:darklight
ID: 1177811
BTW...Hope I can still e-mail either of you if I have a 'small' problem with VC++ ? :)

If not, NP ;)

Thanks again

Dark Light
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177812
My e-mail address is on my expert page.  Let me know when/if you want to start drawing the non-client area manually, and I'll send you some code that draws it manually to make it look just like a normal window.  You cna alter that to make it draw differently.
0
 

Author Comment

by:darklight
ID: 1177813
Ok thanks nietod :)

Dark Light
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 clear a vector as well as how to detect empty vectors in C++.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now