|
I can invoke COM server functions in my thread by doing this :
#define _WIN32_WINNT 0x0400 in my stdafx.h file.
That works ok.
Now the moment I add an Active X component in my Project (Dialog Application), I get the following in Debug :
Warning: OleInitialize returned scode = RPC_E_CHANGED_MODE ($80010106).
Warning: CreateDlgControls failed during dialog init.
and the App fails to run .
|
|
|
|
|
Boy! Are you in for a ride...
Do a google for some of the following words:
STA
MTA
Apartment
COM Threading Model
You will find tons of information, most of which you HAVE to read
(There is no short explanation to your problem, sorry)
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
We are all aware that by default VC++ implementation of NEW does not throw an exception (as it should based on C++ standards).
MSDN has an article related to using set_new_handler() to make new throw std::bad_alloc when it fails instead of returning NULL.
My question is how is that handled in an MFC app? For instance lets say you have a method named Foo(), and Foo() might throw std::bad_alloc due to it calling new internally. If you called Foo() from an MFC class method you override, and did not have a try/catch, would MFC catch the bad_alloc?
In fact, what impact does it have at all on MFC if you change NEW to throw?
I'm also curious how other developers handle NEW... Do you leave it returning NULL by default? If so, won't that cause problems if you use STL and an STL method calls new and it throws?
|
|
|
|
|
MFC has its own override of operator new that throws a CMemoryException .
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Yep, and that is what happens when MFC calls new and it fails.
But what happens if you call STL or your own funtions from within an MFC function override and your new handler is called throwing bad_alloc?
It appears that MFC wont catch it, you will get an unhandled exception. If you try to recover from it, you might leak MFC resources.
PS: Did this change in VC .NET? Or does new still return NULL?
|
|
|
|
|
I've got a group box on my dialog that shows up as transparent. All controls have transparent UNchecked. Any ideas?
Well, actually, I just fixed it by selecting 'transparent' for the group box. What's the deal with that?
BW
"Gandalf. Yes. That is what they used to call me. Gandalf the Grey. *I* am Gandalf the White."
- Gandalf the White
|
|
|
|
|
i dunno what a transparent groupbox even looks like maybe a picture?
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
The "transparent" setting is a little counterintuitive. You can look up details about it in MSDN under "WS_EX_TRANSPARENT".
One description in MSDN says, WS_EX_TRANSPARENT Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated.
For example, if you have CStatic text written on a dialog, and it is NOT transparent, then the CStatic control will fill the control's rectangular window with a background color (usually gray) before writing the text. This has the effect of erasing anything that was drawn there previously. If "transparent" is specified, the CStatic control will not fill the control's rectangular region with gray before writing the text. (If I remember correctly - that's how it works.)
So, why is your group box showing up transparent? If it is a custom-designed control, then the developer might've forgotten to actually do the rectangular-area fill before drawing everything else. The dialog won't fill this rectangular region because "it's under the ownership of the group-box" and because it is non-transparent, it is not the dialog's responsibility to fill it.
------------------------------------------
"Isn't it funny how people say they'll never grow up to be their parents, then one day they look in the mirror and they're moving aircraft carriers into the Gulf region?" - The Onion
|
|
|
|
|
This may be a simple question, but is there a way to catch when an MFC application is maximized? It would be great if there is a message or something I could override and add my code to....Thanks!
|
|
|
|
|
WM_SIZE(SIZE_MAXIMIZED, ...
|
|
|
|
|
Exactly what I needed! Thanks!
|
|
|
|
|
I have a point in one of my classes where I need to send the users focus to the next field in the tab order, is there a way I can throw a <tab> keypress, or a way to set focus to the next field in the tab order?
thanks for any suggestions
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
NextDlgCtrl();
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks for the quick responce i was using a CFormView, and it wouldn't let me use it, but i realized my problem was that i was creating my edit fields with WS_READONLY instead of WS_DISABLED.. my program was stopping at uneditable fields and i didnt want it to, didnt realize it was cause it wasnt disabled
ill keep this answer in mind tho, im sure ill need it sooner or later
thanks again!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Hello,
I've searched but have been able to come up with anything on this, so any input would be appreciated
The problem:
When my process is taking care of some lengthy processing, the Applications tab of the Windows Task Manager reports it as "Not Responding", when in reality it is just busy working hard. The problem is that most users confuse this by stating "The process is hung" and try to kill it, etc. They don't realize that ( NotResponding != Dead ) which is probably not their fault, but M$'s for choosing such a term to "label" a busy process.
My question:
Is there any way to programatically control what is displayed here? Or, what would probably be a better solution, send "I'm still alive and working" type messages to the Windows Task Manager so that it doesn't report the process as Not Responding?
Thanks!
--
Edward Livingston
(aka ExtraLean)
--
"I still maintain that seeing a nipple is far less disturbing than seeing someone get their brains blown out." -- Chris Maunder
|
|
|
|
|
The process is too busy in it's main thread for it's message loop to respond to windows. You need to do this work in a worker thread.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi Christian, long time we didn't fight for a question
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
*grin* I must admit I'd never seen your solution before. Will it make the UI responsive, or only *seem* responsive ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
It'll only fool the Task Manager into thinking the app is responsive, but this is what the guy asked for.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That's fair enough, I was only curious for myself because I'd not seen it before at all, so I wanted to know for my own reference.
Thanks
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Try inserting
MSG msg;
PeekMessage(&msg,NULL,0,0,PM_NOREMOVE); every so often within your lengthy processing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The problem is that your "lengthy processing" is taking more than 5 seconds to complete, and during this time, it does not have a chance to process windows messages. The windows task manager will wait five sconds before deciding that a windows task is "dead", and will show the task as "not responding" as long as this condition is true.
Here's the code I use:
MSG msg;
if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
I usually put this into a "while" or "do" loop when I'm waiting for another flag to be set to allow processing to continue.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
I renamed the OK button : ID_FAKEOK and changed its tab order. Then my modeless dlg didnt vanish when I hit ok. BUT.....I dont want this button at all!!!! So when I deleted it, now the modeless dlg vanishes again when I hit enter.....
I plan to send and receive lots of messages in this CDialog so I think I cant pre-translatemessage it.
How shall I correct my enter-key response?
Appreciate your help,
ns
|
|
|
|
|
Try overriding OnOK with a do-nothing function.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That did it!!!! Many thanks!
Appreciate your help,
ns
|
|
|
|