Click here to Skip to main content
15,914,642 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: display unicode text from into text box from utf database record Pin
Richard MacCutchan22-Jun-10 4:14
mveRichard MacCutchan22-Jun-10 4:14 
GeneralRe: display unicode text from into text box from utf database record Pin
Jayapal Chandran22-Jun-10 5:11
Jayapal Chandran22-Jun-10 5:11 
GeneralRe: display unicode text from into text box from utf database record Pin
Richard MacCutchan22-Jun-10 5:59
mveRichard MacCutchan22-Jun-10 5:59 
QuestionMigration from VC 6.0 to Visual studio 2005 Pin
VC_RYK10-Jun-10 1:20
VC_RYK10-Jun-10 1:20 
AnswerRe: Migration from VC 6.0 to Visual studio 2005 Pin
Chris Losinger10-Jun-10 1:30
professionalChris Losinger10-Jun-10 1:30 
AnswerRe: Migration from VC 6.0 to Visual studio 2005 Pin
David Crow10-Jun-10 2:59
David Crow10-Jun-10 2:59 
AnswerRe: Migration from VC 6.0 to Visual studio 2005 Pin
peterchen10-Jun-10 3:29
peterchen10-Jun-10 3:29 
QuestionCall an .NET CF application with CreateProcess() under WinCE5.0 Pin
stefanu2110-Jun-10 0:54
stefanu2110-Jun-10 0:54 
GeneralMessage Removed Pin
10-Jun-10 0:20
Alex@9C10-Jun-10 0:20 
GeneralRe: Important Points for KT Pin
Cedric Moonen10-Jun-10 1:30
Cedric Moonen10-Jun-10 1:30 
GeneralRe: Important Points for KT Pin
Richard MacCutchan10-Jun-10 2:28
mveRichard MacCutchan10-Jun-10 2:28 
GeneralRe: Important Points for KT Pin
Cedric Moonen10-Jun-10 2:47
Cedric Moonen10-Jun-10 2:47 
GeneralRe: Important Points for KT Pin
LittleYellowBird10-Jun-10 5:22
LittleYellowBird10-Jun-10 5:22 
GeneralRe: Important Points for KT Pin
Cedric Moonen10-Jun-10 8:11
Cedric Moonen10-Jun-10 8:11 
GeneralRe: Important Points for KT Pin
Richard MacCutchan10-Jun-10 5:43
mveRichard MacCutchan10-Jun-10 5:43 
GeneralRe: Important Points for KT Pin
Niklas L11-Jun-10 2:09
Niklas L11-Jun-10 2:09 
GeneralRe: Important Points for KT Pin
Richard MacCutchan11-Jun-10 2:44
mveRichard MacCutchan11-Jun-10 2:44 
GeneralRe: Important Points for KT Pin
Tim Craig10-Jun-10 13:48
Tim Craig10-Jun-10 13:48 
GeneralRe: Important Points for KT Pin
CPallini10-Jun-10 3:00
mveCPallini10-Jun-10 3:00 
QuestionProblem in redrawing Rectangle on "Up Arrow Key Down" in MFC Dialog Based application Pin
Arindam Tewary9-Jun-10 23:55
professionalArindam Tewary9-Jun-10 23:55 
Hi,

I am writing a small program in MFC using Dialog based project.
What I want to achive is : On pressing "Up Arrow Key" I want to redraw a rectangle which was already drawn.( want to draw the rectangle in other point).

Can you please help me what I am doing wrong here.

I am setting a variable "iKeyPressed" to "1" "PreTranslateMessage" method when Up Key is pressed.

BOOL CKeyDownTestDlg::PreTranslateMessage(MSG* pMsg)
{
	// TODO: Add your specialized code here and/or call the base class
    iKeyPressed = 0;
	if (pMsg->message == WM_KEYDOWN)
	{
		if(pMsg->wParam==VK_UP)
		{
			iKeyPressed = 1;
			CKeyDownTestDlg::OnPaint();
		 //::AfxMessageBox(_T("Inside"));              
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}


Then in OnPaint() method I am checking the value of "iKeyPressed". If that is "1", then I intend to "Redraw" (erasing out the previously drawn rectangle)rectangle which was drawn earlier.

void CKeyDownTestDlg::OnPaint()
{
	if (IsIconic())
	{
		//These code is not executed.
	}
	else
	{
		char c[10];
		
		CPaintDC dc(this); // device context for painting
		CString MFCString; 
		MFCString = c;
		if(iKeyPressed==0)
		{
			dc.Rectangle(5,5,100,20);
			AfxMessageBox(_T("iKeyPressed = 0"));     
			/*dc.SelectObject(old_brush);*/
		}

		if(iKeyPressed==1)
		{
			CPaintDC dc(this); // device context for painting
			AfxMessageBox(_T("iKeyPressed = 1"));      
			dc.Rectangle(5,5,20,100);			
		}
		CDialog::OnPaint();
	}
}

Interestingly, while executing I could see Message "iKeyPressed = 1".

Any help is appreciated.
Thanks,
Arindam D Tewary

AnswerRe: Problem in redrawing Rectangle on "Up Arrow Key Down" in MFC Dialog Based application Pin
Aescleal10-Jun-10 0:14
Aescleal10-Jun-10 0:14 
AnswerRe: Problem in redrawing Rectangle on "Up Arrow Key Down" in MFC Dialog Based application Pin
CPallini10-Jun-10 0:26
mveCPallini10-Jun-10 0:26 
GeneralRe: Problem in redrawing Rectangle on "Up Arrow Key Down" in MFC Dialog Based application Pin
Arindam Tewary10-Jun-10 0:38
professionalArindam Tewary10-Jun-10 0:38 
GeneralRe: Problem in redrawing Rectangle on "Up Arrow Key Down" in MFC Dialog Based application Pin
CPallini10-Jun-10 1:02
mveCPallini10-Jun-10 1:02 
Questioncatching new Pin
Sakhalean9-Jun-10 22:56
Sakhalean9-Jun-10 22:56 

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.