|
Except FindFirstFile you can use of DlgDirList for get files and folders.
|
|
|
|
|
The DlgDirList function replaces the contents of a list box with the names of the subdirectories and files in a specified directory. so if the user does not have a list box at his disposal, this API won't be useful.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
This function will return the directory contents in a vector of strings.
std::vector< std::wstring > GetDirectoryList( const std::wstring &strDirectory )
{
std::vector< std::wstring > contents;
WIN32_FIND_DATA data;
HANDLE hFind = FindFirstFile( (strDirectory + L"\\*").c_str() , &data);
if ( hFind != INVALID_HANDLE_VALUE ) {
do {
contents.push_back( data.cFileName );
} while ( FindNextFile( hFind , &data ) != 0 );
FindClose( hFind );
}
return contents;
}
|
|
|
|
|
// send initial update to all views (and other controls) in the frame
SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);
SendMessageToDescendants
the Handler of WM_INITIALUPDATE takes a very long time since ther a huge data to update. and this frizes the application UI.
Looking for a good idea to make UI active while it updates. pls advice
|
|
|
|
|
make the WM_INITIALUPDATE without the data and seperate the "huge data update" in another thread, which if ready updates the windows
"Wait for data loading..." with sandclock
Greetings from Germany
|
|
|
|
|
If you have to do ANY lengthy processing in response
to a Window message, then you need to start the processing in a
separate thread and return immediately from the message handler.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi..
I have create an MFC application which should have one button to load a file from the disk.
When i click the button it should display the open file dailog, can anyone help me, plz provide me some sample code..
thanks and regards
vinayskvs
|
|
|
|
|
this may help you
void CyourDlg::OnOpenBtn()
{
this->UpdateData();
CFile f;
char strFilter[] = { "BCR Files (*.bcr)|*.bcr|All Files (*.*)|*.*||" };
CFileDialog FileDlg(TRUE, ".bcr", NULL, 0, strFilter);
if( FileDlg.DoModal() == IDOK )
{
if( f.Open(FileDlg.GetFileName(), CFile::modeRead) == FALSE )
return;
CArchive ar(&f, CArchive::load);
ar >> m_Make >> m_Model >> m_Year >> m_Mileage >> m_Owner;
ar.Close();
}
else
return;
f.Close();
this->UpdateData(FALSE);
}
|
|
|
|
|
vinaykskvs wrote: When i click the button it should display the open file dailog, can anyone help me, plz provide me some sample code..
A code snippet which does this...
void CDialoTestDlg::OnButton1()
{
CFileDialog Fd( TRUE );
if( Fd.DoModal() == IDOK )
{
MessageBox( Fd.GetPathName() );
}
else
{
MessageBox( _T( "You didn't select a file" ));
}
}
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
|
Hamid. wrote: A good article for you.
While the article itself may be good, it serves no purpose to the OP.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
But why his answer is CFileDailog and this article is more than his answer(Why 2 votes=1)?
|
|
|
|
|
Hi all,
I am geting problem, when i am using GetSafeHwnd()API,
its gives error like this:
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
error showing in line no 24:
afx.h headr file
Please any body sugest me how to reslove this.
Thanks inadvance
-Gangadhar
|
|
|
|
|
|
i need to run a thread after a fix interval .currently i m doing like this
bool run=true;
while(run)
{
//code
sleep(200);
}
but this not work properly it donot sleep for fix interval , how can i get the same result
|
|
|
|
|
you can use a Timer for this.
BOOL dlg::OnInitDialog()
{
CDialog::OnInitDialog();
....
....
SetTimer(1,60, NULL);
return true;
}
void dlg::OnTimer(UINT nIDEvent)
{
AfxBeginThread (YourthreadThread , _param)
}
|
|
|
|
|
this will create a new thread after every 60msec that is not a good approch.please tell if there is an alternate.
|
|
|
|
|
anilaabc wrote: it donot sleep for fix interval
What do you mean by that exactly ?
|
|
|
|
|
Sleep() do not sleep for specified interval , it may be more than interval specified ,i tested several time.please tell me a better solution
|
|
|
|
|
anilaabc wrote: sleep for fix interval
Well, Windows is not a real-time operating system. So depending on what kind of accuracy you need, this may or may not be possible in a windows environment.
See here[^] for more info.
Calling ::Sleep() is almost always wrong.
See here[^] for more info.
I suggest you create a waitable timer, ::CreateWaitableTimer() , that your thread can wait on with ::WaitForMultipleObjects() . To get the best accuracy you can use the multimedia timers, ::timeSetEvent() and so on, and set it up to signal an event you've created that you can wait on with ::WaitForMultipleObjects() .
For more info on how to create and shut down the thread properly, and how to wait on synchronization objects inside the thread, see here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks for your help ,I will try and be back to u
|
|
|
|
|
Hello everybody,
I live in Brazil and I´m heaving problems with on a compilation C++ project. The message is:
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h(4575) : error C3861: '_beginthreadex': identifier not found
The header PROCESS.H be present in the main hearder file.
My problem beguns when a change my Visual Studio 5 for Visual Studio 8.
The C++ comand line is:
/GL /I "C:\Samuel\20-SOFTools\Notepad++\SOFTools" /I "..\src\WinControls\AboutDlg" /I "..\..\scintilla\include" /I "..\include" /I "..\src\WinControls" /I "..\src\WinControls\ImageListSet" /I "..\src\WinControls\OpenSaveFileDialog" /I "..\src\WinControls\SplitterContainer" /I "..\src\WinControls\StaticDialog" /I "..\src\WinControls\TabBar" /I "..\src\WinControls\ToolBar" /I "..\src\MISC\Process" /I "..\src\ScitillaComponent" /I "..\src\MISC" /I "..\src\MISC\SysMsg" /I "..\src\WinControls\StatusBar" /I "..\src" /I "..\src\WinControls\StaticDialog\RunDlg" /I "..\src\tinyxml" /I "..\src\WinControls\ColourPicker" /I "..\src\MISC\RegExt" /I "..\src\WinControls\TrayIcon" /I "..\src\WinControls\shortcut" /I "..\src\WinControls\Grid" /I "..\src\WinControls\ContextMenu" /I "..\src\MISC\PluginsManager" /I "..\src\WinControls\Preference" /I "..\src\WinControls\WindowsDlg" /I "..\src\WinControls\TaskList" /I "..\src\WinControls\DockingWnd" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_VC80_UPGRADE=0x0710" /D "_AFXDLL" /D "_ATL_DLL" /D "_MBCS" /FD /EHa /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W0 /c /Zi /clr /Gz /TP /errorReport:prompt
The link comand line is:
/VERBOSE:LIB /OUT:"Debug/notepadPlus_Debug.exe" /VERSION:1.0 /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\notepadPlus_Debug.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /TLBID:5 /DEBUG /ASSEMBLYDEBUG /PDB:"Debug/notepadPlus.pdb" /SUBSYSTEM:WINDOWS /LTCG /DYNAMICBASE:NO /FIXED:No /MACHINE:X86 /CLRTHREADATTRIBUTE:MTA /ERRORREPORT:PROMPT comctl32.lib shlwapi.lib shell32.lib
Please, I realy need help. I did everything I know ...
Sorry by poor english
|
|
|
|
|
In the project setting make sure multithreading is enabled.
Steve
|
|
|
|
|
But Steve, i thing is alredy enable. The option /MDd don´t show it ?
Or there is other place to change ?
|
|
|
|
|
Friends, the problem remains.
Someone, can help me ?
|
|
|
|