VC中一些控制項的小技巧

2021-09-05 23:52:02 字數 1722 閱讀 8704

1.讓list control有check box

用setextendedstyle方法可以設定,看**:

(clistctrl m_listctrl;)

dword dwstyle = m_listctrl.getstyle();

dwstyle |= lvs_ex_checkboxes;

m_listctrl.setextendedstyle(dwstyle);

2.讓list box有check box

首先,宣告control變數的時候用cchecklistbox代替clistbox。

然後,將list box的has strings屬性改為true;把ower draw屬性改為fixed。

3.spin control與edit control的繫結

首先,要讓spin control的tap order緊跟著edit control(就是說,spin control的tap order是edit control的tap order加1)。

然後,設定spin control的auto buddy和set buddy integer屬性為true。

4.可以設定背景和文字顏色的static控制項

從cstatic類繼承乙個自己的static類,相應wm_ctlcolor訊息。下面是**:

.h檔案:

class clxstatic : public cstatic ;

.cpp檔案:

implement_dynamic(clxstatic, cstatic)

clxstatic::clxstatic()

clxstatic::~clxstatic()

void clxstatic::setbackcolor(colorref clrback)

void clxstatic::settextcolor(colorref clrtext)

begin_message_map(clxstatic, cstatic)

on_wm_ctlcolor_reflect()

end_message_map()

hbrush clxstatic::ctlcolor(cdc* pdc, uint /*nctlcolor*/)

5.在static控制項中顯示bmp

首先,給static控制項新增乙個control變數(id要改了以後才能新增變數,也就是說id不能為idc_static),本例為m_statictest。

然後,用modifystyle函式修改static控制項的style,讓它可以顯示:

m_statictest.modifystyle(0, ss_bitmap | ss_centerimage);

最後,就是load檔案顯示出來:

crect rect;

m_statictest.getwindowrect(&rect);

//  hbitmap hbmp = (hbitmap)::loadimage(0, _t("d:\test.bmp"), image_bitmap, 0, 0, lr_loadfromfile);

hbitmap hbmp = (hbitmap)::loadimage(0, _t("d:\test.bmp"), image_bitmap, rect.width(), rect.height(), lr_loadfromfile);

m_statictest.setbitmap(hbmp);

deleteobject(hbmp);

Qt Creator中一些常用小技巧(總結)

參考部落格 以下 摘抄以上大神部落格 1 注釋 常用雙斜槓 是單行注釋,可以多行注釋,其實在qt creator裡面還有一種注釋方式也非常好用,三個斜槓 回車後會自動建立新的一行注釋來,比較方便 2 函式說明 需要寫注釋說明,那這時候可以快速的生成乙個函式說明的注釋格式,在函式名的上一行,輸入 然後...

PB中一些技巧

取資料視窗中可列新的表名。string ls table ls table dw 1.describe datawindow.updatetable.table 22.取資料視窗物件中列的名稱及型別 string ls cols,ls types intli count,i li count int...

PB中一些技巧

取資料視窗中可列新的表名。string ls table ls table dw 1.describe datawindow.updatetable.table 22.取資料視窗物件中列的名稱及型別 string ls cols,ls types intli count,i li count int...