当前位置:编程学习 > VC++ >>

VC Picture Control显示BMP图片

VC对话框初始时,Picture Control显示BMP图片:
[cpp] 
BOOL CLoginDog::OnInitDialog()  
{  
    CDialog::OnInitDialog();  
  
    HBITMAP hBitmap;    //添加登陆窗口中的图片 
    //关联图片ID  www.zzzyk.com
    hBitmap =(HBITMAP)LoadImage(AfxGetInstanceHandle(),  
                                MAKEINTRESOURCE(IDB_BITMAP_LOGIN_PIC),  
                                IMAGE_BITMAP,0,0,  
                                LR_LOADMAP3DCOLORS);  
 
    CStatic *pStatic=(CStatic *)GetDlgItem(IDC_STATIC_PIC); //获得指向静态控件的指针 
    pStatic->ModifyStyle(0xF,SS_BITMAP|SS_CENTERIMAGE);  //设置静态控件的样式,使其位图居中  
    pStatic->SetBitmap(hBitmap);     //设置静态控件显示位图 
 
    return TRUE;  
}  
SetBitmap定义如下:
[cpp]
// uBmpResource:图片ID; uCtrlResource: Picture控件ID  
void SetBitmap(UINT uBmpResource, UINT uCtrlResource)  
{  
    HBITMAP hBitmap;  
    CStatic *pStatic = (CStatic *)GetDlgItem(uCtrlResource);  
    hBitmap = (HBITMAP)LoadImage(  
        AfxGetInstanceHandle(),  
        MAKEINTRESOURCE(uBmpResource),  
        IMAGE_BITMAP,  
        0,  
        0,  
        LR_LOADMAP3DCOLORS);  
    pStatic->ModifyStyle(0xF, SS_BITMAP);  
    pStatic->SetBitmap(hBitmap);  
补充:软件开发 , Vc ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,