Click here to Skip to main content
16,005,389 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLoading file data into Edit Cntrl boxes Pin
wohoowahoo21-Mar-05 21:42
wohoowahoo21-Mar-05 21:42 
GeneralRe: Loading file data into Edit Cntrl boxes Pin
toxcct21-Mar-05 22:38
toxcct21-Mar-05 22:38 
GeneralRe: Loading file data into Edit Cntrl boxes Pin
wohoowahoo22-Mar-05 6:46
wohoowahoo22-Mar-05 6:46 
GeneralRe: Loading file data into Edit Cntrl boxes Pin
toxcct22-Mar-05 21:05
toxcct22-Mar-05 21:05 
QuestionHow to using splitter window in CWnd? Pin
KeyL21-Mar-05 21:32
KeyL21-Mar-05 21:32 
GeneralMFC Programming using SDI Pin
charu12321-Mar-05 20:11
charu12321-Mar-05 20:11 
GeneralRe: MFC Programming using SDI Pin
David Crow22-Mar-05 2:52
David Crow22-Mar-05 2:52 
GeneralRe: MFC Programming using SDI Pin
charu12322-Mar-05 17:48
charu12322-Mar-05 17:48 
I am using the ondraw function. I have a variable called color in the doc class and a function which returns the current colour. I ma calling this function in the ondraw function to get the colour. Below is the code of ondraw function and the doc class..

void CFiguresdiView::OnDraw(CDC* pDC)<br />
{<br />
	CFiguresdiDoc* pDoc = GetDocument();<br />
	ASSERT_VALID(pDoc);<br />
	// TODO: add draw code for native data here<br />
	COLORREF m_nColor = pDoc->GetCurrentColor();<br />
	<br />
	CBrush brush (m_nColor);<br />
            int x1 = 100;<br />
            int y1 = 100;<br />
            int x2 = 300;<br />
            int y2 = 400;<br />
            CRect rect (x1, y1, x2, y2);<br />
            pDC->FillRect (rect, &brush);<br />
}


In the document class i ahve the following code.

<br />
COLORREF CFiguresdiDoc::GetCurrentColor()<br />
{<br />
		return m_nColor;<br />
}<br />
<br />
void CFiguresdiDoc::OnColorsRed() <br />
{	<br />
	m_nColor=RGB (255,0,0);<br />
}<br />
<br />
void CFiguresdiDoc::OnColorsGreen() <br />
{<br />
	m_nColor = RGB(0,255,0);// TODO: Add your command handler code here<br />
}<br />
<br />
void CFiguresdiDoc::OnUpdateColorsGreen(CCmdUI* pCmdUI) <br />
{<br />
	pCmdUI->SetCheck (m_nColor == RGB (0, 255, 0));<br />
}<br />
<br />
<br />
void CFiguresdiDoc::OnUpdateColorsRed(CCmdUI* pCmdUI) <br />
{<br />
	pCmdUI->SetCheck (m_nColor == RGB (0, 255, 255));// TODO: Add your command update UI handler code here<br />
	<br />
}


m_nColor is of type COLORREF.
i AHVE SET THE DEFAULT COLOR AS RED . It is set in the onNew Document function. IF i try doing the same thing on OnButtonDown event of mouse in the client area the color does change.
I am not able to figure out how i can click on the colour in the menu and as soon as i click the menu option the Figure gets redrawn with the chosen colour. I probably need to write some message map but i cant figure out how.


Thanks david
GeneralRe: MFC Programming using SDI Pin
Anonymous23-Mar-05 0:02
Anonymous23-Mar-05 0:02 
GeneralCharts Pin
frankieb21-Mar-05 18:01
frankieb21-Mar-05 18:01 
GeneralRe: Charts Pin
Christian Graus21-Mar-05 18:26
protectorChristian Graus21-Mar-05 18:26 
GeneralRe: Charts Pin
Martijn van Kleef22-Mar-05 1:26
Martijn van Kleef22-Mar-05 1:26 
GeneralRe: Charts Pin
Anonymous23-Mar-05 15:25
Anonymous23-Mar-05 15:25 
GeneralRe: Charts Pin
Martijn van Kleef24-Mar-05 0:11
Martijn van Kleef24-Mar-05 0:11 
GeneralPocket PC 2003 c++ and iostream Pin
CLermen21-Mar-05 16:35
CLermen21-Mar-05 16:35 
GeneralRe: Pocket PC 2003 c++ and iostream Pin
Christian Graus21-Mar-05 18:27
protectorChristian Graus21-Mar-05 18:27 
GeneralDebug Assertion Failed! Pin
cockytrumpet21-Mar-05 14:32
susscockytrumpet21-Mar-05 14:32 
GeneralRe: Debug Assertion Failed! Pin
Christian Graus21-Mar-05 14:58
protectorChristian Graus21-Mar-05 14:58 
GeneralRe: Debug Assertion Failed! Pin
David Crow22-Mar-05 2:57
David Crow22-Mar-05 2:57 
GeneralSystem process Pin
giany00721-Mar-05 11:48
giany00721-Mar-05 11:48 
GeneralRe: System process Pin
Tom Wright21-Mar-05 12:21
Tom Wright21-Mar-05 12:21 
GeneralRe: System process Pin
giany00721-Mar-05 23:10
giany00721-Mar-05 23:10 
GeneralRe: System process Pin
Blake Miller22-Mar-05 5:58
Blake Miller22-Mar-05 5:58 
Generalmfc dll and IWebBrowser2 questions Pin
Spiritofamerica21-Mar-05 10:51
Spiritofamerica21-Mar-05 10:51 
GeneralRe: mfc dll and IWebBrowser2 questions Pin
David Crow21-Mar-05 11:01
David Crow21-Mar-05 11:01 

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.