RichEdit 增加 行號和 位置Pointer

2021-10-06 01:45:25 字數 1775 閱讀 6586

照此 新增鏈結描述 部落格上**:

發現有幾個問題

1.行號和行數不一定能夠對齊.

繪製文字時候的有可能出現偏差,所以造成行號和行數無法對齊。

2.當richedit存在滾動時,重繪速度會很慢.

行號是整頁全部都繪製,修改為可見部分的繪製,其他部分當前不繪製。

3.使用時間長了之後,會發現行號會消失,原因是 hdccpb = createcompatibledc(hdcedit) 失敗.

在繪製行號底色使用了cbrush ,但是結束後沒有deleteobject,猜測可能造成釋放 hdc hdccpb hbitmap hdcbmp 失敗!

//此處為繪製行號的**

int

getmaxlinenumber

(hwnd hedit, hdc hdc)

void

showlinenum

(hwnd hedit)

//將已"畫好"的點陣圖真正"貼"到richedit中

bitblt

(hdcedit,0,

0, _def_line_wide, clientheight, hdccpb,0,

0, srccopy)

;//::restoredc(hdccpb, -1);

font.

deleteobject()

; newbrush.

deleteobject()

;::releasedc

(hedit, hdcedit)

;selectobject

(hdccpb, old_hbmp);::

deleteobject

(hdcbmp);::

deletedc

(hdccpb)

;}

//此處為位置pointer,以及修改pointer和跟隨 的**

void

showpositon

(hwnd hedit,

int iscriptposition)

//將已"畫好"的點陣圖真正"貼"到richedit中

bitblt

(hdcedit, _def_line_wide,

0, _def_pos_wide, clientheight, hdccpb,0,

0, srccopy);::

destroyicon

(hicon)

;//::restoredc(hdccpb, -1);

newbrush.

deleteobject()

;::releasedc

(hedit, hdcedit)

;selectobject

(hdccpb, old_hbmp);::

deleteobject

(hdcbmp);::

deletedc

(hdccpb);}

int clinericheditctrl::

getscirptposition()

void clinericheditctrl::

setscirptposition

(int ipos)

void clinericheditctrl::

__displayscirpitposition

(bool bmod)

int clinericheditctrl::

getpositontext

(cstring & cstext)

MySQL使用變數新增行號 分組新增行號

drop table ifexists computer stu create table computer stu id int 11 notnull name varchar 20 default null score float default null primary key id engi...

DataGridView新增行號

在datagridview控制項中的 rowpostpaint事件中 vb.net原始碼 private sub dgvrealdatacar rowpostpaint byval sender as system.object,byval e as system.windows.forms.dat...

向表前加行號

gridview沒有自動加行號的功能,記錄需要行號的話,可以在模板列中使用 container.dataitemindex 1 repeater container.itemindex 1 資料庫查詢序號 rownumber select rownumber over order by bookid...