|
OK -- now I have uninstalled Dr. Watson on the machine in question and sure enough, when I run the test program, it gets to the GetFtpConnection call and then aborts with "The instruction at "0xaddress" referenced memory at "0xaddress"".
|
|
|
|
|
Hello Friends,
I'm developing an application, Where sound data has to be captured from a pci based "sound card" and the processed data has to again fed back to the sound card so that it can be listened by plugging-in a headphone.
I've used Microsoft Visual C++ 6.0 as a platform and DirectX commands for capturing the soundand processing it.This part(CApturing and processing) works well ,but i'm not able to stream the data back to the card.
Can anyone help me in this or refer to any directx programs which does this kind of an process.
Thank You In Advance
Rajeev
|
|
|
|
|
Hi,
I have an MFC application with a main window and a child window. Since my main window shouldn't have any menu/toolbars, I have to use a button on child window to close the whole application. For example, when I click the close button on the child window it calls the close routine in the main application and the whole application should terminate and exit. But, when i am trying to implement this, I am getting illegal memory reference at the point when I am destroying the main application (sometimes at the point when I destroy the child window).
Anyone have any ideas on this issue. I would also like to know if there is any way to implement this (terminating and exiting the main MFC application from child window).
thanks,
-Pav
|
|
|
|
|
Try POSTING a WM_CLOSE message to your main application window and see if that helps. I think you are resulting in a crash because you are directly calling the main close function, which is problematic, since your child window is busy processing an existing message (button click). By posting to main window, you decouple the two events and regular processing of close sequence can occur.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Hi,
thanks for the reply. The command WM_CLOSE basically calls Destroywindow() function if I am right. I noticed that there is no error when I close the main application from the child window only when I didnt use any of the buttons or options on child window. My child window contains buttons which call functions defined in main application window. But the crash happens only when I try to close the main application after using any of the child window buttons and I noticed this crash happens when I try to close and destroy the child window from main application.
here is the code-
void main_application::OnClose()
{
...
...
...
child_window_instance->DestroyWindow(); <------
delete child_window_instance;
DestroyWindow();
}
void child_window::OnClose()
{
parent->OnClose();
}
I am getting error at the line marked with arrow. Any suggestions?
thanks,
-Pavan
|
|
|
|
|
In your child window OnClose, you might be setting up a circular dependency.
It calls parent close, which calls child destroy, which results in child close, etc.
I would mereely POST a message to parent to close - call
PostMessage(hParentWindow, WM_CLOSE, 0, 0);
instead of directly calling the parent->OnClose();
This would give your child window OnClose a chance to return from its processing first.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Sorry if I am asking to much. So what you are suggesting is, instead of calling parent->OnClose() in Childwindow's OnClose function, its better to use PostMessage function in the place of the above command in Childwindow's OnClose function. Is my interpretation right?
If so, then can you tell me how to call that function in childwindow's OnClose function? From where can i get the handle for the parent window(main application)?
I was still not able to understand how come it is closing application with out errors when i try to close without using any of the options in child window and just clicking on the close button.
thanks,
-Pavan.
-- modified at 16:45 Thursday 5th January, 2006
|
|
|
|
|
Yes.
If your 'parent' is already a CWnd, then you can use parent->m_hWnd as the window handle.
Otherwise, AfxGetApp()->m_pMainWnd->m_hWnd should be the main window handle.
Or you can try
CWnd* pWindow = AfxGetMainWnd( );
pWindow->m_hWnd
would be main window handle.
Because the main parent window closing does not seem to invoke the child closing directly. I think if you call DestroyWindow the OnClose is not called. However, if you are IN the child and closing, then you were getting into trouble.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
I can use parent->m_hWnd, but how can I pass 4 parameters using the CWnd::PostMessage function? it accepts only 3 parameters. Whereas the Windows SDK's PostMessage takes 4 parameters.
-Pavan.
|
|
|
|
|
parent->PostMessage(WM_CLOSE);
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Thanks, I have just used the same command. But still I am getting the same error while I am closing the child window (Access Violation error) to be detail -
In debug mode it is giving as follows-
'Unhandled exception in mainapplication.exe :xC0000005: Access Violation'
and then in the stack it is pointing to memory 00000000 address
and sometimes in this mode it is also pointing to a statement in AFXWIN.H like WinProc(msg,wparam,lparam)
In actual execution mode it is giving as-
a crash error and then 'The instruction at "some address" referenced memory at "some address". the memory could not be read'
-Pavan
|
|
|
|
|
I have noticed another thing. It is giving the same error when i try to destroy the childwindow within its OnClose() function and not calling any function of main application in it. Do you have any idea on this situation. The error occurs only when i click any of the buttons i have on the child window which calls a function in the main window and then try to destroy the child window using its OnClose() function.
thanks,
-Pavan
|
|
|
|
|
Instead of using PostMessage function, I use SendMessage with the message as "WM_SYSCOMMAND"
here is the example:
<br />
::SendMessage(pParent->m_hWnd,WM_SYSCOMMAND,SC_CLOSE,0); <br />
I guess the assertion error may be related to your child window?
You should better have a look what you have done on Destroying child window, especially pointers stuff .....
Hope this help
|
|
|
|
|
Yep tht's right, the error is from childwindow only and arising only when I am destroying it even in its own OnClose function and again this happens only if I use any of the buttons on my childwindow which have calls to parent functions in them. The only pointer object i am having in my hcild window is a pointer to its parent window and all the functions and some public variables of the main application are called using tht pointer. I am not able to understand why I am getting this error only when I try to destroy the child window either directly or indirectly.
-Pavan
-- modified at 22:56 Thursday 5th January, 2006
|
|
|
|
|
How you create the child window?
In addition, have you trace in debug window line by line to see at which line the problem occur?
|
|
|
|
|
The child creation is by defining a pointer object tot he child dialog class. Yep, i did traced it line by line and the result is it is having a null memory reference at the time when it is trying to destroy the child window or even if i comment the child window destroy statement and try to destroy the main window directly (which is of ocurse not the right way to terminate an application). So, what I doubt is the child destroy function is trying to free or access a null reference, but dont know where it happens.
thanks,
-Pavan.
-- modified at 0:01 Friday 6th January, 2006
|
|
|
|
|
I assume what you have done is as follow:
<br />
<br />
{<br />
<br />
dChildDlg = new CChildDlg;<br />
dChildDlg->Create();<br />
<br />
};<br />
<br />
If the case is similar, maybe you check if you call :
delete dChildDlg
somewhere before you call:
dChildDlg->DestroyWindow()
Hope this help a bit~
-- modified at 4:35 Friday 6th January, 2006
|
|
|
|
|
My whole childwindow creation in main window initdialog goes like this-
RECT rect;
achild = new CChildWindow(this);
achild->Create(IDD_CHILD_WINDOW,this);
achild->GetClientRect(&rect);
achild->MoveWindow(0,650,(rect.right-rect.left),(rect.bottom-rect.top)); achild->ShowWindow(SW_SHOW);
then some of the functions in childwindow calls the functions in main window like this-
void CChildWindow::OnFunction1()
{
// TODO: Add your control notification handler code here
parent->OnKeyFunction1();
}
so, where am i referencing a null memory while destroying my child window???
-Pavan
|
|
|
|
|
there is a problem
assume your OnKeyFunction1 at parent (CMainWindow::OnKeyFunction1()) is for closing the application, in it you will KILL the child (i.e. delete the pointer of child window or equivlant) and so the function don't know how to return to the child part (CChildWindow::OnKeyFunction1)!!
so, what you have to do is change the structure:
1. Use callback function to use parent window function instead of directly calling, callback allow window to handle when to call the function
2. Use Send message as the "tunnel" for commuincation for some command function
3. try to build the function in child only if it only consider to be used in child
hope this help!
|
|
|
|
|
Hi,
Thanks for ur replies. Today I recognised one thing which is causing me the same error. Actually my program is having 2 threads running parallel (but will be in suspended state when they r not used and resumed when needed) to the main application. My application is terminating well without any errors if I am not starting any of the threads. But when I have started them even once and then try to terminate the application or even if I click on the main application window it is giving me the same error, Access Violation and at the time of debugging the error it is sometimes pointing to
// delegate to object's WindowProc
lResult = pWnd->WindowProc(nMsg, wParam, lParam);
in WINAFX.h. Any idea??
-Pavan
-- modified at 16:47 Monday 9th January, 2006
|
|
|
|
|
hmm.... those thread are worker thread or UI thread?
|
|
|
|
|
Those threads are worker threads, i hope. But there is a statement in those, which calls another child window on the main application using the window handle and updates the image of tht window (since this application is a real time image grabbing application).
-Pavan.
|
|
|
|
|
Hi I developed a GUI and i want to save all selected data in a text file,
how can i do this, if any have some idea than please help me.
Thanking you
|
|
|
|
|
learning to save thing in the file is very elementary, you should first look up in google before. There are tons of samples out there.
-Prakash
|
|
|
|
|
Hi,
If the size of data is small, try serialization.
Thanks and Regards,
Cool Ju
Dream Ur Destiny
|
|
|
|