我用splitterWnd把窗口分成了四分,其中一份为以formview为基类的类。
我想动态的载入图片,但是好像不行,为何?
代码如下:void CMapView::OnShowWindow(BOOL bShow, UINT nStatus) 
{
CFormView::OnShowWindow(bShow, nStatus);

// TODO: Add your message handler code here
CStatic myStatic;
// Create a child bitmap static control.
  myStatic.Create(_T("my static"), 
   WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, CRect(10,10,150,50), 
   this);// If no bitmap is defined for the static control, define the bitmap 
// to the system close bitmap.
if (myStatic.GetBitmap() == NULL)
   myStatic.SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE(IDB_HANYU)) );
}
运行完了图片并没有出现在窗口上,为何?
是不是不应该在OnShowWindow中写这些代码?那应该在什么地方写?(昨晚干到2:00,非常感谢)

解决方案 »

  1.   

    用picture控件或者使用BitBlt把图片自己画上去
      

  2.   

    CDC::BitBlt  
    BOOL BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop );Return ValueNonzero if the function is successful; otherwise 0.ParametersxSpecifies the logical x-coordinate of the upper-left corner of the destination rectangle.ySpecifies the logical y-coordinate of the upper-left corner of the destination rectangle.nWidthSpecifies the width (in logical units) of the destination rectangle and source bitmap.nHeightSpecifies the height (in logical units) of the destination rectangle and source bitmap.pSrcDCPointer to a CDC object that identifies the device context from which the bitmap will be copied. It must be NULL if dwRop specifies a raster operation that does not include a source.xSrcSpecifies the logical x-coordinate of the upper-left corner of the source bitmap.ySrcSpecifies the logical y-coordinate of the upper-left corner of the source bitmap.dwRopSpecifies the raster operation to be performed. Raster-operation codes define how the GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. The following lists raster-operation codes for dwRop and their descriptions: BLACKNESS   Turns all output black.
    DSTINVERT   Inverts the destination bitmap.
    MERGECOPY   Combines the pattern and the source bitmap using the Boolean AND operator.
    MERGEPAINT   Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator.
    NOTSRCCOPY   Copies the inverted source bitmap to the destination.
    NOTSRCERASE   Inverts the result of combining the destination and source bitmaps using the Boolean OR operator.
    PATCOPY   Copies the pattern to the destination bitmap.
    PATINVERT   Combines the destination bitmap with the pattern using the Boolean XOR operator.
    PATPAINT   Combines the inverted source bitmap with the pattern using the Boolean OR operator. Combines the result of this operation with the destination bitmap using the Boolean OR operator.
    SRCAND   Combines pixels of the destination and source bitmaps using the Boolean AND operator.
    SRCCOPY   Copies the source bitmap to the destination bitmap.
    SRCERASE   Inverts the desination bitmap and combines the result with the source bitmap using the Boolean AND operator.
    SRCINVERT   Combines pixels of the destination and source bitmaps using the Boolean XOR operator.
    SRCPAINT   Combines pixels of the destination and source bitmaps using the Boolean OR operator.
    WHITENESS   Turns all output white. 
    For a complete list of raster-operation codes, seeAbout Raster Operation Codes in the Appendices section of the Win32 SDK Programmer’s Reference.ResCopies a bitmap from the source device context to this current device context. The application can align the windows or client areas on byte boundaries to ensure that the BitBlt operations occur on byte-aligned rectangles. (Set the CS_BYTEALIGNWINDOW or CS_BYTEALIGNCLIENT flags when you register the window classes.) BitBlt operations on byte-aligned rectangles are considerably faster than BitBlt operations on rectangles that are not byte aligned. If you want to specify class styles such as byte-alignment for your own device context, you will have to register a window class rather than relying on the Microsoft Foundation classes to do it for you. Use the global function AfxRegisterWndClass.GDI transforms nWidth and nHeight, once by using the destination device context, and once by using the source device context. If the resulting extents do not match, GDI uses the Windows StretchBlt function to compress or stretch the source bitmap as necessary.If destination, source, and pattern bitmaps do not have the same color format, the BitBlt function converts the source and pattern bitmaps to match the destination. The foreground and background colors of the destination bitmap are used in the conversion. When the BitBlt function converts a monochrome bitmap to color, it sets white bits (1) to the background color and black bits (0) to the foreground color. The foreground and background colors of the destination device context are used. To convert color to monochrome, BitBlt sets pixels that match the background color to white and sets all other pixels to black. BitBlt uses the foreground and background colors of the color device context to convert from color to monochrome.Note that not all device contexts support BitBlt. To check whether a given device context does support BitBlt, use the GetDeviceCaps member function and specify the RASTERCAPS index.
      

  3.   

    可以LoadImage()函数动态加载一副图片然后用BitBlt函数或者StretchBlt()函数将他画到FormView中,最好在OnPaint中处理!
      

  4.   

    具体用法参考下面
    http://www.ccw.com.cn/htm/produ/special/vc/jiqiao/01_9_13_20.asp
      

  5.   

    ::LoadBitmap(NULL, MAKEINTRESOURCE(IDB_HANYU)) 
    把得到的值放进类成员或者全局变量中试一下