Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Some Color issues...redirecting the registry? =) Pin
#realJSOP19-Sep-00 1:20
professional#realJSOP19-Sep-00 1:20 
GeneralRe: Some Color issues...redirecting the registry? =) Pin
Fredrik19-Sep-00 2:15
Fredrik19-Sep-00 2:15 
GeneralRe: Some Color issues...redirecting the registry? =) Pin
#realJSOP21-Sep-00 1:19
professional#realJSOP21-Sep-00 1:19 
GeneralRe: Some Color issues...redirecting the registry? =) Pin
Fredrik21-Sep-00 1:38
Fredrik21-Sep-00 1:38 
GeneralConsole Output to Windows Control Pin
J. J.18-Sep-00 5:43
sussJ. J.18-Sep-00 5:43 
GeneralRe: Console Output to Windows Control Pin
Sam Hobbs18-Sep-00 11:26
Sam Hobbs18-Sep-00 11:26 
GeneralButton color Pin
Roger18-Sep-00 5:42
Roger18-Sep-00 5:42 
GeneralHere's what I did... Pin
Fredrik18-Sep-00 22:50
Fredrik18-Sep-00 22:50 
I am far from good at C++ but this is what I did after looking around on diffrnt sites, hope it helps/works =)

First: I used MFC to make the button in my dialog, then I chose Properties with left mouse button on the button and set the button to ownerdrawn. Then use Classwizard to add the WM_DrawItem (Is it called a listener? Nm...hehe) to your dialog window. Then add the following code, with a few changes:


void CAboutDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpdis) // (Change the name CAbotDlg to your Dialogs name (Classwizar should do this for you though))
{
CBrush myBrush;
CBrush m_brHollow;
myBrush.CreateSolidBrush(RGB(178,196,213)); //Change the RGB color to what you want the color of the the button to be
m_brHollow.CreateStockObject(NULL_BRUSH);

const UINT& nAction = lpdis->itemAction;

// Full redraw or selected (up/down) state changed
CWnd* pCtl = CWnd::FromHandle(lpdis->hwndItem);
CString sText;
pCtl->GetWindowText(sText); // button text
CRect rc;
pCtl->GetWindowRect(&rc); // window rectangle..
pCtl->ScreenToClient(&rc); // ..client rectangle
if (lpdis->itemState & ODS_SELECTED) // button is down:
rc += CPoint(1,1); // shift southeast

CDC* pDC = CDC::FromHandle(lpdis->hDC);


// painting the background
CBrush* pOldBrush = pDC->SelectObject(&myBrush);
pDC->PatBlt(0, 0, rc.Width(), rc.Height(), PATCOPY);
pOldBrush = pDC->SelectObject(pOldBrush);

if (lpdis->CtlType==ODT_BUTTON)
{
// Draw button border using COLOR_BTNTEXT
CBrush* pOldBrush = pDC->SelectObject(&m_brHollow);
CPen pen(PS_SOLID, 2, GetSysColor(COLOR_BTNTEXT));
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->Rectangle(&rc); // Draw rectangle

// Draw button text
pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
pDC->DrawText(sText,&rc,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
} else {
// Note: assumes static icon!
pDC->DrawIcon(0, 0, AfxGetApp()->LoadIcon(IDR_MAINFRAME)); //I'll be honest to tell you I don't fully know what this line does =)
}
}

Hope that helps, I'll be checking in here later for questions/remarks etc...
/Fredrik
GeneralRe: Here's what I did... Pin
Roger19-Sep-00 2:17
Roger19-Sep-00 2:17 
GeneralBitmap in a status bar pane Pin
#realJSOP18-Sep-00 3:51
professional#realJSOP18-Sep-00 3:51 
Generalspawning exe file from another exe file Pin
Hamid Yousaf18-Sep-00 1:52
Hamid Yousaf18-Sep-00 1:52 
GeneralRe: spawning exe file from another exe file Pin
Dark Angel18-Sep-00 4:38
Dark Angel18-Sep-00 4:38 
GeneralGet the coordinates of the AppBar Pin
Eq18-Sep-00 0:55
Eq18-Sep-00 0:55 
GeneralRe: Get the coordinates of the AppBar Pin
Michael Dunn18-Sep-00 7:18
sitebuilderMichael Dunn18-Sep-00 7:18 
GeneralError in running Script control Pin
Reny j joseph thuthikattu17-Sep-00 21:37
Reny j joseph thuthikattu17-Sep-00 21:37 
GeneralVC++ conversion urgent Pin
Guruprasad17-Sep-00 18:05
Guruprasad17-Sep-00 18:05 
GeneralRe: VC++ conversion urgent Pin
Dark Angel18-Sep-00 4:34
Dark Angel18-Sep-00 4:34 
GeneralUsing 256 color icons in CTreeCtrl Pin
Mustafa Demirhan16-Sep-00 23:45
Mustafa Demirhan16-Sep-00 23:45 
GeneralSystem Tray Pin
kennan16-Sep-00 23:07
kennan16-Sep-00 23:07 
GeneralRe: System Tray Pin
Mustafa Demirhan16-Sep-00 23:27
Mustafa Demirhan16-Sep-00 23:27 
GeneralRe: System Tray Pin
Mustafa Demirhan16-Sep-00 23:30
Mustafa Demirhan16-Sep-00 23:30 
GeneralRe: System Tray Pin
Sam Hobbs17-Sep-00 19:45
Sam Hobbs17-Sep-00 19:45 
GeneralMFC, API Pin
kennan16-Sep-00 22:06
kennan16-Sep-00 22:06 
GeneralRe: MFC, API Pin
Paolo Messina16-Sep-00 22:48
professionalPaolo Messina16-Sep-00 22:48 
GeneralProblem with getting file and line from ImageHlp.dll Pin
Stephen Kellett16-Sep-00 5:31
Stephen Kellett16-Sep-00 5:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.