Click here to Skip to main content
15,881,248 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Syncing the files Pin
David Crow21-Feb-06 7:13
David Crow21-Feb-06 7:13 
GeneralRe: Syncing the files Pin
cuteee21-Feb-06 10:47
cuteee21-Feb-06 10:47 
QuestionRe: Syncing the files Pin
David Crow22-Feb-06 2:48
David Crow22-Feb-06 2:48 
QuestionRe: Syncing the files Pin
cuteee22-Feb-06 6:49
cuteee22-Feb-06 6:49 
QuestionRe: Syncing the files Pin
David Crow22-Feb-06 7:31
David Crow22-Feb-06 7:31 
QuestionRe: Syncing the files Pin
cuteee22-Feb-06 7:34
cuteee22-Feb-06 7:34 
AnswerRe: Syncing the files Pin
David Crow22-Feb-06 7:41
David Crow22-Feb-06 7:41 
QuestionDrawings disappear !!! Pin
llp00na21-Feb-06 6:17
llp00na21-Feb-06 6:17 
Dear all;

I am having this weird problem where I am drawing ellipses but they disppear if i resize the dialog box or move the mouse over the shapes.

I know that this problem is related to OnPaint(). Now that i have tried to call Invalidate() and UpdateWindow() after the drawings, I get a blank screen with no drawings. And because the shapes are only drawn whenever I press a specific button, I kind of see the drawings but they quickly disappear.

Here is some code to give u insights:

int CTestDlg::buttonClicked(void)
{
CClientDC dc(this);
drawShapes(dc);
drawings = TRUE;
Invalidate(TRUE);
//UpdateWindow();

}

void CTestDlg::drawShapes(CDC& cd)
{
for(int index = 0; index < 20, index ++ ){
xCentre = getRandom(0, 1000);
yCentre = getRandom(0, 700);
cd.Ellipse(xCentre + 20, yCentre + 17, xCentre - 20, yCentre - 17);
cd.TextOut(xCentre -10, yCentre-10, "A test");
}
// getRandom () is a method which returns a random number
// that is greater than 0 and smaller than 1000 for x and 700 for y
}


void CTestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<wparam>(dc.GetSafeHdc()), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);

if(drawings == TRUE){
drawShapes(dc);
}
}
else
{
CDialog::OnPaint();
}
}

Now can someone please tell me whats going wrong with my application ??

Thank you

llp00na

-- modified at 12:18 Tuesday 21st February, 2006
AnswerRe: Drawings disappear !!! Pin
Jim Crafton21-Feb-06 6:31
Jim Crafton21-Feb-06 6:31 
GeneralRe: Drawings disappear !!! Pin
llp00na21-Feb-06 7:05
llp00na21-Feb-06 7:05 
AnswerRe: Drawings disappear !!! Pin
David Crow21-Feb-06 7:14
David Crow21-Feb-06 7:14 
GeneralRe: Drawings disappear !!! Pin
llp00na21-Feb-06 7:20
llp00na21-Feb-06 7:20 
GeneralRe: Drawings disappear !!! Pin
David Crow21-Feb-06 9:04
David Crow21-Feb-06 9:04 
GeneralRe: Drawings disappear !!! Pin
llp00na22-Feb-06 2:05
llp00na22-Feb-06 2:05 
GeneralRe: Drawings disappear !!! Pin
Stephen Hewitt21-Feb-06 11:24
Stephen Hewitt21-Feb-06 11:24 
GeneralRe: Drawings disappear !!! Pin
Owner drawn21-Feb-06 16:46
Owner drawn21-Feb-06 16:46 
GeneralRe: Drawings disappear !!! Pin
David Crow22-Feb-06 2:43
David Crow22-Feb-06 2:43 
GeneralRe: Drawings disappear !!! Pin
Stephen Hewitt22-Feb-06 11:19
Stephen Hewitt22-Feb-06 11:19 
AnswerRe: Drawings disappear !!! partially solved Pin
llp00na21-Feb-06 7:34
llp00na21-Feb-06 7:34 
AnswerRe: Drawings disappear !!! Pin
Michael Dunn21-Feb-06 8:33
sitebuilderMichael Dunn21-Feb-06 8:33 
GeneralRe: Drawings disappear !!! Pin
llp00na21-Feb-06 8:39
llp00na21-Feb-06 8:39 
GeneralRe: Drawings disappear !!! Pin
Michael Dunn21-Feb-06 9:15
sitebuilderMichael Dunn21-Feb-06 9:15 
Questionsending mail in vc++ Pin
renuchandran21-Feb-06 6:10
renuchandran21-Feb-06 6:10 
AnswerRe: sending mail in vc++ Pin
David Crow21-Feb-06 6:14
David Crow21-Feb-06 6:14 
AnswerRe: sending mail in vc++ Pin
ThatsAlok22-Feb-06 3:11
ThatsAlok22-Feb-06 3: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.