ÄÚÈÝ·¢²¼¸üÐÂʱ¼ä : 2025/1/8 6:45:55ÐÇÆÚÒ» ÏÂÃæÊÇÎÄÕµÄÈ«²¿ÄÚÈÝÇëÈÏÕæÔĶÁ¡£
C++ MFC¿ìËÙ³¬¼òµ¥ÈëÃÅѧϰ
×¢Ò⣺ºìÉ«×ÖÌåΪÖØÒªµÄÐÅÏ¢£¬±ØÐëÀí½â²¢¼Çס¡£
ÔÚѧϰMFC֮ǰ£¬Äã±ØÐë¶ÔC++µÄ ¡°ÀàºÍ¶ÔÏóÓÐÒ»¶¨µÄÈÏʶºÍÀí½â£¬ÒòΪMFC¾ÍÊÇC++ÍêÈ«µÄÃæÏò¶ÔÏóÉè¼Æ£¬ËüÀïÃæ·â×°Á˺öàÀ࣬ÎÒÃÇÖ»Òªµ÷ÓþÍOK£¬¾ÍÏñCÓïÑÔµ÷Óÿ⺯ÊýÒ»Ñù£¬Ö±½ÓʹÓã¬Õâ¾ÍÊÇC++
µÚÒ»ÌØÐÔ£º·â×°ÐÔ£¬µÚ¶þÐÔ¾ÍÊǼ̳ÐÓëÅÉÉú£¬
Õâ¸öÔÚMFCÖÐÌåÏÖµÃÁÜÁÜÖÁ¼ä£¨×Ö´ò´íÁË£©¡£Èç¹û²»¶®£¬ÎÒÔÙÀ´½âÊÍһϣ¬Àý£ºÓÐÒ»¸öÉÌÆ·À࣬class GOODS ÉÌÆ·ÊôÐÔÓÐÃû×Ö£¬¼Û¸ñ
Ëü¿É×÷Ϊһ¸ö»ùÀ࣬ÎÒ¿ÉÒÔÅÉÉϳö Æ»¹ûÀ࣬class Apple :public GOODS . Æ»¹ûÊôÐÔ³öÁ˼̳ÐÁËÉÌÆ·µÄÊôÐÔÃû×Ö£¬¼Û¸ñÖ®Í⣬»¹¿ÉÅÉÉú³ö£¬ÑÕÉ«£¬µÈÊôÐÔ£¬¼Ì³ÐÓëÅÉÉú¾ÍÊÇÒ»¸öÊÇÁíÒ»¸öµÄ×Ó¼¯£¬µ«ÊÇÕâ¸ö×Ó¼¯²»½ö°üÀ¨¸¸¼¯µÄÌØÕ÷£¬»¹¾ßÓÐһЩеÄÌØÐÔ£¬¶®ÁË°É£¬ÕâÑù¡£ MFCÆäÖÐÖØÒªµÄÀàÊÇ£ºCDialog ¶Ô»°¿òÀà £¬CEdit,(±à¼¿òÀà)CButton,£¨°´Å¥Àࣩ CRadio£¨µ¥Ñ¡Å¥Àࣩ,ÕâЩ¶¼ÊÇ×÷Ϊ»ùÀ࣬ ÓÉÎÒÃÇ×Ô¼º¶¨ÒåµÄÀàÈ¥ÅÉÉúËüÃÇ¡£
ºÃÁË£¬ÏÖÔÚÏÈÁ˽âÒ»ÏÂʲôÊÇMFC°É£¬Çë¿´µ±Ç°Ä¿Â¼ÏµÄMFCÈëÃÅ֪ʶµÄ»ÃµÆƬ1¡ª20ÕÅ£¬»ò´ó¸ÅµÄä¯ÀÀһϵ±Ç°Ä¿Â¼ÏµÄÆäËüÁ¬¸öwordÎļþ£¬ºóÃæµÄ»ÃµÆƬÎÒ¾õµÃû±ØÒª¿´ÁË£¬ÒòΪÊÇ¿ìËÙÂ𣬽ÚԼʱ¼ä£¬£¨Ê×ÏÈ¿´²»¶®Ã»¹Øϵ£¬£©µ« µ«¿´ÍêÖ®ºó£¬±ØÐëÕÆÎÕÈçÏÂ֪ʶ£º
1. MFCÊÇ×÷ʲôÓõģ¿ÓëÒÔÇ°ÎÒÃÇдµÄC£¬C++ÓïÑÔÓÐʲô²»Í¬¡£ÒÔ¼°ËüµÄһЩÓŵ㣬
²»Í¬£¬ÒÔÇ°µÄÊÇ¿ØÖÆ̨µÄ½çÃæ²»ºÃ¿´£¬²»ÓѺ㬲Ù×÷²»·½±ã£¬ºÚ¿ò¿òµÄһƬ¡£ MFC·´Ö®¡£
Óŵ㣺¿ÉÓü«ÉٵĴúÂëʵÏÖÇ¿´óµÄ¹¦ÄÜ£¬
2. ¹ØÓÚMFCµÄһЩÊõÓ¸ÅÄî°¡
3. ÄãÒªÖªµÀMFCµÄ¶Ô»°¿òÊÇÓɿؼþ×é³ÉµÄ£¬¾ßÓÐÄÄЩ¿Ø¼þ£¨Àý°´Å¥:Button, µ¥Ñ¡Å¥:radio,Edit£© Àý£ºÒªÖªµÀMFCµÄ±à³ÌµÄÔÔò£¬Ò²¾ÍÊÇ×ÚÖ¼ÀíÄî°É£¬¡°ÏûÏ¢Ó³É䣬ʼþÇý¶¯¡°£¬Õâ¾ä»°Òª¼Çס²¢Àí½â£¬ºÜÖØÒª£¬ÕæµÄ¡£Äǵ½µ×ÊÇʲôÒâ˼ÄØ£¿ ÏÖʵ¾ÙÀý£ºÒ»¸öÈ˾߱¸Ò»ÖÖ¡°¸ÐÖª¡°µÄÄÜÁ¦£¬£¨Ò²¿É³ÆÏûÏ¢°É£©£¬µ±Óûð½Ó½üÕâ¸öÈËʱ£¨·¢ÉúµÄʼþ£©£¬¾Í»á£¨Çý¶¯£©Õâ¸öÈË×ö³ö·´Ó¦£¬Ô¶À롱»ð¡°£¬ ÓÃMFC¾ÙÀý£ºÒ»¸ö°´Å¥ÓÐʲôÏûÏ¢°¡£¬ÎÒ¿ÉÒÔµ¥»÷Ëü£¬ËùÒÔËü¾ß±¸µ¥»÷µÄÏûÏ¢£º
µÚÒ»¸ö
¾ÍÊÇ×ó¼üµ¥»÷µÄÏûÏ¢£¬µÚ¶þ¸ö ¾ÍÊÇË«»÷µÄÏûÏ¢£¬¼ûÃû˼Òé¾Í
OKÁË¡£ÎÒµ¥»÷Õâ¸ö°´Å¥Òª²úÉúij¸öʼþ£¬ ÎҾͿÉÒÔµÚÒ»²½£¬Ïȸø°´Å¥Ìí¼ÓÒ»¸öÏûÏ¢ÏìÓ¦º¯Êý£¬Òâ˼¾ÍÊǵ±ÎÒµ¥»÷°´Å¥Ê±£¬¾Íµ÷ÓÃÄǸöº¯Êý£¬°´Å¥Ê±Ê±¿Ì¿Ì¶¼´¦ÓÚ´ýÃüµÄ״̬£¬ ¼ÙÈçÌí¼ÓµÄº¯ÊýÈçÏ£º void CDsDlg::OnButton1() {
AfxMessageB ox(¡°ÎÒµ¥»÷ÁËÕâ¸ö°´Å¥¡±);
//Õâ¸öº¯ÊýÒª¼Çס£¬¾ÍÊǵ¯³öÒ»¸öÏûÏ¢¿ò.ÆäÖеÄ×Ö//·û´®×Ô¼ºÉèÖᣠ}
µ±Óû§µ¥»÷ÁËÕâ¸ö°´Å¥Ê±£¬¾Í»áµ÷ÓÃÉÏÊöº¯Êý£¬µ¯³öÒ»¸öÏûÏ¢¿òÏÔʾ¡°ÎÒµ¥»÷ÁËÕâ¸ö°´Å¥¡±ºÃÁË£¬½ÓÏÂÀ´¾Í¿´ÆäËü¿Ø¼þµÄÏûÏ¢°É£¡
½ÓÏÂÀ´µÄ¾ÍÓÃʵÀýɵ¹ÏʽµÄ½Ì´ó¼ÒÔõÑù´´½¨MFC³ÌÐò°É£¬
µÚÎåÕ ¶Ô»°¿òºÍ³£Óÿؼþ
¶Ô»°¿òÊÇWindowsÓ¦ÓóÌÐòÖÐ×îÖØÒªµÄÓû§½çÃæÔªËØÖ®Ò»£¬ÊÇÓëÓû§½»»¥µÄÖØÒªÊֶΣ¬ÔÚ³ÌÐòÔËÐйý³ÌÖУ¬¶Ô»°¿ò¿ÉÓÃÓÚÆË×½Óû§µÄÊäÈëÐÅÏ¢»òÊý¾Ý¡£¶Ô»°¿òÊÇÒ»¸öÌØÊâÀàÐ͵Ĵ°¿Ú£¬ÈκζԴ°¿Ú½øÐеIJÙ×÷£¨È磺Òƶ¯¡¢×î´ó»¯¡¢×îС»¯µÈ£©¶¼¿ÉÔÚ¶Ô»°¿òÖÐʵʩ£¬Ò»°ãÀ´Ëµ£¬ÔÚ¶Ô»°¿òÖÐͨ¹ý¸÷Öֿؼþ£¨È磺°´Å¥¡¢±à¼¿ò¡¢Áбí¿ò¡¢×éºÏ¿òµÈ£©À´ºÍÓû§½øÐн»»¥¡£¿Ø¼þÊÇÔÚϵͳÄÚ²¿¶¨ÒåµÄÓÃÓÚºÍÓû§½»»¥µÄ»ù±¾µ¥Ôª¡£ Ò»¡¢¶Ô»°¿òµÄʹÓÃ
Visual C++ÌṩµÄ¶Ô»°¿ò±à¼Æ÷ÄÜ¡°¿ÉÊÓ¡±µØ½øÐÐÉè¼Æ¡¢±à¼£¬²¢¿ÉÓà ClassWizardΪ¶Ô»°¿ò´ÓCDialog»ùÀàÖÐÅÉÉúÒ»¸öÀ࣬MFCµÄCDialogÀà·â×°ÁËÓÃÓÚ¶Ô»°¿òµÄÏÔʾ¡¢¹Ø±ÕµÈ²Ù×÷µÄÐí¶à¹¦Äܺ¯Êý£¬ÀýÈ磺DoModalº¯ÊýÓÃÀ´ÏÔʾģʽ¶Ô»°¿ò²¢·µ»ØÓû§²Ù×÷µÄ½á¹û¡£Õâ¸öº¯ÊýÏȼÇס°É£¬»áÓÐÓõġ£
Àý£ºCDialog d1; //ÒòΪCDialog(¶Ô»°¿òÀà)ÊÇMFCÒѾ·â×°µÄÒ»¸öÀ࣬¾ÍÊÇÏ൱ÓÚÒ»¸ö¿âº¯ÊýµÄ²î²»¶à£¬¿âº¯ÊýÏþµÃ°É£¬ÀýCÓïÑԵģ¬printf(); Õâ¸öÒ²Êǿ⺯