The following code will enumerate all the files in the current directory. CFileFind finder; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); myListBox.AddString(finder.GetFileName()) }
or Use the method CListBox::Dir
vcplusplus
Posts
-
How to implement DirListBox and DriveListBox in Visual C++ ? -
Help on Command Line Parametersif szCmdLine contains other parameters besides /a or /b, you will need to do this.
if (szCmdLine.Find("/b") >= 0 || szCmdLine.Find("/a") >= 0) { MessageBox (NULL, szCmdLine,"met",0); } else { MessageBox (NULL, szCmdLine,"Not met",0); }
-
How to write o soft keyboard -
vc++If you want to do it at run time, override the virtual function DoModal();
#include <afxpriv.h> // Required for CDialogTemplate int CMyDlg::DoModal() { CDialogTemplate dlt; // Load dialog Template if (!dlt.Load(MAKEINTRESOURCE(CMyDlg::IDD))) { return -1; } // Set Font Size; // Default Value WORD nFontSize = 10; TCHAR chFaceName[100] = "Courier New"; // Open an ini file or read from the registry to get the new font size and face name if (GetNewFontSize(....)) { nFontSize = newsize; } if (GetNewFaceName(....)) { lstrcpy(chFaceName, newfacename); } dlt.SetFont(chFaceName, (WORD)nFontSize); // Get pointer to the modified dialog template LPSTR pData = (LPSTR)GlobalLock(dlt.m_hTemplate); if (pData == NULL) { return -1; } // Let MFC know that you are using your own template m_lpszTemplateName = NULL; InitModalIndirect(pData); // Display Dialog Box INT nResult = CDialog::DoModal(); // Unlock memory object GlobalUnlock(dlt.m_hTemplate); return nResult; }
-
Hook woesAre you assigning lpMeasureItemStruct->itemHeight the new height?
void CMyView::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { ... ... ... lpMeasureItemStruct->itemHeight = nNewHeight; ... ... ... }
-
Compile with version.lib -
Installing Visual Studio -
CFilevc-programmer- wrote: CFile is like as sql have new,delete,update. Here is a list of all the methods for CFile. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cfile_class_members.asp[^]
-
Detect PrivilegesNetUserGetInfo(servername, username, USER_INFO_1, bufptr); http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/netusergetinfo.asp[^]
-
windows ce and pocketpc 2003Did you try WM_LBUTTONDOWN and WM_LBUTTONUP?
-
Execute a *.exe inside my applicationillidan99 wrote: I want to run another application(B) inside my application(A). In this moment the application B takes control and when it's closed, then my application A retakes the control. ¿Which function or class can I use for this?
_spawnl(_P_WAIT, "c:\\MyApp.exe", "c:\\MyApp.exe", NULL, NULL);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_crt__spawnl.2c_._wspawnl.asp[^] -
Folder creation from inline code?You're right, my mistake.:(
-
Folder creation from inline code?CreateDirectory("C:\\Engineering Data\\Diagnostic Data\\2004_10_15") will fail if "C:\\Engineering Data\\Diagnostic Data\\" does not exist.
-
stupid array initializationint *pArr = new int[Size];
-
int to CString -
Socket Programming using threadsI have heard that there are problems with CSocket. Check out this article. http://tangentsoft.net/wskfaq/articles/csocket.html[^]
-
#define style templates and float3.5 and 8.7 are consider constant doubles. When I compile the code below, VC gives me a warning for "a" but not for "b"
float a = 2.4; warning C4305: 'initializing' : truncation from 'const double' to 'float' float b = 2.4f;
-
How to start a PC/Application from ProgramIf you are using NT/2000/XP, you will need to set privileges.
DWORD dwVersion = GetVersion(); if ( dwVersion < 0x80000000) { // NT/2000/XP HANDLE hToken; LUID tmpLuid; HANDLE handleProcess=GetCurrentProcess(); if (!OpenProcessToken(handleProcess,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return; if (!LookupPrivilegeValue(0,"SeShutdownPrivilege", &tmpLuid)) return; TOKEN_PRIVILEGES NewState; LUID_AND_ATTRIBUTES luidattr; NewState.PrivilegeCount = 1; luidattr.Luid=tmpLuid; luidattr.Attributes=SE_PRIVILEGE_ENABLED; NewState.Privileges[0]=luidattr; if (!AdjustTokenPrivileges(hToken, false, &NewState, sizeof(TOKEN_PRIVILEGES), 0, 0)) return; } ExitWindowsEx(...);
-
SetForegroundWindow failsI found a work-around for this problem. http://codeproject.com/dialog/dlgboxtricks.asp[^]
-
SetForegroundWindow failsThat's how XP works. It flashes the taskbar instead of having the application take over the screen. If you can, try your App. on a Win 98 machine just to make sure it's XP and not your code.