|
MFC objects do not operate well across threads. There are some Knowledge base articles on MSDN that explain why. Basically they use thread local storage to map the resource handle to the C++ object pointer. So in another thread the mapping does not exist.
So always pass the resource HANDLE rather than an MFC C++ class pointer across threads. then if you want to use MFC classes in the thread you can attach the HANDLE to a thread local scope MFC object.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Pass the HDC.
Make sure the CDC is retreived by GetDC.
Make thet window class has CS_OWNDC. you get it on WM_CREATE.
you can set the GDI objects into this context once and thay persistent
couse to CS_OWNDC.
|
|
|
|
|
Hi suiram
Thanks for your response.
Yes i am passing hdc to the thread.
I tried with CS_OWNDC, But of no improvement. My problem is with the CDC of PrintPreview. What should i do now.
Please, do help me.
kumari
|
|
|
|
|
Hi suiram
Thanks for your response.
Yes i am passing hdc to the thread.
I tried with CS_OWNDC, But of no improvement. My problem is with the CDC of PrintPreview. What should i do now.
Please, do help me.
kumari
|
|
|
|
|
Any article on how to load a dll made in C# to be used in visual c++ 6. Also if this dll is capable of throwing events how do we handle these events?
Thanks
|
|
|
|
|
as every other dll!?
LoadLibrary!?
GetProcAddress!?
Don't try it, just do it!
|
|
|
|
|
I don't believe that is going to work.
|
|
|
|
|
Probably the easiest way do do it is to expose the C# code as a com object.
The architect has placed his bets,
but the odds are long
-Poster Children
|
|
|
|
|
I dont think you can create a DLL in C#. You can only build an assembly in C#. There is a difference between DLL and Managed assembly, although they share the same extension. To use the assembly from C++, as another reader pointed out convert the C# class to a COM object and use the COM object in VC++. Else you can host the CLR runtime in your VC++ app and then load your assembly there in.
|
|
|
|
|
Do a search for "hosting the CLR". As for catching exceptions, it's probably pretty similar to managed c++.
--
Joel Lucsy
|
|
|
|
|
I want to display Dialog Box from window service, but i am unable to do that
pls help
i am using domodol to show dlg box but it is not showing.
pls help me abt this
waiting for reply
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
My first question would be why would you want a UI component in a service?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
yes i want to display some infoemation to user thorugh dlg box if you know the code pls help me
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I reiterate that this is a bad idea. Most services run on a server locked away in a closet somewhere, so if your service presented any UI elements, such as a message box, no user would be in front of the machine to see and then dismiss it. Also, any windows created would probably appear on a window station or desktop different from the one the user was sitting in front of, and thus the message wouldn't be visible to the user anyway. It sounds like you need a Service Control Program (SCP) instead.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yeah i got the solution.
i have made my service desktop interactive.
all of my problem has been solved thanks for your concern.
now i will use winlogon notifcation package to know wheather the user is login or not
thanks any way
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I suggest that if you write a GUI application that interogates the service. Windows services run before users login and indeed run without a desktop.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
how a Gui application interact with service,have you any idea.
i think wheather i use socket or there is any other way
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
There are various methods of interprocess communication(IPC). Named pipes, memory mapped files and other forms of shared memory.
If you search for IPC on codeproject you can't go far wrong reading about these.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Alok the programmer wrote:
how a Gui application interact with service,have you any idea.
This is what a Service Control Program (SCP) is for. It's how the actual service is configured.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
#ifdef _WIN32_WINNT
#if (_WIN32_WINNT >= 0x0400)
#define MB_SERVICE_NOTIFICATION 0x00200000L
#else
#define MB_SERVICE_NOTIFICATION 0x00040000L
#endif
#define MB_SERVICE_NOTIFICATION_NT3X 0x00040000L
#endif
MessageBox(...,MB_SERVICE_NOTIFICATION)
|
|
|
|
|
what is that sir.
i want to show dlg box
your above code is also not working
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I have two programs, and I need to have a special window open whenever one or both of them are loaded. It's working pretty well, but I've run across a problem: if I load program 1, then program 2, then close P2, then close P1, it works fine (the window isn't destroyed until the last program exits), but if I load P1, then P2, then close P1, the special window is destroyed (because P1 was the program that spawned it). Is there any way to pass the special window from P1 to P2, so closing P1 doesn't close the that window? I can't just recreate the special window, because then it loses its position on the taskbar (moves to the end of the list of open programs).
Thanks!
|
|
|
|
|
When P1 starts, check for the existance of the special window and create it if necessary. Save the window handle for later. When P2 starts, check for the existance of the special window and create it if necessary. Save the window handle for later. When P1 ends, if it has a valid window handle and P2 is not running, close the special window. When P2 ends, if it has a valid window handle and P1 is not running, close the special window. Will that work?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
That's exactly what I'm doing already. The problem occurs when closing P1 but P2 is still running: the special window is closed anyway (which appears unavoidable unless a separate process is used for the special window).
|
|
|
|
|
So are you saying that P1 is closing the special window without first checking to see if P2 is still running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|