|
Hi all,
I am working on a dialog-based MFC application, which consists of multiple property pages. From one of the property pages, I am trying to launch a dialog box which contains an ActiveX control.
This is currently not working and the application exits with an access violation error when I call DoModal for the dialog. On debugging, I see this is due to AfxGetThread() returning NULL in AfxOleInit(). This does not happen if I launch the dialog-box from the application's InitInstance() function instead of a property page or if I add the control to the property page itself. I have made sure that the control is registered and that I call AfxEnableControlContainer() from the application's InitInstance() function.
I am using Visual Studio C++ .NET.
Is there something else that I have missed? Any help is greatly appreciated.
Thanks,
Priya
-- modified at 6:46 Thursday 16th August, 2007
|
|
|
|
|
Is OLE as applicable as of now in terms of its support and are there others technologies that do an exact override of the functionality in OLE.
|
|
|
|
|
tom groezer wrote: Is OLE as applicable as of now in terms of its support
Huh? You mean COM? COM is heavily used in Windows systems.
tom groezer wrote: an exact override
You mean different but with "similar" features. What would be the point of being different but exactly the same?
|
|
|
|
|
I've seen some codes using delete[] blah; and someone else delete blah; .
I didn't read in any book how to use them and what's difference. It's a couple of years that I'm programming and using just delete. Does any one know what is the difference and when we need to use those brackets?
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: delete[] blah; delete blah; .
what's difference
Simple: If the memory was new ed with [] , use delete[] , otherwise normal delete.
delete[] calls the destructors of the elements of the array before freeig the memory, whereas delete does not.
You might get away with using the wrong one, until you are really under pressure. Then the whole sh*t will explode in your face.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
What a big memory leak in some of my applications.
Thank you.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: What a big memory leak in some of my applications.
Not necessarily[^] if you were using VC++, at least according to Stan Lippman.
But in general, this leads to undefined behavior and should be avoided.
|
|
|
|
|
I was wondering why I didn't notice this type of memory leak reports already. I'm mostly very careful about it. I used vld dll for a while.
So it is possible that this does not result in a memory leak in VC++, but worse than that, it might lead to an unknown behavior. Why VC++ compiler doesn't generate a warning? or perhaps it does in level4?(I often use the default level3)
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: but worse than that, it might lead to an unknown behavior
No, my understanding is that with VC++ it works fine either way (haven't tried it though ). However, the C++ Standard says that such a case leads to undefined behavior which means that with other compilers (or a new version of VC++) you may see just about anything at all: leaks, crashes, destructors not being called - you name it.
|
|
|
|
|
Thanks.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Wow - four letter words get automagically beeped here.
I did write a 'i' instead of a '*" in the post above.
-- modified at 11:46 Wednesday 15th August, 2007
Being too soapboxy
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hamed Mosavi wrote: I didn't read in any book how to use them and what's difference.
Why not?[^]
|
|
|
|
|
Thanks.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
you must call delete [] if you have an array of objects.
if you leave out the [] the destructor only is called for the first object of the list.
So, to be sure not to get resource/memory leak you have to use [] for arrays.
|
|
|
|
|
I have written an application that has a system tray icon. When the OnClose() event of the main form is executed I just hide the form without letting the application exit. But my problem is when Windows is restarted the application cannot exit because the OS just sends WM_QUIT which does not terminate the program. Do you have any idea how I can solve this problem?
Thank you in advance!
modified 8-Mar-17 3:49am.
|
|
|
|
|
Daniel Kanev wrote: WM_QUIT which does not terminate the program.
Why not?
|
|
|
|
|
It's because when the main form receives WM_CLOSE I just hide it.
modified 8-Mar-17 3:48am.
|
|
|
|
|
Daniel Kanev wrote: WM_QUIT
Daniel Kanev wrote: WM_CLOSE
they are not the same thing. You said the app doesn't quit when WM_QUIT is sent. I asked why not and you answer with what you do in WM_CLOSE. Do you see a problem with this conversation?
|
|
|
|
|
Yes, you are right. I may not be doing the right thing
Thanks
modified 8-Mar-17 3:48am.
|
|
|
|
|
(That question must have been answered before, but I'm not certain what to google for, and it's not urgent.)
I have a pop-up menu on a CTreeCtrl filled with dynamic values :
while( SomethingIsTrue)
{
groupMenu.AppendMenu(MF_STRING, 0, someDynamicString );
}
I know I could use a range of predefined range of values, but It will make thing harder since I will need to create a temporary map of value-pair between the menu ID and the string (data) that is inserted in the menu.
The pop-up is called with TrackPopupMenu , even if I use the TPM_RETURNCMD flag, I still need to have a valid ID to know which menu item was selected ?
The question I have is :
Is it possible to get the string from the selected menu item ?
Thanks.
Max.
|
|
|
|
|
I have an application MyApp which spawns 2 process A and B. MyApp cannot communicate to either A or B. MyApp first starts the process A and It has to wait untill A has completed initilization and reaches a stable state which is approx 4 mins. MyApp should remain idle during this time period. After 4 min, MyApp starts process B and should wait for approx 2 min and shutdown.
What is the best method for suspending MyApp for the above said duration using very little system resources? I do not want to use Sleep() for this purpose.
|
|
|
|
|
I am unsure if this applys to you, but have you considered WaitForSingleObject()?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Use the Event?!
WaitForSingleObject(..., 4 minutes, ...).
Maxwell Chen
|
|
|
|
|
koumodaki wrote: I do not want to use Sleep()
Why not it suspends the thread using very little system resources and so meets your requirements?
|
|
|
|
|
Perhaps he's afraid that he'll forget to set the alarm and oversleep.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|