|
tBoai wrote: English-Japanese dictionary, IM chat, and P2P file sharing ...
There is an old saying --- "Do one thing at a time!"
... especially you said that you are a beginner. I doubt that people would use that software made by a beginner. If you really made one, maybe we would use the dictionary portion. But not the file sharing function! Who knows if there any risk to crash my file system?!
OK, the above was the educational words. Since this is a technical forum and I should provide something meaningful to your questions.
Dictionary: Spelling checker dictionary[^].
File sharing, hashing/indexing, IM chat: Source code of eMule Plus[^].
Maxwell Chen
|
|
|
|
|
Hi,
I've coded a dialog based app that allows you to drop files into a listbox.
Once the drop has taken place I've written some code to check if the files dropped are already listed in the lisbox - and if so a dialog box shows asking the user if they want to replace their existing files (pretty much like windows explorer).
My problem is, everything works fine until the end of the DropFiles function is reached..when it returns the program crashes from the following Assert:
ASSERT(::IsWindow(m_hWnd));
Anyone know how to fix this?
Thanks in advance.
|
|
|
|
|
Where is the assert? What this is saying is that the HWND identified by the member variable m_hWnd is not a valid window. To say more I would need more info like:
- The callstack.
- Some code around the assert.
- The value of m_hWnd .
Steve
|
|
|
|
|
The assert is coming from wincore.cpp (void CWnd::AssertValid() const)
If I comment out the domodal part of the code it works fine, it's only when domodal is called that the problem occurs at the end of the function.
void CWnd::AssertValid() const<br />
{<br />
if (m_hWnd == NULL)<br />
return;
<br />
ASSERT(HWND_TOP == NULL);
if (m_hWnd == HWND_BOTTOM)<br />
ASSERT(this == &CWnd::wndBottom);<br />
else if (m_hWnd == HWND_TOPMOST)<br />
ASSERT(this == &CWnd::wndTopMost);<br />
else if (m_hWnd == HWND_NOTOPMOST)<br />
ASSERT(this == &CWnd::wndNoTopMost);<br />
else<br />
{<br />
ASSERT(::IsWindow(m_hWnd));<br />
<br />
CHandleMap* pMap = afxMapHWND();<br />
ASSERT(pMap != NULL);
|
|
|
|
|
Stephen was asking for some code of your own. So, use the call stack to find in which function it crashes (or you can also use your debugger, which is very very helpfull).
|
|
|
|
|
<br />
int RetVal;<br />
int nFiles = DragQueryFile(hDrop, -1, szDroppedFile, 2048);<br />
for(int i=0;i<nFiles;i++)<br />
{<br />
DragQueryFile(hDrop,i,szDroppedFile,2048);<br />
GetFileInfo=GetFileAttributes(szDroppedFile);<br />
hFile = FindFirstFile(szDroppedFile, &FindFileData);<br />
FileSize=FindFileData.nFileSizeLow;<br />
<br />
int x=CheckForDupeName(false, true, FindFileData.cFileName, -1);<br />
if(x>-1)
{<br />
CFileReplace md;<br />
md.ReturnValue=&RetVal;<br />
md.DoModal();<br />
<br />
...<br />
}<br />
<br />
...<br />
If I comment out the 3 lines regarding the CFileReplace function and assign a value to RetVal the function works fine, it's only by calling DoModal that the error occurs.
|
|
|
|
|
What does the CFileReplace dialog do when it is being dismissed?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
GrumbleWeedster wrote: it exits with OnOK()
That's all that's in CFileReplace::OnOK() ?
Is CFileReplace::ReturnValue a pointer? Where does it get assigned a new value?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
At this moment it isn't returning a value because of the current problem, it's still a plain dialog box with an OnOK() to close.
|
|
|
|
|
Ok, so what happens in CFileReplace::OnInitDialog() ?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Nothing.
At the moment CFileReplace is an empty default dialog with and OK and Cancel button.
There are no custom functions in place yet because I need to get around the initial error.
|
|
|
|
|
GrumbleWeedster wrote: At the moment CFileReplace is an empty default dialog with and OK and Cancel button.
There are no custom functions in place...
Based on that, can we then assume that it has no bearing on the problem?
Also, answering this question will go a long way towards the solution.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I may have found a solution but can anyone tell me if it could cause a problem?
Changing the code in PreTranslateMessage(MSG* pMsg) stopped the error from occuring:
Original Code: (Not Working)
<br />
if( pMsg->message == WM_DROPFILES) OnDropFiles(pMsg->wParam,pMsg->lParam);<br />
return CDialog::PreTranslateMessage(pMsg);<br />
Modified Code: (Working)
<br />
if( pMsg->message == WM_DROPFILES)<br />
{<br />
OnDropFiles(pMsg->wParam,pMsg->lParam);<br />
::TranslateMessage(pMsg);<br />
::DispatchMessage(pMsg);<br />
return TRUE;<br />
}<br />
else return CDialog::PreTranslateMessage(pMsg);<br />
As I said, this does make the function work correctly, but is it a solution or is it just diverting from the error?
|
|
|
|
|
GrumbleWeedster wrote: if( pMsg->message == WM_DROPFILES)
What's this? Why are you looking for this message in the PreTranslateMessage() method? You should be handling the WM_DROPFILES message via the message map:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
ON_MESSAGE(WM_DROPFILES, OnDropFiles)
END_MESSAGE_MAP()
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Dialog based applications can't seem to handle drop files that way.
Nothing is ever added to the list when items are dropped. The only way I've found to enable drag and drop in a dialog based app is intercept the message in PreTranslateMessage()
|
|
|
|
|
GrumbleWeedster wrote: My problem is, everything works fine until the end of the DropFiles function is reached..when it returns the program crashes from the following Assert:
ASSERT(::IsWindow(m_hWnd));
Anyone know how to fix this?
So what is happening within the DropFiles() function?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
This error can occours if you destroyed that CWnd object into the DropFiles function.
else, be more clear to understand how the error comes, or how work the function.
Have a nice code day
|
|
|
|
|
I am building a directshow source filter, but I received the error message "LoadLibrary("xxx.ax") failed - The specified module could not be found." when I registered the filter. I used some DLL to build the filter. Thanks for any information about the error message.
|
|
|
|
|
I think the error message is pretty clear no ? There is a missing library. Add this missing file in the proper folder (probably the working directory) to solve the problem.
Otherwise give more information about the problem.
|
|
|
|
|
Thanks. You are right. I used dependencywalker to find out what dlls are missing, and added those dlls in the same directory. Problem was solved.
|
|
|
|
|
how to having some 32 bit number invert only a single bit in it
some clever stuff of ~&| ops is needed
0100101010011[1]001001010100111001 to invert 1 value bit
0100101010011[0]001001010100111001
or
01001010100111[0]01001010100111001 to invert 0 value bit
01001010100111[1]01001010100111001
9ine
|
|
|
|
|
DWORD dw = 0xFC246A09;
DWORD mask = 0x00008000;
if ((dw & mask) == mask) {
dw &= ~mask;
}
else {
dw |= mask;
}
|
|
|
|
|
If you just want to toggle you could use xor
dw ^= mask;
codito ergo sum
|
|
|
|
|
oh yes just to toggle
9ine
|
|
|
|