We help IT Professionals succeed at work.

OnPaint()

podoboq
podoboq asked
on
Medium Priority
1,355 Views
Last Modified: 2013-11-20
okay, what i want is a constantly updated window within my Dialog. i have a suspicion that that window will not be intialized with, say it, a pixel, RIGHT after the program's startup. it looks like WM_PAINT isn't posted after OnInitDialog...

BOOL SomeDlg::OnInitDialog()
{      ...
     win= new CWnd(this);
     win->Create(0,0,WS_CHILD|WS_VISIBLE,CRect(0,0,10,10), this,0);
     return TRUE;  
}

void SomeDlg::OnPaint()
{
     if (IsIconic()) { ... }
     else
     {    
          win->GetDC()->SetPixel(1, 1, RGB(0,0,0));
          CDialog::OnPaint();

     }
}


Comment
Watch Question

Commented:
hi there, there is a site describing the SetPixel Function On MFC :
goto

http://www.codeproject.com/dialog/gribble1.asp

It has a full describtion about the function and the CWND it's also a very good site, as you'll see.

Author

Commented:
well, never mind the pixel. i want to have some graph operations in onpaint
does your graph operation needs to be updated when you want it only, or you need your program to constantly update it?
   if u need update when you need it only, use a function to do so instead to putting in OnPaint()

like

void CSomeDlg::draw_line()
{
     HDC hdc;
     hdc=::GetDC(m_hWnd );
     LineTo(hdc,100,100);   //draw a line, and many gdi
                               //function can be put here
     ::ReleaseDC (m_hWnd,hdc);
}

even if u want constant update in onpaint, the above sample easily modified into one
by having the gdi function
  LineTo, SetPixel.........etc, u can do graphing

anyway, there are those graph controls which have been developed by others.
   if you don't really need to reinvent the wheel, go to www.codeproject.com to download one of those example code

Author

Commented:
okay, take the ****ing points. nobody wants them however.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.