C 開發技巧

2022-05-06 06:27:07 字數 1248 閱讀 3347

1、時間長度的計算 timespan類。   

例如:timespan span = datetime1 - datetime2   方便啊

2、從類(class)返回乙個system.type型別,用typeof關鍵字

3、從乙個物件例項(object)返回乙個system.type型別,用gettype方法

4、判斷是否處於設計狀態:designmode屬性

5、根據guid建立物件例項

system.guid pguid = new guid(guid);

system.type objectcustorm = type.gettypefromclsid(pguid);

object obj = activator.createinstance(objectcustorm);

6、gdi+不支援xor繪製模式的近似解決方法: controlpaint.drawreversibleframe、controlpaint.drawreversibleline方法

7、獲取enum型別中的所有列舉值:  enum.getnames方法

將字串轉換成列舉值  enum.parse方法

8、label放在上時,使label透明 piclogo.controls.add(lblstatus); lblstatus.backcolor = color.transparent;

9、呼叫幫助檔案

開啟幫助檔案 help.showhelp(this,@"c:/windows/help/mspaint.chm");

開啟幫助檔案,並跳轉到指定的主題 help.showhelp(this,@"c:/windows/help/mspaint.chm","paint_lines.htm");

開啟幫助檔案,並轉到「索引」選項卡 help.showhelpindex(this,@"c:/windows/help/mspaint.chm","paint_lines.htm");

在螢幕上顯示一條浮動的幫助資訊 help.showpopup(this,"這裡是幫助資訊",new point(100,100));

例如,兩個系統可能會共用登入資訊,登入乙個系統後,再啟動另乙個系統時,不需要重新登入。

先定義乙個在應用程式之間傳遞的資料的類,該類必須從marshalbyrefobject繼承:

*  from table1 minux truncate table table1; insert into table1 select * from table_new;

C 開發小技巧總結

1.乙個應用程式只能被使用者開啟一次 2.乙個框架視窗下只開啟乙個子視窗 3.彈出式視窗顯示漸變效果 在頁面上新增乙個timer控制項fadetimer,interval設為50 類的例項變數為 private m showing true 在form load中寫 opacity 0.0 acti...

C 開發小技巧之筆記

一 vc2008如何將lib檔案引入 lib引用有兩種方法 1.pragma comment lib,opengl32.lib 2.選擇project xx properties.linker input additional dependences,在其中加入lib檔名即可。注意要放到工程目錄下。...

C 多執行緒開發技巧 2

看個打破保護原則的例子 include include static dword winapi mythread lpvoidlpparam static int num 20 int main int argc,char argv handlehthread 4 inti for i 0 i 4 ...