|
prasad_som wrote: I'll use CWnd::PostMessage , if I've CWnd object(no need to wrap window handle, specially to use this version), and ::PostMessage , if I've window handle.
So you'll use both at the same time when you have a CWnd object...
Pardon the silly humour...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
GC104 wrote: I have been using the WINAPI PostMessage() function call rather than the MFC wrapper CWnd::PostMessage()
You have to use the Windows API function. Worker threads aren't CWnd .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You already got answer in earlier post. If you want to pass pointer to handle, use address of m_hHandle member variable, which is handle of CMainFrame. No need to call GetSafeHwnd.
|
|
|
|
|
hello guys...I made this small console app inwhich I can get the difference (duration) between two times. I then store them into database as string. But the problem is that sometimes it shows some weird difference which I am unable to trace. Here is what I have
SYSTEMTIME t,t2,t3;
GetSystemTime(&t);
GetSystemTime(&t2);
t3.wHour = t2.wHour - t.wHour;
t3.wMinute = t2.wMinute - t.wMinute;
t3.wSecond = t2.wSecond - t.wSecond;
GetMyDateTime2(t,t2,t3);
But here is one of the durations that I got from this calculation
2 3/3/2011 21:57:57 3/3/2011 21:58:3 0:1:65482(duration) D:\Recordings\SecondRec.wav
what can be the problem?? thnx
modified on Friday, March 4, 2011 5:08 AM
|
|
|
|
|
The problem is your calculations are wrong (do you remember 'carry'?) and the SYSTEMTIME fields are 16 bit WORDS .
Try
WORD wCarry;
if (t2.wSecond >= t1.wSecond )
{
wCarry = 0;
t3.wSecond = t2.wSecond - t1.wSecond;
}
else
{
wCarry = 1;
t3.wSecond = 60 + t2.wSecond - t1.wSecond;
}
if (t2.wMinute >= t1.wMinute + wCarry)
{
wCarry = 0;
t3.wMinute = t2.wMinute - t1.wMinute;
}
else
{
wCarry = 1;
t3.wMinute = 60 + t2.wMinute - t1.wMinute;
}
if (t2.wHour >= t1.wHour + wCarry)
{
t3.wHour = t2.wHour - t1.wHour;
}
else
{
}
Please note the above code would have troubles on button clicks crossing the date boundary...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you can use CTime and CTimeSpan MFC classes, no need to bother about calculations.
|
|
|
|
|
overloaded Name wrote: hello guys...I made this small console app inwhich I can get the difference
(duration) between two times.
You might also check out difftime() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
By far, the simplest way is GetSystemTimeAsFileTime[^]. This returns a FILETIME[^] struct which contians 2 DWORDs which you can then drop directly into a ULARGE_INTEGER[^].
FILETIME ftStart, ftEnd;
GetSystemTimeAsFileTime(&ftStart);
GetSystemTimeAsFileTime(&ftEnd);
ULARGE_INTEGER liStart = { ftStart.dwLowDateTime, ftStart.dwHighDateTime };
ULARGE_INTEGER liEnd = { ftEnd.dwLowDateTime, ftStart.dwEndDateTime };
printf("Duration: %I64u ms\n", (liEnd - liStart) / (10 * 1000));
or, if you dont mind using casts since ULARGE_INTEGER and FILETIME have the same structure:
ULARGE_INTEGER liStart, liEnd;
GetSystemTimeAsFileTime((FILETIME *)&liStart);
GetSystemTimeAsFileTime((FILETIME *)&liEnd);
printf("Duration: %I64u ms\n", (liEnd - liStart) / (10 * 1000));
|
|
|
|
|
Hi all,
I have made a Dialog based application, on that dialog I have 3 option buttons and one push button. On click of option buttons a variable called flag value is being set to 1,2 or 3 respectively. my problem is that when i click on push button i hide it and after that flow of control automatically transfers to any option button click code and it changes the flag value....
my stop button and option button is not having any relation with each other....
I have tried it in new application it works fine... but i want to correct it in my exsisting application...
How can i resolve it
Thanks in advance
|
|
|
|
|
VCProgrammer wrote: I have made a Dialog based application, on that dialog I have 3 option buttons...
Do you mean radio button?
VCProgrammer wrote: my stop button and option button is not having any relation with each
other....
Which means what?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
|
Check if you are duplicating button ids in any way. or using wrong message mappings.
|
|
|
|
|
Could someone please give me some guidance how to troubleshoot this?
I am using OpenCV1.1 ( required for VC6.0) and have added functions requiring another OpenCV library - cxcore.
The library compiles without error and builds cxcored110.dll.
My application also compiles without error but fails to start.
I get "application failed to initialize...0xC0150002)" first, then in debug this snippet
...
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'X:\XP\Program Files\OpenCV\bin\cv110.dll', no matching symbolic information found.
LDR: LdrpWalkImportDescriptor() failed to probe x:\xp\Program Files\OpenCV\bin\cv110.dll for its manifest, ntstatus 0xc0150002
First-chance exception in OpenCV_.exe (NTDLL.DLL): 0xC0150002: (no name).
The thread 0x4C0 has exited with code -1072365566 (0xC0150002).
The program 'Z:\0\0 OpenCV_\V 1\OpenCV_\Debug\OpenCV_.exe' has exited with code -1072365566 (0xC0150002).
I also get another pop up error message
Could not execute - path not found (Win32 error 3)
I have compiled all OpenCV libraries in debug and they should have suffix ..d, but I do not get why "failed to probe ...cv110.dll" , it should be cv110d.dll.
Please note that I switched from Win2000 to XP and now I am getting this error ( on new application build from scratch in XP).
Similar application runs just fine in Win2000.
Please refrain from suggesting to "upgrade" to OpenCV2.2 etc.)
Any constructive help will be as always appreciated.
Thanks for reading.
Vaclav
-- Modified Friday, March 4, 2011 11:26 AM
|
|
|
|
|
Hi,
I have a project which I originally built as an MFC extension DLL using Visual Studio 2008 App Wizard. I would now like to be able to build the same project as a static library but I don't know how to do this.
Ideally, I would like to retain both DLL and static builds.
Can anyone please advise?
thanks Tony
|
|
|
|
|
In the toolbars at the top there is the configuration boxes, 1 containing Debug or Release and the other containing Win32. Drop down either of those boxes and select Configuration Manager.
From the Configuration Manager you can add extra configurations to each individual project.
Select the configuration (debug or release) next to your MFC DLL project and select <new> from the dropdown. Call it Static Debug (or anything else if you feel like it) and then change Copy settings from: to Debug.
Repeat again for Release, calling it Static Release.
If you want to change the default configuration from DLL to static LIB then you can change the Configuration type for the MFC DLL in the Configuraion Manager that is to be build with the Debug and Release compiles.
Close the Configuration Manager.
Now right click on the MFC DLL project in the solution explorer and select Project Properties.
Change the configuration at the top of the properties box to Static Debug, then go to the General page from the list at the left. change Configuration Type to Static Library.
Do the same for Static Release.
You may need to change a few other things as well, there is probably a definition in the C++>Preprocessor page for DLL or something that you will need to get rid of.
|
|
|
|
|
Thanks Andrew, this is exactly the information I needed.
Tony
|
|
|
|
|
I have a recursive CountFiles function that I just can't get to work properly. It counts all files in all directories under a given root. But when I run it it allways returns somewhat less nr of files than expected. I suspect I've made a logical dive somewhere, but I just can't see it! The code below is supposed to return 13.301 files for my image library, but comes with 12.110... Can anybody see what my mistake is??
int CBackupImagesDlg::CountFiles(const CString strRoot)
{
int count=0;
CFileFind f;
CString strDir = strRoot;
strDir +=+ _T("\\*");
CString csNewPath(_T(""));
if(f.FindFile(LPCTSTR(strDir)))
{
while(f.FindNextFile() )
{
BOOL bDir=f.IsDirectory();
BOOL bDot=f.IsDots();
csNewPath = f.GetFilePath();
if (bDot)
continue;
if(bDir)
{
count=count + CountFiles(csNewPath);
}
else
{
count++;
}
}
}
f.Close();
return count;
}
modified on Thursday, March 3, 2011 12:56 PM
|
|
|
|
|
Hi!
You are missing 1 file per call to countfiles(). Simply move the while to the bottom of the loop to solve this.
if ( f.FindFile(LPCTSTR(strDir)))
{
do
{
...
}
while ( f.FindNextFile() );
}
Regards
Frank
|
|
|
|
|
MSDN states that you must call FindNextFile() at least once before calling any other member function. Are you saying that's no longer required?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Very strange indeed, MSDN[^] says certain functions require a FindNextFile being executed first, however as FindFile returns the first file, and FindNextFile finds the next ones, how could one execute those functions on the first file at all?
Anyway, the Win32 functions FindFirstFile, FindNextFile don't show such a remark, although here[^] is a note suggesting to call GetFileInformationByHandle() . So did the MFC guys ignore the note? or is it no longer relevant?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I've always coded my recursive CFileFind code as follows:
void ProcessFolder( LPCTSTR lpszPath )
{
CString strPath(lpszPath);
CFileFind fileFind;
if (strPath.Right(1) != _T('\\'))
strPath += _T('\\');
BOOL bFound = fileFind.FindFile(strPath + _T("*.*"));
while (bFound)
{
bFound = fileFind.FindNextFile();
if (fileFind.IsDirectory())
{
if (! fileFind.IsDots())
ProcessFolder(fileFind.GetFilePath());
}
else
{
}
}
} It's worked for years like that.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
you're right, I had to read once more to discover in MFC FindFile opens the search but does not return the first file, so FindNextFile is needed to find even the first file; this is different from how Win32 works, and IMO quite confusing (FindFile should have been named PrepareFileSearch or something similar).
This also means the first reply (by Frank) is wrong, and the wrong count hasn't been explained yet.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thank you, David! I tried your code, and it works like a charm!!
I'm still not certain what was wrong with the original function, but that investigation has to wait for another day! Anyhow, thank you all for your help, David in perticular!
|
|
|
|
|
Mr_Gbg wrote: The code below is supposed to return 13.301 files for my image library...
According to what?
Mr_Gbg wrote: strDir +=+ _T("\\*");
What is +=+ ?
Mr_Gbg wrote: if(f.FindFile(LPCTSTR(strDir)))
Why the superfluous cast?
Mr_Gbg wrote: The code below is supposed to return 13.301 files for my image library, but
comes with 12.110... Can anybody see what my mistake is??[Rose]
To make sure your recursion logic is sound, you might try moving count outside of CountFiles() , either by making it global or a member variable.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Good Questions, both of them! Sloppy programming I guess is the answer. Fixed now, thanks!
I've tried the whole global count variable thing as well, I still can't see a way around this... Grrr!
|
|
|
|