如题

解决方案 »

  1.   

    代码多的是,我说一下原理
    获取BMP大小,用CDC类中的API判断获取的点是不是透明的
    再SETWINDOWSRGN一下!
      

  2.   

    重载OnEraseBkgnd(HDC hdc)来绘制图片!
      

  3.   

    获取这个不规则区域的最大矩形外框。然后将图片显示到这个矩形中,显示时,设置CDC的裁剪区域为这个不规则区域即可。SetClipRgn(pRgn);
      

  4.   

    SetWindowRgnSee Also
    GetLastError, GetWindowRgnRequirements
    Runs on Versions Defined in Include Link to 
    Windows CE OS 2.12 and later Winuser.h   Winmgr.lib 
    This function sets the window region of a window. The window region determines the area within the window where the system permits drawing. The system does not display any portion of a window that lies outside of the window region int SetWindowRgn(
    HWND hWnd, 
    HRGN hRgn, 
    BOOL bRedraw
    );
      

  5.   

    刚好机子上有代码,虽然是汇编,不过应该没问题。
    ;设置窗口大小
    invoke GetObject, g_hbmBackground, sizeof BITMAP, addr bm
    invoke GetWindowRect, hWnd, addr rcWindow
    invoke MoveWindow, hWnd, rcWindow.left, rcWindow.top, bm.bmWidth, bm.bmHeight, TRUE ;设置不规则性
    invoke GetDC, hWnd
    mov hdc, eax
    invoke CreateCompatibleDC, hdc
    mov hmemdc, eax
    invoke SelectObject, hmemdc, g_hbmBackground
    invoke GetPixel, hmemdc, 0, 0
    mov colMask, eax
    mov x, 0
    mov y, 0
    invoke CreateRectRgn, 0, 0, bm.bmWidth, bm.bmHeight
    mov rgnWnd, eax .while TRUE
    .while TRUE
    invoke GetPixel, hmemdc, x, y
    .if colMask == eax
    mov ebx, x
    inc ebx
    mov edx, y
    inc edx
    invoke CreateRectRgn, x, y, ebx, edx
    mov rgnTmp, eax
    invoke CombineRgn, rgnWnd, rgnWnd, rgnTmp, RGN_XOR
    invoke DeleteObject, rgnTmp
    .endif
    inc x
    mov eax, x
    .if eax >= bm.bmWidth
    mov x, 0
    .break
    .endif
    .endw
    inc y
    mov eax, y
    .break .if eax >= bm.bmHeight
    .endw
    invoke SetWindowRgn, hWnd, rgnWnd, TRUE