|
thanks
i chekout this but there is an error "'static_cast' : cannot convert from 'void (__thiscall CToolTipRessourceButton::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'"
please help me.
|
|
|
|
|
Hi,
When the error is happening?
You tried which? Please provide more info.
As James R. Twine said, try adding TrackMouseEvent() handler for your button and show the Tooltip control inside that function.
If you have problems, please let us know.
Best Regards,
Suman
|
|
|
|
|
3 easy steps:
1: Use the TrackMouseEvent(...) on the controls in question or capture mouse movement messages to see when the mouse is over the control.
2: When the time is right, use the ToolTip control to cause an immediate tooltip to appear.
3: When the mouse moves off of the control, pop the tooltip.
1 easier step:
1: Use the tooltip control - it was designed for this kind of thing. Check the docs for the tooltip control.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
hi
How to typecast BSTR to CString?
give me example
*****THANKS N ADVANCE****
Mathen.K
(I WILL TRY MY LEVEL BEST )
|
|
|
|
|
You cannot typecast it - but you may have to convert it.
If you are in a Unicode build, both the BSTR and the CString are of the same character type, so you can just assign the BSTR to the CString (or use to construct one).
If not, you need to use a conversion function or macro: W2T(...) , MultibyteToWideChar(...) , etc. Although CString may have a conversion constructor...?
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
I created the .ini file manually in C:\ drive and added following
[Section]
a=1
b=2
CWinApp *pApp = AfxGetApp();<br />
free((void*)pApp->m_pszProfileName);<br />
pApp->m_pszProfileName = _tcsdup("C:\\myfile.ini");<br />
<br />
pApp->GetProfileInt("Section", "a", 0);
But GetProfileInt() returns 0 instead of 1.
I went through the registry. There was NO entry of ini section and entry, since i have created ini file manually.
Whether GetProfileInt reads only registry or both registry and ini file?
|
|
|
|
|
You should use GetPrivateProfileInt [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
Where could i find CxImage class... I am working on a sample of BMP to DCM... This sample provided by CodeProject uses a class CxImage.. So the project could not get compiled with Visual C++... How to compile it?
|
|
|
|
|
Hi,
Is this[^] are you looking for ?
Regards,
Paresh.
|
|
|
|
|
If you want to work with image files you ca use of CImage class.
|
|
|
|
|
In my appication i need to connect to windows machine remotely to perform some opetrations . In the case i need to first authenticate the user with the windows machine username/password (The machine need to remotely connected) . How to achieve this ???
vineesh
|
|
|
|
|
Have you looked into functions like LogonUser() and ImpersonateLoggedOnUser() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello everyone,
In COM STA model, a hidden Window will be created with synchronized message pump operation. I have seen and debugged a couple of samples. My quesitons are,
1. Who (which party) is responsible for generating code to create the hidden Window and generate message pump (retrieve message one-by-one from message queue so that all processing to the component is synchronized)? Generated by COM Runtime (I suspect it generated by COM Runtime, because I have seen no code in the samples I studied to explicitly create the hidden Window)?
2. If it is created by the COM Runtime? When such code is generated? During call to CoInitializeEx and when specifiying parameter value for dwCoInit (COINIT_APARTMENTTHREADED or COINIT_MULTITHREADED)?
3. Where is the generated binary code? Injected by linker in the result COM DLL or EXE?
thanks in advance,
George
|
|
|
|
|
I believe that the COM subsystem (meaning Windows proper) is responsible for creation of this Window and the message pump, but the pump only runs (i.e. is triggered) when you make a COM call<sup>1</sup> ). I am not certain if your application runs the pump, or if the COM subsystem does, but I bet that the COM subsystem does.
I believe it is created at initialization. You may be able to confirm this by using Spy++ and enumerating all windows.
I do not believe that any injection takes place, this code is part of the COM subsystem (DLLs?).
I may be wrong - I do not have my copy of Essential COM with me here...
<sup>1</sup> Which explains why STA COM reentrancy only happens when you call into the COM subsystem - you do not get interrupted while in the middle of something else.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks James,
1.
I have seen a couple of samples of STA model. No explicit code for pumping message to somewhere. Just jobs like, like CoCreateInstance, QueryInterface, and method call by the interface public method.
So, I think the function call through public method of interface (retrieved from QueryInterface) is translated into message pump. Is that correct?
2.
How does message pump work? Like enqueue a message into a double ended queue, one end is the function call, the other end is the component itself?
regards,
George
|
|
|
|
|
Yes, any call into the interface (method, property, etc.) are translated into a message and placed onto the queue (if the call crosses apartment - is crossing application boundaries). Not sure if connection points work the same way (and I rarely used them because of undesirable side-effects). When the message pump runs, the message is dispatched to the COM message handler which takes over handing of the call.
The message pump is a standard windows message queue (which is why the hidden window is required).
One correction for my above post: The message pump is run by the thread that created/owns the COM object - I remember this because I had worker threads using COM in STA that needed to run a PeekMessage /GetMessage loop for things to work. This also means that while COM creates the hidden window, it is owned by the calling thread because threads have to pump messages for their own windows.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Great, James!
One more comments. I think to manage a message queue, we need at least two threads acting as producer (invoke methods of COM interface and push message) and consumer (which extracts messages from message queue and interacts with COM component directly).
But STA means single threaded apartment, i.e. in the apartment, there is only one thread. So, is the thread in STA the producer or consumer? Or I am totally wrong about above producer/consumer pattern of how STA works?
regards,
George
|
|
|
|
|
When you make the cross-apartment COM call, it turns into a message, this message is queued, processed, and then returned back to you.
You and the target apartment constituite both ends of the queue/pump system.
When you see "only one thread in an STA," that means that each application only has one thread in the STA, not all applications have one shared thread in one shared STA.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks James,
1.
My understanding is, inside the STA, no message queue is needed, and the message queue is only needed when there is call from other apartment, right?
2.
For call from other apartment, I think the call from other apartment are translated into messages into the message queue, and the thread in the STA is responsible for retrieve the message, invoke the object, and finally return the method call result by the means of message into the queue again, right?
But I have not seen samples when the STA thread explicitly retrieves message from somewhere, and convert the messages into function call to the component component inside the STA.
Does the STA thread explicitly retrieves message from somewhere, and convert the messages into function call to the component component inside the STA?
regards,
George
|
|
|
|
|
Cross-apartment STA calls, regardless of inter- or extra-process, involve the message queue. I do not believe that STA calls between two objects created in the same process and apartment involve the message queue.
The message-and-parameters getting unpacked into a method call on the COM interface, and the return/result from that call, are all handled by the COM subsystem for you. This is why you never have to write code that cracks the messages and their parameters, etc. Remember that each window has a pointer to a WinProc - in the case of COM message queue windows, this WinProc is implemented in the COM subsystem.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks James,
Another terms which makes me confuesd is marshell. From my study, if we call from one apartment to another STA apartment, even in the same process, the call needs to be marshelled.
I am confused,
1. Is marshell the same thing as to translate method call into windows message and push into STA hidden window?
2. If no to (1), what is the different function between marshell and the message window when we call a function in STA? I think a message windows is enough (for synchronize message processing) to STA, why involve marshelling as well?
regards,
George
|
|
|
|
|
Simply, marshalling is the packaging of data so that it can be serialized/transported in an independent format. For example, you cannot (normally) pass memory directly between two applications, as each runs in its own address space. So one way is to write the data to a file, and then have the other applicatoin pick-up that file. The file is used as a way to marshall data between the two processes. The same thing happens when you use functions like htonl(...) and ntohl(...) in Winsock.
Marhsalling in COM is basically the same thing. It is a way to convert the standard Marshall-able data types (String/BSTR, 32-bit integers, characters, etc.) so that they can be passed between processes (even across the network), and reconstituted into the actual data.
Nornally, marshalling is limited to certain data types, called the automation-capable data types, or Marshall-able types. You can expand on this by writing your own marhsalling code so you can then support marhalling of more complex types between interfaces.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|