RGB-to-Hex Conversion
November 3, 2009 by saim · Leave a Comment
Question is: How do I convert RGB values of a color to a hexadecimal string? The algorithm is as follows: make sure that RGB values are in the range 0…255, convert RGB values to hex strings, and then merge the three strings. Here is a script that does this conversion: function RGBtoHex(R,G,B) { return toHex(R)+toHex(G)+toHex(B); [...]
Changing the background color of a dialog
November 1, 2009 by saim · Leave a Comment
If you want to change the background color of your dialog box, it is a very simple. In your CTestDlg header file, declare a member variable from CBrush: class CTestDlg : public CDialog{…protected: CBrush m_brush;…}; Then, add this line in the OnInitDialog function: BOOL CTestDlg::OnInitDialog(){ … m_brush.CreateSolidBrush(RGB(255, 255, 255)); // color white brush … } [...]
Changing the background color of a dialog
November 1, 2009 by saim · Leave a Comment
I have found this proper way to set the color of CDialog in MFC application. Write this Function in your class. HBRUSH CCaptureOPtionsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if( nCtlColor == 6 ) // for Slider control { pDC->SetBkMode(TRANSPARENT);// Set the Background Mode to TRANSPARENT } else if( nCtlColor == CTLCOLOR_DLG ) // for [...]