![]() While I was consulting at BALR, I wrote several applications for a client. One was a client management system written in C++ and MFC. The other was a marketing management system also written in C++ and MFC. The team designed the database backend worked to define how the dialogs would look. I did almost all the coding with a buddy working on the database shared procedures. I can't really show good screen shots because it requires a database connection to run. One unique technology we used was binding controls. Controls were bound to a specific field in the database with a table and index. Modifying the control instantly updated the database behind it. We used stored procedures to create, delete, and find entries in the tables to bind to. I also wrote several other applications such as a call scheduler, mail card scanner, and MQ backend services. ![]() ![]() int CReportChildFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu) { CString strPath(pszPath); CString strPath2; CString str; WIN32_FIND_DATA wfd; HANDLE h; int nPos; int nEndPos; int nNewEndPos; int nLastDir; TCHAR buf[INTERNET_MAX_PATH_LENGTH]; CStringArray astrFavorites; CStringArray astrDirs; CMenu* pSubMenu; // make sure there's a trailing backslash if(strPath[strPath.GetLength() - 1] != _T('\\')) strPath += _T('\\'); strPath2 = strPath; strPath += "*.*"; // now scan the directory, first for .URL files and then for subdirectories // that may also contain .URL files h = FindFirstFile(strPath, &wfd); if(h != INVALID_HANDLE_VALUE) { nEndPos = nStartPos; do { if((wfd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))==0) { str = wfd.cFileName; if(str.Right(4) == _T(".url")) { // an .URL file is formatted just like an .INI file, so we can // use GetPrivateProfileString() to get the information we want ::GetPrivateProfileString(_T("InternetShortcut"), _T("URL"), _T(""), buf, INTERNET_MAX_PATH_LENGTH, strPath2 + str); str = str.Left(str.GetLength() - 4); // scan through the array and perform an insertion sort // to make sure the menu ends up in alphabetic order for(nPos = nStartPos ; nPos < nEndPos ; ++nPos) { if(str.CompareNoCase(astrFavorites[nPos]) < 0) break; } astrFavorites.InsertAt(nPos, str); m_astrFavoriteURLs.InsertAt(nPos, buf); ++nEndPos; } } } while(FindNextFile(h, &wfd)); FindClose(h); // Now add these items to the menu for(nPos = nStartPos ; nPos < nEndPos ; ++nPos) { pMenu->AppendMenu(MF_STRING | MF_ENABLED, 0xe00 + nPos, astrFavorites[nPos]); } // now that we've got all the .URL files, check the subdirectories for more nLastDir = 0; h = FindFirstFile(strPath, &wfd); ASSERT(h != INVALID_HANDLE_VALUE); do { if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // ignore the current and parent directory entries if(lstrcmp(wfd.cFileName, _T(".")) == 0 || lstrcmp(wfd.cFileName, _T("..")) == 0) continue; for(nPos = 0 ; nPos < nLastDir ; ++nPos) { if(astrDirs[nPos].CompareNoCase(wfd.cFileName) > 0) break; } pSubMenu = new CMenu; pSubMenu->CreatePopupMenu(); // call this function recursively. nNewEndPos = BuildFavoritesMenu(strPath2 + wfd.cFileName, nEndPos, pSubMenu); if(nNewEndPos != nEndPos) { // only intert a submenu if there are in fact .URL files in the subdirectory nEndPos = nNewEndPos; pMenu->InsertMenu(nPos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT)pSubMenu->m_hMenu, wfd.cFileName); pSubMenu->Detach(); astrDirs.InsertAt(nPos, wfd.cFileName); ++nLastDir; } delete pSubMenu; } } while(FindNextFile(h, &wfd)); FindClose(h); } return nEndPos; } |
Projects >