我在my111doc.cpp里面实现了一个onopenfile(),功能是把打开的位图放到内存里。然后再my111view.cpp重载了OnPaint()函数,用以显示位图。可是它们之间怎么调用呢?现在是只能把打开的位图放进内存,却不能显示

解决方案 »

  1.   

    OnPaint() 一般不需要自已调用的,只要是界面有刷新了,它都会自动调用,你可用UpdataDate()这个方法,
      

  2.   

    你还要在在onpaint中画出那个图画出来。
      

  3.   


    ....
    Invalidate();
    UpdateWindow();
    ....
      

  4.   

    用“UpdataDate()这个方法”这个方法可能不行。你可以在其它地方用InvalidateRect 或invalidate等函数来刷新(自动调用onpaint)。
      

  5.   

    先在?????Doc.cpp中调用UpdateAllViews(NULL,USER_ON_PAINT);//#define USER_ON_PAINT 2
    再重载view中的OnUpdate,添加:
    switch(lHint)
    {
    case USER_ON_PAINT:
    Invalidate();
    break;
    }
      

  6.   

    InvalidateRect比较高效void InvalidateRect( LPCRECT lpRect, BOOL bErase = TRUE );lpRect
    指向一个CRect对象或RECT结构,其中包含了要被加入更新区域的矩形(客户区坐标)。如果lpRect为NULL,则整个客户区都被加入更新区域。 bErase
    指定更新区域内的背景是否要被擦除。这个函数将给定的客户区矩形加入CWnd更新区域,使该区域无效。无效的矩形与更新区域内的其它区域一起被标记为在发送下一条WM_PAINT消息时需要重画。无效的区域在更新区域内累积,直到发生下一次WM_PAINT调用,这个区域被处理为止,或者直到这个区域被ValidateRect或ValidateRgn成员函数标为有效为止。 bErase参数指定了在处理更新区域的时候是否要擦除更新区域内的背景。如果bErase为TRUE,则当调用BeginPaint函数的时候,将擦除背景。如果bErase为FALSE,则背景保持不变。如果对于更新区域的任何部分bErase为TRUE,则整个区域的背景都会被擦除,而不仅是给定的部分。 当CWnd的更新区域不为空,并且应用程序的窗口消息队列中没有其它消息时,Windows就发送一条WM_PAINT消息。 
      

  7.   

    楼上的解释很详细哦。Using the WM_PAINT Message
    You can use the WM_PAINT message to carry out the drawing necessary for displaying information. Because the system sends WM_PAINT messages to your application when your window must be updated or when you explicitly request an update, you can consolidate the code for drawing in your application's window procedure. You can then use this code whenever your application must draw either new or existing information. The following sections show a variety of ways to use the WM_PAINT message to draw in a window: Drawing in the Client Area 
    Redrawing the Entire Client Area 
    Redrawing in the Update Region 
    Invalidating the Client Area 
    Drawing a Minimized Window 
    Drawing a Custom Window Background 
      

  8.   


    void Cmy111view::OnPaint()
    {
        Cmy111doc* pDoc = (Cmy111doc*)GetDocument();
        ....    CPaintDC dc(this);
        dc.BitBlt(..);}