嵌入式实习报告基于wince个人通讯录开发(编辑修改稿)内容摘要:
序 通讯录 图 22 通讯录模块功能图 编辑 按姓名 按号码 按分类 《嵌入式系统开发与应用工程实习报告》 5 退出 退出功能流程图如 32 所示。 通讯录 模块 通讯录模块包括添加、删除、编辑、按姓名排序、按号码排序、按分类排序等功能。 删除功能流程图如 33 所示。 开始 进入文件模块 删除 全部数据库 结束 是否有记录 跳出当前记录为空 是 否 确定删除。 是 否 取消 删除成功 图 31 文件模块处理流程图 开始 进入文件模块 退出 结束 是否退出 返回 否 是 退出成功 图 32 退出处理流程图 《嵌入式系统开发与应用工程实习报告》 6 4 代码编写 全局数据 // Global data const TCHAR szAppName[] = TEXT (AlbumDB)。 HINSTANCE hInst。 // Program instance handle HANDLE g_hDB = INVALID_HANDLE_VALUE。 // Handle to album database CEOID g_oidDB = 0。 // Object ID of the album database CEGUID g_guidDB。 // Guid for database volume CENOTIFYREQUEST cenr。 // Notify request structure. int g_nLastSort = 0。 // Last sort order used CEDBASEINFOEX g_diex。 // Sort order array // These two variables represent a oneitem cache for // the list view control. int g_nLastItem = 1。 LPBYTE g_pLastRecord = 0。 //主窗口过程函数的消息映射表用到 decodeUINT结构 const struct decodeUINT MainMessages[] = { WM_CREATE, DoCreateMain, WM_SIZE, DoSizeMain, WM_COMMAND, DoCommandMain, WM_NOTIFY, DoNotifyMain, WM_DESTROY, DoDestroyMain, WM_DBNOTIFICATION, DoDbNotifyMain, }。 // Command message dispatch for MainWindowProc 开始 进入通讯录模块 删除某一条记录 结束 是否删除 返回 否 是 删除成功 图 33 删除处理流程图 《嵌入式系统开发与应用工程实习报告》 7 const struct decodeCMD MainCommandItems[] = { IDM_DELDB, DoMainCommandDelDB, IDM_EXIT, DoMainCommandExit, IDM_NEW, DoMainCommandNew, IDM_EDIT, DoMainCommandEdit, IDM_DELETE, DoMainCommandDelete, IDM_SORTNAME, DoMainCommandSort, IDM_SORTARTIST, DoMainCommandSort, IDM_SORTCATEGORY, DoMainCommandSort, IDM_ABOUT, DoMainCommandAbout, }。 // Album category strings。 must be alphabetical. const TCHAR *pszCategories[] = {TEXT (Family), TEXT (Friends), TEXT (collague), TEXT (mates)}。 程序入口及 初始化 //程序的入口 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { HWND hwndMain。 MSG msg。 int rc = 0。 // Initialize this instance. hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow)。 if (hwndMain == 0) return 0x10。 // Application message loop while (GetMessage (amp。 msg, NULL, 0, 0)) { TranslateMessage (amp。 msg)。 DispatchMessage (amp。 msg)。 } // Instance cleanup return TermInstance (hInstance, )。 } HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow){ HWND hWnd。 WNDCLASS wc。 INITCOMMONCONTROLSEX icex。 if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) // For Windows Mobile devices, allow only one instance of the app hWnd = FindWindow (szAppName, NULL)。 if (hWnd) { SetForegroundWindow ((HWND)(((DWORD)hWnd) | 0x01))。 return (HWND)1。 } endif 《嵌入式系统开发与应用工程实习报告》 8 // Save program instance handle in global variable. hInst = hInstance。 // Create a guid for the database Ex functions that points // to the object store. CREATE_SYSTEMGUID(amp。 g_guidDB)。 memset (amp。 cenr, 0, sizeof (cenr))。 // Initialize the notify request. 删除数据库模块 // Command handler routines // DoMainCommandDelDB Process Program Delete mand. LPARAM DoMainCommandDelDB (HWND hWnd, WORD idItem, HWND hwndCtl, WORD wNotifyCode) { int i, rc。 i = MessageBox (hWnd, TEXT (Delete the entire database?), TEXT (Delete!), MB_YESNO)。 if (i != IDYES) return 0。 if (g_oidDB) { CloseHandle (g_hDB)。 rc = CeDeleteDatabase (g_oidDB)。 if (rc == 0) { ErrBox (hWnd, TEXT (Couldn\39。 t delete database. rc=%d), GetLastError())。 g_hDB = OpenDB (hWnd, NULL)。 // Open the database. return 0。 } g_hDB = INVALID_HANDLE_VALUE。 g_oidDB = 0。 } ListView_SetItemCount (GetDlgItem (hWnd, ID_LISTV), 0)。 return 0。 } 退出模块 // // DoMainCommandExit Process Program Exit mand. LPARAM DoMainCommandE。嵌入式实习报告基于wince个人通讯录开发(编辑修改稿)
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。