WIN32 pictrue control 显示图片(在网上搜的都是MFC,但win32 和MFC本是同源,故可参考)

打开选择显示画面:

    int cx,cy;
    RECT rect,rc;
    HDC hdc;
    char szFileName[MAX_PATH]={0};
    OPENFILENAME  OpenFileName = {0};
    OpenFileName.lStructSize =sizeof(OPENFILENAME);
    OpenFileName.nMaxFile = MAX_PATH;
    OpenFileName.lpstrFilter = "图片(*.bmp)\0*.bmp\0图片(*.jpg)\0*.jpg\0";
    OpenFileName.lpstrFile = szFileName;
    OpenFileName.lpstrInitialDir ="D:\\SaveZklsBmp\0";
    OpenFileName.nFilterIndex =1;
    OpenFileName.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ALLOWMULTISELECT;
    if(::GetOpenFileName(&OpenFileName))
    {
        MessageBox(NULL,szFileName,"测试",MB_OK);
        //HBITMAP hbmp = (HBITMAP)LoadImage(NULL,szFileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
        CImage image;
        image.Load(szFileName);
        cx = image.GetWidth();
        cy = image.GetHeight();
        HWND hwdn = GetDlgItem(m_hWin,IDC_STATPICTRUE);//m_hwin 主窗口句柄
        GetWindowRect(hwdn,&rect);
        hdc = GetDC(hwdn);
        GetClientRect(hwdn,&rc);
        image.StretchBlt(hdc,rc,SRCCOPY);
        ReleaseDC(hwdn,hdc);
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值