Click here to Skip to main content
15,891,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: question with the OpenGL loading texture? Pin
El Corazon8-Sep-07 5:11
El Corazon8-Sep-07 5:11 
GeneralRe: question with the OpenGL loading texture? Pin
King Tran8-Sep-07 5:25
King Tran8-Sep-07 5:25 
GeneralRe: question with the OpenGL loading texture? Pin
El Corazon8-Sep-07 5:36
El Corazon8-Sep-07 5:36 
GeneralRe: question with the OpenGL loading texture? Pin
King Tran8-Sep-07 5:50
King Tran8-Sep-07 5:50 
QuestionDDE Comunication Problem in Sharescope Pin
onlyjaypatel8-Sep-07 0:31
onlyjaypatel8-Sep-07 0:31 
Questionhow to change the color of Text if Edit Box Pin
GauranG Shah8-Sep-07 0:25
GauranG Shah8-Sep-07 0:25 
AnswerRe: how to change the color of Text if Edit Box Pin
Nishad S8-Sep-07 0:53
Nishad S8-Sep-07 0:53 
AnswerRe: how to change the color of Text if Edit Box Pin
bob169728-Sep-07 5:27
bob169728-Sep-07 5:27 
If you want some independence from the dialog box, you can control it directly from within a derived control class. This is not the best or easiest way, but it's an option nonetheless...

Create a new class and derive it from CEdit. Create some member variable for text color, background color, background brush etc...

// .h file
class CEditControl : public CEdit
{
// ...
private:
COLORREF m_colorBack;
COLORREF m_colorText;
CBrush m_brushBack;
//...
}

When you choose your variable for the edit control using class wizard, choose category "control", and for the type choose your derived type instead of CEdit.
Also don't forget to include your derived class in your StdAfx.h file

// StdAfx.h
#include "EditControl.h"


Create a handler for the "=WM_CTLCOLOR" message in your derived edit class. It's important to note that there are two WM_CTLCOLOR messages in the wizard. Choose the one with the "=" in front of it. Set it up as described below.

// .cpp file
CEditControl::CEditControl()
: m_colorBack(RGB(255,255,0))
, m_colorText(RGB(255,0,0))
{
m_brushBack.CreateSolidBrush(m_colorBack);
}

CEditControl::~CEditControl()
{
m_brushBack.DeleteObject();
}


BEGIN_MESSAGE_MAP(CEditControl, CEdit)
//{{AFX_MSG_MAP(CEditControl)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEditControl message handlers

HBRUSH CEditControl::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here

/*
This sets the text background to transparent. Works good
for single line edit controls but for multiline you will
need OPAQUE to prevent refresh issues with the text when
typing in the middle of a line in the string.

For example, when edit is multiline, use this instead:
pDC->SetBkMode(OPAQUE);
pDC->SetBkColor(m_colorCustom);
pDC->SetTextColor(m_colorText);
*/
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(m_colorText);

// Return a non-NULL brush if the parent's handler should not be called
return m_brushBack;

// return NULL;
}
QuestionRe: how to change the color of Text if Edit Box Pin
Mark Salsbery8-Sep-07 6:32
Mark Salsbery8-Sep-07 6:32 
AnswerRe: how to change the color of Text if Edit Box Pin
ThatsAlok9-Sep-07 20:14
ThatsAlok9-Sep-07 20:14 
Questioncalling API in driver Pin
zon_cpp8-Sep-07 0:05
zon_cpp8-Sep-07 0:05 
QuestionShared Dll to Static Lib Pin
shakumar_227-Sep-07 21:12
shakumar_227-Sep-07 21:12 
AnswerRe: Shared Dll to Static Lib Pin
Cedric Moonen7-Sep-07 23:22
Cedric Moonen7-Sep-07 23:22 
QuestionHow to begin DirectX Pin
kcynic7-Sep-07 20:59
kcynic7-Sep-07 20:59 
AnswerRe: How to begin DirectX Pin
Nishad S8-Sep-07 0:57
Nishad S8-Sep-07 0:57 
GeneralRe: How to begin DirectX Pin
kcynic8-Sep-07 2:16
kcynic8-Sep-07 2:16 
Questionkernel mode dll Pin
samira forooghi7-Sep-07 19:44
samira forooghi7-Sep-07 19:44 
QuestionSome ambiguities with MFC CString class. [modified] Pin
Hamed Musavi7-Sep-07 19:20
Hamed Musavi7-Sep-07 19:20 
AnswerRe: Some ambigituies with MFC CString class. Pin
chandu0047-Sep-07 19:26
chandu0047-Sep-07 19:26 
GeneralRe: Some ambigituies with MFC CString class. Pin
Hamed Musavi7-Sep-07 19:36
Hamed Musavi7-Sep-07 19:36 
GeneralRe: Some ambigituies with MFC CString class. Pin
Cedric Moonen7-Sep-07 22:57
Cedric Moonen7-Sep-07 22:57 
AnswerRe: Some ambiguities with MFC CString class. Pin
progDes7-Sep-07 20:26
progDes7-Sep-07 20:26 
GeneralRe: Some ambiguities with MFC CString class. Pin
Hamed Musavi7-Sep-07 20:53
Hamed Musavi7-Sep-07 20:53 
AnswerRe: Some ambiguities with MFC CString class. Pin
progDes7-Sep-07 22:29
progDes7-Sep-07 22:29 
GeneralRe: Some ambiguities with MFC CString class. Pin
Hamed Musavi8-Sep-07 4:11
Hamed Musavi8-Sep-07 4:11 

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.