①mfc組合框(下拉列表)自動排序了,我要按輸入資料時的順序排列怎麼辦?
把屬性裡面sort改為false
②cstring 與 string 間的轉換
cstring 轉 string
string 轉 cstringcstring cstrtest =_t(
"test");
string strtest;
string =
ct2a
(cstrtest.
getstring()
);
cstring轉intstring strtest=
"test"
;cstring cstrtest;
cstrtest=
ca2t
(strtest.
c_str()
);
③mfc對話方塊button控制項置灰cstring strnum
("100");
int num;
//ansi
num =
atoi
(strnum)
; num =
_ttoi
(strnum)
;//unicode
num =
atoi
(ct2a
(strnum.
getbuff()
));num =
_ttoi
(strnum)
;使用 _ttoi 可以適用於 ansi和unicode兩種版本。
④mfc改變edit控制項字型的大小getdlgitem
(idc_***)
->
enablewindow
(false)
//idc_***為你想變灰的按鈕的id
首先,為edit控制項繫結乙個控制變數:
m_edit;
然後,在對話方塊類中新增乙個成員變數:注:此處必須是成員變數,不能是區域性變數。
cfont m_ofont;
3、最後就是,利用setfont函式修改字型了,主要有兩種方式,可以在對話方塊的初始化函式oninitdialog中實現:
⑤mfc 的編輯框中怎麼顯示系統的當前時間m_ofont.
createpointfont
(180,_t
("隸書"))
;m_edit.
setfont
(&m_ofont)
;
⑥cfile類寫入txt,txt之前的內容被覆蓋的問題在oninitdialog
()中新增**:
cstring strtime;
ctime tm;
tm=ctime::
getcurrenttime()
;//獲取當前系統時間
strtime=tm.
format
("%y年%m月%d日 %x");
//格式du化系統時間。即使系統時 間按照format中設定的格式顯dao示
setdlgitemtext
(idc_time,strtime)
;//初始化編輯框顯示
settimer(1
,1000
,null);
//啟動定時器給對話方塊新增wm_timer訊息處理函式,新增如下**:
cstring strtime;
ctime tm;
tm=ctime::
getcurrenttime()
;
strtime=tm.
format
("%y-%m-%d %h:%m:%s");
setdlgitemtext
(idc_time,strtime)
;//顯示系統時間
⑦mfc按下按鈕改變按鈕的文字以及獲取按鈕文字首先,不能用cfile::modecreate模式,應當用cfile::modewrite模式
然後,每次開啟檔案要使用seektoend函式
cstdiofile file;
file.
open
("c:\\a.txt"
,cfile::modewrite)
;file.
seektoend()
;file.
writestring
("hello world!");
file.
close()
;下面這個方法我沒試過
char szbuf=
"123"
;cfile file
("c:\\file.txt"
, cfile::modecreate|cfile::modereadwrite|cfile::modenotruncate)
;file.
seektoend()
;file.
write
(szbuf,
lstrlen
(szbuf));
file.
close()
;
(1)獲取按鈕的文字具體示例如下:
//用於緩衝的臨時cstring
cstringtempstr;
//獲取id_simpause按鈕的文字內容,其中id_simpause為按鈕的id
getdlgitem
(id_simpause)
->
getwindowtext
(tempstr)
;(2)設定按鈕的文字具體示例如下:
//,其中id_simpause為按鈕的id,」」內為按鈕的文字內容
getdlgitem
(id_simpause)
->
setwindowtext
("**恢復"
);
近期專案遇到的一些問題
1.乙個邏輯判斷的問題但是,之前想了好久沒想到 根據active判斷內部還是外部郵件,然後進行 一開始判斷卡了很久,外部郵件可以發,但是內部郵件不可以,很奇怪,認為進來了這個this.active的判斷,只是不知道 出現了問題而已。一直列印各種東西,從頭到尾,都無法成功,明明this.active列...
vue專案遇到的一些問題總結
1 新install乙個模組後出現typeerror is not a function 異常。解決方案 如果可以確定 沒問題,重新 npm run dev。2 element表單清空 1 form 必須指定 ref name 和rules rules 2 el form item必須指定 prop...
Egret專案中遇到的一些問題
經常會遇到一些莫名其妙的undefined,而且本地除錯沒問題,發版後就會報,這個時候查錯都不好差,後來發現是本地除錯引用的是ts類庫,發版後引用的是js類庫,通過發web版後除錯發現typeof define為undefined,那麼就確定了問題所在 if typeof define functi...