using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.linq;
using system.text;
using system.windows.forms;
using system.runtime.interopservices;
namespace test
return prams;}}
///
/// 獲得當前程序,以便重繪控制項
///
///
///
[system.runtime.interopservices.dllimport("user32.dll")]
static extern intptr getwindowdc(intptr hwnd);
[system.runtime.interopservices.dllimport("user32.dll")]
static extern int releasedc(intptr hwnd, intptr hdc);
///
/// 邊框顏色
///
private color _bordercolor = color.black;
public mytextbox()
//設定rect訊息
private const int em_setrect = 179;
//獲取rect訊息
private const int em_getrect = 178;
//貼上訊息
private const int wm_paste = 0x0302;
///
/// 窗體處理訊息主函式 處理貼上及繪製訊息
///
///
[dllimport("user32.dll", entrypoint = "sendmessagea")]
private static extern int sendmessage(intptr hwnd, int wmsg, intptr wparam, string lparam);
[dllimport("user32.dll", entrypoint = "sendmessagea")]
private static extern int sendmessage(intptr hwnd, int wmsg, intptr wparam, ref rectangle lparam);
protected override void onenter(eventargs e)
///
/// 設定文字顯示布局位置
///
public void settextdisplayout()
///
/// 是否允許有回車
///
[categoryattribute("設定"), displayname("允許回車"), descriptionattribute("配合內邊使用")]
public bool allowreturn
private padding _textpadding = new padding(1);
///
/// text padding值 當允許多行和禁止回車時,paddin有效
///
[categoryattribute("設定"), displayname("內邊距"), descriptionattribute(" 當允許多行和禁止回車時,paddin有效")]
public padding textpadding set }
///
/// 尺寸變化時重新設定字型的顯示位置居中
///
///
protected override void onsizechanged(eventargs e)
///
/// 窗體處理訊息主函式 處理貼上及繪製訊息
///
///
protected override void wndproc(ref system.windows.forms.message m)
system.drawing.pen pen = new pen(this._bordercolor, 1);
pen.color = _bordercolor;
//繪製邊框
system.drawing.graphics g = graphics.fromhdc(hdc);
g.smoothingmode = system.drawing.drawing2d.smoothingmode.antialias;
g.drawrectangle(pen, 0, 0, this.width - 1, this.height - 1);
pen.dispose();
//返回結果
m.result = intptr.zero;
//釋放
releasedc(m.hwnd, hdc);
}string str = "";
int i = 0;
if (m.msg == 0x0204)
i++;
if (!allowreturn
&& m.msg == wm_paste
&& system.windows.forms.clipboard.containstext())}}
}
自定義控制項樣式
分三個層次 drawable selector style drawable可以是一張 顏色 xml檔案畫的向量圖。xml向量圖根節點是shape,屬性用來指定形狀,子標籤有solid 填充 corners 圓角 gradient 漸變 padding 間隔 size 大小 stroke 描邊 se...
可自定義補全演算法的TextBox控制項
net framework中system.windows.froms.textbox有補全功能,但只有有限的幾種模式。如果想輸入拼音,補全列表提示漢字,這是做不到的。於是,你可以使用我的customizablecompletetextbox。該控制項的乙個重要成員是completing事件。你可以訂...
可自定義補全演算法的TextBox控制項
net framework中system.windows.froms.textbox有補全功能,但只有有限的幾種模式。如果想輸入拼音,補全列表提示漢字,這是做不到的。於是,你可以使用我的customizablecompletetextbox。該控制項的乙個重要成員是completing事件。你可以訂...