另外如果你只想画矩形的话,用
BOOL Rectangle( int x1, int y1, int x2, int y2 );BOOL Rectangle( LPCRECT lpRect );
比较好

解决方案 »

  1.   

    LoadBitmap是从已有的资源中获得句柄CreateBitmap可以从包含rgb信息的数组中获得句柄。我现在就是想从rgb数组中获得HBITMAP句柄
      

  2.   

    调试一下看一下这一句中:
    SelectObject(hdcMem,hBitmap);
    中hBitmap是否分配值,还是为空?
      

  3.   

    SelectObject(hdcMem,hBitmap)执行之后,hBitmap的之没有变化,不为空
      

  4.   

    在SelectObject(hdcMem,hBitmap);后面加三句
    for(int i=0;i<48;i++) 
        for(int j=0;j<48;j++)
          SetPixel(hdc,i,j,RGB(r,g,b));
      

  5.   

    这你也想得出来!i fule you!
    还有两个问题:
    1)我原来的程序为什么不行?
    2)怎么加分?我的帖子有人回复之后好像就不能管理了。
      

  6.   

    case WM_CREATE:
              hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;          hBitmap = LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_BITMAP2)) ;          GetObject (hBitmap, sizeof (BITMAP), &bitmap) ;
      

  7.   

    接上面
              cxSource = bitmap.bmWidth ;
              cySource = bitmap.bmHeight ;break;
     case WM_PAINT:       hdc = BeginPaint (hwnd, &ps) ;
              hdcMem = CreateCompatibleDC (hdc) ;
              SelectObject (hdcMem, hBitmap) ;
      SetBkMode(hdc,TRANSPARENT);
    //   GetCursorPos(&Pos);
      BitBlt (hdc,Pos.x, Pos.y, Pos.x+cxSource, cySource+Pos.y, hdcMem,0,0 ,MERGECOPY) ;
    //   FillRect(hdc,&rect,NULL);

              
      DeleteDC (hdcMem) ;
      ReleaseDC(hwnd,hdc);
              EndPaint (hwnd, &ps) ;
      
      break;
      

  8.   

    to 大协作
    现在没有资源文件,只有rgb数组
      

  9.   

    hdc=BeginPaint(hWnd,&ps);
      hdcMem = CreateCompatibleDC(hdc) ;
      SelectObject(hdcMem,hBitmap);
      BitBlt(hdc,20,20,48,48,hdcMem,0,0,SRCCOPY);
      DeleteDC(hdcMem);
      EndPaint(hWnd,&ps); 
    你只是把图象画到屏幕,但是图象还是空的呢。CreateBitmap创建的图象不一定与当前设备兼容,建议用CreateCompatibleBitmap。
      

  10.   

    原来的hdc未写入位图信息,要从非资源文件读入位图,就要用SetPixel写入hdc设备
      

  11.   

    那CreateBitmap最后一个参数是干什么用的?
    HBITMAP CreateBitmap(
        int nWidth, 
        int nHeight, 
        UINT cPlanes, 
        UINT cBitsPerPel, 
        CONST VOID *lpvBits );