Ô±¹¤½ÌʦͨѶ¼ӦÓÃϵͳ ÏÂÔر¾ÎÄ

ʯºÓ×Ó´óѧ--Delphi¿Î³ÌÉè¼Æ 2012Äê11ÔÂ2ÈÕ

¢Ü Á¬½Ó³É¹¦Ö®ºó»á³öÏÖÈçͼ3-13ËùʾµÄÑ¡ÔñÊý¾Ý¿â¶ÔÏóµÄ¶Ô»°¿ò£¬ÔÚÕâÀïÎÒÃÇÑ¡ÔñgroupInfo£¬È»ºóµ¥»÷È·¶¨°´Å¥£¬ËæºóMFC»á×Ô¶¯Éú³ÉÀàCGroupInfoµÄ´úÂë¡£

ͼ3-13 Ñ¡ÔñÊý¾Ý¿â¶ÔÏó

¢Ý ²Î¿¼ÉÏÊöÉú³ÉÀàCGroupInfoµÄ²½Ö裬Éú³É¼Ç¼¼¯ÀàCPeopleºÍCuserµÄ´úÂë¡£

ʯºÓ×Ó´óѧ--Delphi¿Î³ÌÉè¼Æ 2012Äê11ÔÂ2ÈÕ

4 ϵͳµÄʵÏÖ

4.1 Ö÷´°¿ÚÉè¼Æ

4.1.1 Ö÷´°¿ÚÐÅÏ¢ÏÔʾ

±¾ÏµÍ³²ÉÓÃÁËÒÔ¶Ô»°¿òΪÖ÷ÌåµÄ½çÃæ·½°¸£¬ÔÚ½¨Á¢Á˳ÌÐò¿ò¼Ü¼°À©Õ¹ÁËÏà¹Ø¼Ç¼¼¯ºó¾Í¿ÉÒÔ¿ªÊ¼½øÐоßÌ幦ÄÜÉϵÄʵÏÖÁË¡£

ͨѶ¼×îÖØÒªµÄ¹¦ÄܱãÊÇÏÔʾ½ÌʦÐÅÏ¢£¬Òò´ËÖ÷´°¿ÚµÄÖ÷Òª¹¦ÄÜÒ²Ó¦µ±ÊDzéѯ¼°ÏÔʾ½ÌʦÐÅÏ¢¡£¸ù¾Ý´ËÇ°¶ÔϵͳÐèÇóµÄ·ÖÎö£¬½ÌʦµÄÐÅÏ¢Ó¦°üº¬ÐÕÃû¡¢ÐԱ𡢹¤×÷µ¥Î»¡¢°ì¹«µç»°¡¢×¡Ö·¡¢×¡Õ¬µç»°¡¢ÊÖ»ú¡¢ÓÊÏä¡¢QQ¡¢MSN¼°±¸×¢ÐÅÏ¢£¬½ÌʦµÄ·Ö×éÁбíÔò¿ÉÒÔÓÃÊ÷¿Ø¼þ½øÐÐÏÔʾ£¬ËùÒÔÖ÷´°¿ÚÖÐÓ¦ÏÔʾÉÏÊöÈ«²¿ÐÅÏ¢¡£

»ùÓÚÉÏÊö¿¼ÂÇ£¬ÔÚ×ÊÔ´ÊÓͼÖиü¸Ä¶Ô»°¿ò£¨¼´IDΪID_ADDRESSLIST_DIALOG µÄ¶Ô»°¿ò£©µÄ´óС²¢°´Í¼4-1ËùʾÌí¼ÓÏàÓ¦¿Ø¼þ¡£ÆäÖÐÓÐÒ»¸öÊ÷¿Ø¼þ£¬È»ºóÊǶà¸ö¾²Ì¬Îı¾ºÍ±à¼­¿ò£¬Ò»¸öµ¥Ñ¡°´Å¥£¬Êý¸ö°´Å¥ÓÃÀ´ÊµÏÖÔöɾ¸Ä²éµÄ¹¦ÄÜ¡£

ʯºÓ×Ó´óѧ--Delphi¿Î³ÌÉè¼Æ 2012Äê11ÔÂ2ÈÕ

ͼ 4-1 Ö÷½çÃæ

¿Ø¼þÌí¼ÓºÃÁËÖ®ºó£¬·Ö±ð¶ÔËüÃǽøÐÐÌí¼Ó±äÁ¿£¬¾ßÌå·½·¨ÈçÏ£º

¢Ù ÓÒ¼üµ¥»÷ij¸ö¿Ø¼þ£¬ÔÚµ¯³öµÄ²Ëµ¥ÖÐÑ¡Ôñ¡°Ìí¼Ó±äÁ¿¡±¡£

¢Ú ´Ëʱ»áµ¯³öÒ»¸ö¶Ô»°¿ò£¬ÔÚÀïÃæ¿ÉÒÔÑ¡Ôñ±äÁ¿µÄÀàÐͺÍÀà±ð£¬È»ºóÊäÈë±äÁ¿Ãû£¬×îºóµ¥»÷Íê³É°´Å¥¼´¿ÉÍê³ÉÒ»¸ö±äÁ¿µÄÌí¼Ó¡£Èçͼ4-2Ëùʾ¡£

ͼ 4-2 Ìí¼Ó±äÁ¿

¢Û Öظ´ÉÏÊö²½Ö裬Ìí¼ÓÆäËû±äÁ¿¡£

ÔÚÉÏÊö²½ÖèÖж¨ÒåµÄ±äÁ¿ÔÚMFCÖÐÊÇÈçºÎÓëÏàÓ¦µÄ¿Ø¼þÁªÏµÆðÀ´µÄÄØ£¿Í¨¹ýÔÚÀàCAddressListDlgÖÐÕÒµ½º¯ÊýDODataExchange£¬¿ÉÒÔ·¢ÏÖMFCÕýÊÇÔÚÕâ¸öº¯ÊýÖÐΪ±äÁ¿ºÍ¿Ø¼þ½¨Á¢ÁËÓ³Éä¹Øϵ£¬Æä´úÂëÈçÏ£º

void CAddressListDlg::DoDataExchange(CDataExchange* pDX)

ʯºÓ×Ó´óѧ--Delphi¿Î³ÌÉè¼Æ

{

CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAddressListDlg)

2012Äê11ÔÂ2ÈÕ

DDX_Control(pDX, IDC_TREE_LIST, m_tree_list); DDX_Text(pDX, IDC_EDIT_ADDRESS, m_address); DDX_Text(pDX, IDC_EDIT_COMPANY, m_company); DDX_Text(pDX, IDC_EDIT_MAIL, m_mail); DDX_Text(pDX, IDC_EDIT_MEMORY, m_memory); DDX_Text(pDX, IDC_EDIT_MOBILE, m_mobile); DDX_Text(pDX, IDC_EDIT_MSN, m_msn);

DDX_Text(pDX, IDC_EDIT_PHONEATHOME, m_phoneInHome); DDX_Text(pDX, IDC_EDIT_PHONEINCOMPANY, m_phoneInCompany); DDX_Text(pDX, IDC_EDIT_QQ, m_qq); DDX_Radio(pDX, IDC_RADIO_MAN, m_sex); DDX_Text(pDX, IDC_EDIT_NAME, m_name); //}}AFX_DATA_MAP

DDX_Control(pDX, IDC_About, m_About);

}

³ÌÐòÆô¶¯ºó£¬ÏÔʾÖ÷´°¿ÚʱÐèÒª¶Ô×ó²àµÄÊ÷¿Ø¼þ½øÐгõʼ»¯£¬ËüÓ¦ÏÔʾµ±Ç°

ʯºÓ×Ó´óѧ--Delphi¿Î³ÌÉè¼Æ 2012Äê11ÔÂ2ÈÕ

ϵͳÖÐËùÓеķÖ×é¼°Á¥ÊôÓÚ²»Í¬×éµÄ½Ìʦ³ÉÔ±¡£Ê÷¿Ø¼þ³õʼ»¯µÄ¹¤×÷Óɺ¯ÊýInitTreeListÍê³É£¬Ëü½«ÔÚ³õʼ»¯º¯ÊýOnInitDialogÖб»µ÷Ó᣺¯ÊýInitTreeListÊ×Ïȵ÷ÓÃÊ÷¿Ø¼þµÄDeleteAllItems·½·¨Çå¿Õ¿Ø¼þÖÐÔ­ÓеÄÏîÄ¿£¬È»ºó´ÓÊý¾Ý¿âÖвéѯ×éÐÅÏ¢£¬²¢ÒÀ´Î½«×éÃû²åÈëµ½Ê÷¿Ø¼þÖУ¬ÔÚÿ²åÈëÒ»¸ö×éºó£¬Á¢¼´½«Á¥ÊôÓÚ¸Ã×éµÄ½ÌʦÌí¼Óµ½¸Ã×éÏ¡£

ÓÉMFCÏòµ¼Éú³ÉµÄ¼Ç¼¼¯ÀàÔÚÉú³ÉʵÀýʱÐèÒª´«ÈëÒ»¸öCDatabaseÀàÐ͵ÄÒýÓòÎÊý£¬Òò´ËÔÚʹÓÃÀàCGroupInfo¼°CPeople֮ǰÐèÒªÏȹ¹½¨CDatabaseÀàµÄʵÀý£¬È»ºó½«ËüµÄÒýÓÃ×÷Ϊ²ÎÊý¹¹½¨ÀàCGroupInfo¼°CPeopleµÄʵÀý¡£ÔÚ²úÉú¼Ç¼¼¯µÄʵÀýºó(º¯ÊýInitTreeListÖеÄʵÀýÃû·Ö±ðΪgiºÍpeople£©£¬½«²éѯSQLÓï¾ä´«ÈëÆäOpen·½·¨´ò¿ª¼Ç¼¼¯£¬È»ºóͨ¹ýÊ÷¿Ø¼þµÄInsetItem·½·¨½«×éÃû»ò½ÌʦÐÕÃû×÷ΪÊ÷¿Ø¼þµÄÒ»¸öÌõÄ¿²åÈ룬ΪÁËÄܹ»ÔڿؼþÖÐΨһµØ±êʶÿһ¸ö×é¼°½Ìʦ£¬»¹ÐèÒªµ÷ÓÃSetItemData·½·¨½«×éID»ò½ÌʦID°ó¶¨µ½¿Ø¼þÖеÄÏàÓ¦ÌõÄ¿ÉÏ¡£ÔÚ¶ÔÊý¾Ý¿âµÄ²Ù×÷·½Ã棬º¯ÊýÖл¹³öÏÖÁ˼Ǽ¼¯µÄMoveNext·½·¨¼°Êý¾Ý¿âµÄClose·½·¨£¬ËüÃǵÄ×÷Ó÷ֱðÊÇÒƶ¯¼Ç¼¼¯Ö¸Õëµ½ÏÂÒ»Ìõ¼Ç¼£¬ÒÔ¼°¹Ø±Õµ±Ç°Êý¾Ý¿âÁ¬½Ó¡£InitTreeList()º¯ÊýÈçÏÂËùʾ¡£

void CAddressListDlg::InitTreeList() {

m_tree_list.DeleteAllItems(); CString strPeoPleQuery;

strPeoPleQuery = \; CDatabase db1; CGroupInfo gi(&db1);

gi.Open(AFX_DB_USE_DEFAULT_TYPE, strPeoPleQuery);