建立拖動image

來源:互聯網
上載者:User
//建立拖動image
cimagelist *cmylist::makedragimage(int item)
{
cimagelist *ilist = new cimagelist; // create a new image-list

crect rc;
getitemrect(item, &rc, lvir_bounds); // get the complete row
rc.offsetrect(-rc.left, -rc.top); // make it (0, 0)-aligned
rc.right = getcolumnwidth(0); // just want the 1st columne

ilist->create(rc.width(), rc.height(), ilc_color24 | ilc_mask, 1, 1);

cdc *pdc = getdc(); // get device-context

if(pdc) {

// create a memory-dc for the image and attach a bitmap to it

cdc drawdc;
drawdc.createcompatibledc(pdc);
cbitmap drawmap;
drawmap.createcompatiblebitmap(pdc, rc.width(), rc.height());
cbitmap *old = drawdc.selectobject(&drawmap);

// erase the background../di2001.jpgd draw the item into the device context

drawdc.fillsolidrect(rc, getsyscolor(color_window));

drawitemstruct dis;
dis.hdc = drawdc.m_hdc; // device-context to draw in
dis.rcitem = rc; // the item rectangle
dis.itemid = item; // the item's id
dis.itemstate = ods_default; // or ods_selected
drawitem(&dis); // draw item into the dc

drawdc.selectobject(old); // switch back to old bitmap

// create a memory-dc for the mask and attach a bitmap to it. to make
// the bitmap just one bit depth, we make it compatible to the memory-
// dc instead of the screen-dc as above

cdc maskdc;
maskdc.createcompatibledc(pdc);
cbitmap maskmap;
maskmap.createcompatiblebitmap(&maskdc, rc.width(), rc.height());
old = maskdc.selectobject(&maskmap);

// erase the background../di2001.jpgd draw the item into the device context

maskdc.fillsolidrect(rc, getsyscolor(color_window));

dis.hdc = maskdc.m_hdc; // device-context to draw in
dis.rcitem = rc; // the item rectangle
dis.itemid = item; // the item's id
dis.itemstate = ods_default; // or ods_selected
drawitem(&dis); // draw into the dc

maskdc.selectobject(old); // switch back to old bitmap

// add the image (and mask) to the image-list

ilist->add(&drawmap, &maskmap);
releasedc(pdc);
}

return ilist;
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.