MFC入門常用細節

2021-07-03 17:07:54 字數 832 閱讀 9493

cstring str; //定義乙個字串

cstring str = "asd";

int a = 1;

trace("%s\n", str);//輸出cstring字串到ide的輸出視窗(不是控制台介面)

trace("%d\n", a);//輸出整數到ide的輸出視窗

控制台工程:

cstring m_stconnect;

coutafxmessagebox(str);//提示框輸出字串str

messagebox(str);//提示框輸出字串str

trace(strtext);//列印字串strtext

afxdumpgetdlgitem(idc_edit1)->setwindowtext("this is a test program!");

//輸出字串到控制項idc_edit1上

getdlgitem(idc_edit1)->getwindowtext(str); //獲取控制項控制項idc_edit1上的內容

getdlgitem(idc_edit1)->getwindowtexta(str); //獲取控制項控制項idc_edit1上的內容

getdlgitemtext(idc_edit1, str);//獲取控制項控制項idc_edit1上的內容

cstring str; 

int num = 10;

num = atoi(str);//字串轉換為數字

str.format("%d",num);//數字轉換為字串

getdlgitem(idc_edit1)->setwindowtext(_t("")); 清空控制項idc_edit1裡的內容

MFC程式設計細節

1.禁止改變視窗大小 style ds setfont ds fixedsys ws minimizebox ws popup ws visible ws caption ws sysmenu ws thickframe style ds setfont ds fixedsys ws minimiz...

MFC呼叫C DLL細節

一 使用 clr 編譯 mfc 可執行檔案或規則 dll 1 開啟專案屬性對話方塊,方法是右鍵單擊解決方案資源管理器中的專案並選擇屬性。2 展開配置屬性旁邊的節點並選擇常規。在右側窗格中的專案預設值下,將公共語言執行庫支援設定為公共語言執行庫支援 clr 3 在相同的窗格中,確保將mfc 的使用設定...

MFC學習 MFC入門

mfc 原作者姓名 zhoujiamurong include afxwin.h class sample public cframewnd class public public0,initinstance中呼叫 initinstance中呼叫 mb ok sample s new sample ...