标题:求这段代码封装成类!
只看楼主
qiaokangjun
Rank: 2
等 级:论坛游民
帖 子:4
专家分:25
注 册:2012-3-5
结帖率:0
已结贴  问题点数:10 回复次数:2 
求这段代码封装成类!
////////按钮图标
    HBITMAP hBmp1=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP2));   
    ((CButton *)GetDlgItem(IDC_BUTTON1))->SetBitmap(hBmp1);

    HBITMAP hBmp2=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP3));   
    ((CButton *)GetDlgItem(IDC_BUTTON2))->SetBitmap(hBmp2);

    HBITMAP hBmp3=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP4));   
    ((CButton *)GetDlgItem(IDC_BUTTON3))->SetBitmap(hBmp3);

    HBITMAP hBmp4=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP5));   
    ((CButton *)GetDlgItem(IDC_BUTTON4))->SetBitmap(hBmp4);

    HBITMAP hBmp5=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP6));   
    ((CButton *)GetDlgItem(IDC_BUTTON5))->SetBitmap(hBmp5);

    HBITMAP hBmp6=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP7));   
    ((CButton *)GetDlgItem(IDC_BUTTON6))->SetBitmap(hBmp6);

    HBITMAP hBmp7=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP8));   
    ((CButton *)GetDlgItem(IDC_BUTTON7))->SetBitmap(hBmp7);

    HBITMAP hBmp8=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP9));   
    ((CButton *)GetDlgItem(IDC_BUTTON8))->SetBitmap(hBmp8);   

    HBITMAP hBmp9=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP10));   
    ((CButton *)GetDlgItem(IDC_BUTTON9))->SetBitmap(hBmp9);

    HBITMAP hBmp10=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP11));   
    ((CButton *)GetDlgItem(IDC_BUTTON10))->SetBitmap(hBmp10);

    HBITMAP hBmp11=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP12));   
    ((CButton *)GetDlgItem(IDC_BUTTON11))->SetBitmap(hBmp11);

    HBITMAP hBmp12=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP13));   
    ((CButton *)GetDlgItem(IDC_BUTTON12))->SetBitmap(hBmp12);

    HBITMAP hBmp13=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP14));   
    ((CButton *)GetDlgItem(IDC_BUTTON13))->SetBitmap(hBmp13);

    HBITMAP hBmp14=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP15));   
    ((CButton *)GetDlgItem(IDC_BUTTON14))->SetBitmap(hBmp14);

    HBITMAP hBmp15=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP16));   
    ((CButton *)GetDlgItem(IDC_BUTTON15))->SetBitmap(hBmp15);

    HBITMAP hBmp16=::LoadBitmap(AfxGetInstanceHandle(),   
    MAKEINTRESOURCE(IDB_BITMAP17));   
    ((CButton *)GetDlgItem(IDC_BUTTON16))->SetBitmap(hBmp16);
搜索更多相关主题的帖子: 封装 
2012-12-07 19:40
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6809
专家分:42393
注 册:2010-12-16
得分:10 
封装成类?
不解,你是想弄成函数的吧

我行我乐
我的博客:
http://blog.yuccn. net
2012-12-07 21:07
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6809
专家分:42393
注 册:2010-12-16
得分:0 
UINT uMap[][2] =
{
    {IDB_BITMAP2, IDC_BUTTON1},  
    {IDB_BITMAP3, IDC_BUTTON2},
    {IDB_BITMAP4, IDC_BUTTON3},
    {IDB_BITMAP5, IDC_BUTTON4},
    {IDB_BITMAP6, IDC_BUTTON5},
    {IDB_BITMAP7, IDC_BUTTON6},
    {IDB_BITMAP8, IDC_BUTTON7},
    {IDB_BITMAP9, IDC_BUTTON8},
    {IDB_BITMAP10, IDC_BUTTON9},
    {IDB_BITMAP11, IDC_BUTTON10},
    {IDB_BITMAP12, IDC_BUTTON11},
    {IDB_BITMAP13, IDC_BUTTON12},
    {IDB_BITMAP13, IDC_BUTTON13},
    {IDB_BITMAP15, IDC_BUTTON14},
    {IDB_BITMAP16, IDC_BUTTON15},
    {IDB_BITMAP17, IDC_BUTTON16},
};

void LoadMap()
{
    for (int i = 0; i < sizeof(uMap) / sizeof(uMap[0]);i++) {
        HBITMAP hBmp=::LoadBitmap(AfxGetInstanceHandle(),  MAKEINTRESOURCE(uMap[i].[0]));   
        ((CButton *)GetDlgItem(uMap[i].[1]))->SetBitmap(hBmp);

    }
}

[ 本帖最后由 yuccn 于 2012-12-7 21:18 编辑 ]

我行我乐
我的博客:
http://blog.yuccn. net
2012-12-07 21:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-390066-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019666 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved