|
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
|
|
|
|
|
sheshidar wrote: Hi I developed a GUI and i want to save all selected data in a text file,
see CStdioFile
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I want to display an Excel Diagram on one of my property sheet. I write my programm with VC++6.How can i do it?Could someone help me?
and what means LPDISPATCH GetDiagram()?What will i get? Is the value of the diagram ? Or a diagram?
Thanks!
grf
|
|
|
|
|
I'm not entirely sure what you intend to do, but I think you'll need to investigate COM. I believe the new name for doing such things is .net, but I don't think that is supported by VC++6(I may be completely wrong about this though as I haven't used visual studio much in the past)
I believe under the projects menu there will be a menu "Add Class", which will generate some header files for you to interface with COM objects. Do a google for COM etc. You can also use MSDN.com as a resource.
Be warned though if you go down this path, as most documaentation you will find will be for VB applications, and a strong use of variant types can make debugging a nightmare without docs.
|
|
|
|
|
Use class wizard to add class from type library function and fro the TLB file u will get the interface needed to program any app that support OLE COM etc
|
|
|
|
|
My job is to write in Excel ,read from Excel and display Diagram .Now i could write and read.I've used EXCEL.EXE from type library function to write/read (Excel.Application, Excel.Workbook,Excel.Sheet...).But i don't know how to display with VC++. I know that it is no easy to do it with VC++.But i have to use VC++ .
|
|
|
|
|
I would like to change the view in a SDI app. I would like to have three different view of the same doc.
Thanks.
|
|
|
|
|
Consult MSDN article Q141334.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Thanks, thats work fine! The next thing that I would like to have, is a dynamic menu for each views. The main menu will contain a top menu item called "Operation" and each views will have different operations. So, how can I do that?
My first idea was to create a popup menu for each views and attach the popup menu to the top menu "Operation". But I really need help to do that.
Thanks again.
-- modified at 11:18 Thursday 5th January, 2006
|
|
|
|
|
I'm not exactly sure, but this article, even though it is for MDI, may be of some help.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I don't want to change the toolbar, but the menu. And not all of the menu, only the sub-menu of a top level menu item.
|
|
|
|
|
Hai All,
I am doing a project related to TAPI.When i am executing the appllication ,i got an error that the selected line does't support voice capabilities.What will be the problem? How can i identify that my modem having suitable driver.(I am using voice modem).Help me please...
With regards
Jeeva
|
|
|
|
|