|
Did you read my answer above? Yes, I have.
How are you sending the message? How do you identify the window you are sending it to? How are you trying to handle the message?
|
|
|
|
|
Sir,again with all due respect and thanks for taking concern for answering me again and again
now back to problem You have Quoted this
"How are you sending the message?"
Using both SendMessage And PostMessage apis
you quoted " How do you identify the window you are sending it to?"
what that's
you quoted " How are you trying to handle the message?"
Using MACRO in ON_RESTRIED_MESSAGE()
one note also,when i give it curent desktop pointer,it working fine in non service based application.
thanks
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Alok the programmer wrote:
you quoted " How do you identify the window you are sending it to?"
what that's
The window you send the message to. If you don't get this right, you'll of course never receive any messages in your application.
Now, for practicalities:
Create a dialog application called "Sender". Add a button and a button handler. In the button handler, add the following code:
void CSenderDlg::OnButton1()
{
HWND hwnd = ::FindWindow( _T( "#32770" ), _T( "Receiver" ) );
UINT hello = ::RegisterWindowMessage( _T( "TEST_MESSAGE" ) );
if( hwnd )
::PostMessage( hwnd, hello, 0, 0 );
}
You don't have to register the message everytime, and should use something more sensible as the id string. FindWindow is the interesting part here, it looks for a dialog (window class "#32770") with the title "Receiver".
Create another dialog application, called "Receiver". Either create it modeless, pumping messages yourself or a modal dialog. Let's start with a modal one (the default).
Register the message so:
UINT hello = ::RegisterWindowMessage( _T( "TEST_MESSAGE" ) );
Add a messsage map entry:
<pre
on_registered_message(="" hello,="" onhello="" )
<="" pre="">
Declare <code>OnHello </code>in the header:
<pre>
LRESULT OnHello( WPARAM, LPARAM );
Implement OnHello :
LRESULT CReceiverDlg::OnHello( WPARAM, LPARAM )
{
AfxMessageBox( _T( "Message received" ) );
return 0;
}
Now, start the application. Also start Sender. Press the button in Sender, and you'll see the message box pop up.
If you want it modeless, you must pump your own messages, use this in the application InitInstance :
CReceiverDlg dlg;
m_pMainWnd = &dlg;
dlg.Create( CReceiverDlg::IDD );
while ( PumpMessage() )
;
You'll also need to override OnCancel in the dialog class, calling DestroyWindow instead of the base class implementation.
Finally, make the window invisible. You'll now have to enumerate all the windows on the desktop, as you don't have the title to look for. You can also start by broadcasting the HWND from receiver as the application starts - and handle this message in Sender, this depends on the final structure of the application.
Alok the programmer wrote:
one note also,when i give it curent desktop pointer,it working fine in non service based application.
I can make no sense out of this, what are you giving the desktop window?
|
|
|
|
|
AGAIN SIR,WITH ALL DUE RESPECT
here is Come the problem
I am Broadcating the message using this Api command
<br />
UINT hello = ::RegisterWindowMessage( _T( "TEST_MESSAGE" ) );<br />
::PostMessage( HWND_BROADCAST, hello, 0, 0 );
ok,now i think you can understand the problem,also now tell me How i use to Findwindow() to find the dialog of my service.
till now our discussion is going great thanks
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Ah, finally, we are getting somewhere!
HWND_BROADCAST is something that should be used with some care - all windows receive it and you must make sure that the registered message does not conflict with any other messages in the system (that is, someoneelse has registered the same message). It will, however, not make any difference for the receive mechanism. Do the steps I outlined, replace the PostMessage with our own broadcast, and you will see the message box, the message is received.
You find the window the way I showed - by calling FindWindow . Enter the class of the dialog (normally #32770, use Spy++ to get the class of your dialog) and the title.
|
|
|
|
|
Johan Rosengren wrote:
You find the window the way I showed - by calling FindWindow. Enter the class of the dialog (normally #32770, use Spy++ to get the class of your dialog) and the title.
BUT AGAIN A BIG PROBLEM HOW TO GET CLASS OF DIALOG WHICH IS NOT VISBLE,IS SERVICE WITH HELP OF SPY++
THANKS AGAIN,I THINK THIS DICUSSION IS ENRICHING OUR KNOWLEDGE
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Tsk, tsk, Alok, you are kidding me
Make it visible, then. It will only be to get the class name - so it need not be permanent. Or call GetClassName in the code somewhere along with a convenient breakpoint. Or test any dialog box, they all have the same class!
|
|
|
|
|
Johan Rosengren wrote:
Make it visible, then. It will only be to get the class name - so it need not be permanent. Or call GetClassName in the code somewhere along with a convenient breakpoint. Or test any dialog box, they all have the same class!
now again with all due respect,
let go back i have told you i am creating a service ok.now if i show the dialog box of service it will shown after the login ok.
now what the problem is winlogindll(that is creted by me have to post the message ok) now how will it find the Classname .
i think now you understand my problem better,thank for nice and polite long disscusion.
it very nice to meet a intelligent guy like you,hat off
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Alok,
Alok the programmer wrote:
now what the problem is winlogindll(that is creted by me have to post the message ok) now how will it find the Classname .
It's no matter if you hide a window, if you move the class and display it in another application, or whatever you do, the class name will always be the same. The class name (now I mean class in the Windows sense, not a C++-class) will in fact be the same for all dialogs in the system. This is normally "#32770" for a dialog, something that you can verify with Spy++ on your system. You can also move your dialog to a normal application, and add a call to ::GetClassName . The name will be the same if you use the dialog in another application, from a DLL, a service, or whatever, so the result of that experiment will be valid for the "real" code as well.
You must have a window if you are going to send, post or broadcast a message. It does not matter the kind of application, or if it is a DLL, a control panel applet or whatever. To reiterate: to handle a registered message, you must have a window.
I have shown how to find a window, given the general dialog class "#32770" and the title of the dialog. I've also mentioned EnumWindows and EnumChildWindows as a way of getting invisible windows - it's also of use if you are not sure of the title (such as if you have a dialog that will be translated to different languages) or if the window you are trying to find for some reason will not have the normal dialog class (in the case where, for example AfxRegisterClass has been used to register the window class - now note that I mean class in the Windows sense again, not C++-class).
I've also stated - and I repeat this - that you should try to get the registered message to work in a normal application (or rather two, one that sends and one that handles it). Have you succeeded in this? If so, you'll just have to move the code to the designated modules, and it should work. Don't get stuck on services, login etc., get the message to work first.
Alok the programmer wrote:
i think now you understand my problem better,thank for nice and polite long disscusion.
it very nice to meet a intelligent guy like you,hat off
But we are getting a little bit strained, both of us
|
|
|
|
|
I got it sir,
thanks for this long disscusion to help me out.
i have one more problem if you don't mind
i have unable to use SmartCard Api's,do you have any knownledege abt it.
thanks in advance
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Alok the programmer wrote:
have unable to use SmartCard Api's,do you have any knownledege abt it.
No, I'm sorry I don't. If I had, you could be assured of a very long answer
|
|
|
|
|
thanks for all cooperation you showed to help me out.
thanks for bearing with us and reading my bad english.
May be we will face each other again for any new dicussion.
Thanks sir for love and affection you showed to me in this discussion.
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
Maybe 'PostThreadMessage' would help
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
parths wrote:
Maybe 'PostThreadMessage' would help
but here is little problem.how to get thread identifier of service .
if it is Any Non service Application i can use OpenProcess to get Thread Identifier,but how to get thread identifier of Service
i very very thankful for your reply
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
See QueryServiceStatusEx()
Bikram Singh
|
|
|
|
|
Alok the programmer wrote:
nope that i don't want i don't want to show dialog noe model nor modeless.
is any way to recieve window message without showing the modelor modelless dialog boxes.
There isn't a way to receive window messages without having the window created. The most simple way of doing this is to create the window as a modeless dialog and then do a ShowWindow(SW_HIDE) straight after creation. I use hidden windows in lots of apps for processing Windows and custom messages.
Michael
CP Blog [^]
|
|
|
|
|
let me explain my problem.
i am creating the window service(which is desktop interractive).i am also created Winlogon dll which notify me that some user is logged on or logged on the Work Station.
now problem arise to comuunicate between these two services i am using RegisterWindowMessage to pass information.
here the problem arise the Service can't receive a until dialog is displayed in case of modol dialog
and the in case of modelless dialog ,from wher i will get the desktop window pointer,without that it will not going to listen my registered message.
i think i have explained my problem
thanks,now any suggesstion
ps(socket create some problem in winlogon,so i can't use socket to sned or recieve message)
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Long post. I dont quite understand exactly what u need. But, if all you want to do is recv a message in a service, from another of your services', you dont need to create a window or dialog.
One service will use PostThreadMessage() to post a message, and another will simply run a thread with a GetMessage() loop.
Bikram Singh
|
|
|
|
|
i think you havn't read whole discussion.
any way thanks for reply.
basically you are correct but problem ramain the same where to produce thread id.
thanks for replyi owe you very much
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Frankly, I have not read the whole discussion. But from what I gather, all u need is the service's proc id, which the func i mentioned, will give u.
Dont be afraid to share ur code with others, Alok. You are still in a nascent stage, so dont try and protect your "wonderful" code at this stage. You have a lot to learn.
I see your english is not too good, well, I am sure i can give u a solution to your problem if u do speak in Hindi.
But in any case, It is wonderful to see you trying. Most people are afradi of admitting their lack of english knowledge, so kudos to you !!
Besides, remember that your approach to the problem is not the best one always ! Always attempt to present your porblem, rather than ask advice on what you *think* is the solution to your problem! Remember that always when posting to message boards !!
ciao!
Bikram Singh
|
|
|
|
|
bikram singh wrote:
I see your english is not too good, well, I am sure i can give u a solution to your problem if u do speak in Hindi.
helloo there,very very thank for advice.i will try to improve my english.basically i am very weak at language.plese forgive me for that.if i write hinglish here , may be our fellow programmer fail to understand.that why i am using english atleast they got the idea of my problem rather then going Null
bikram singh wrote:
Dont be afraid to share ur code with others, Alok. You are still in a nascent stage, so dont try and protect your "wonderful" code at this stage
who said i am afraid of sharing my code.
i am almost opensourec programmer and i have learned most of programming thorugh codes only.
any way thanks for reply.any what are doing in your life????
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Alok the programmer wrote:
who said i am afraid of sharing my code.
I thought u did, cos i saw your reply to a post in which u were going to give code to the person via email. Mu mistake again!
Alok the programmer wrote:
any what are doing in your life????
Im a s/w developer with emphasis on systems programming.
Bikram Singh
|
|
|
|
|
bikram singh wrote:
I thought u did, cos i saw your reply to a post in which u were going to give code to the person via email. Mu mistake again!
Basically i am recently faced critics about my system application,so i must assure it working properly before posting on CP.
Basically many programmer on CP are Raw,so any System S/w may damage there system if not handle with care.
that why i write i will mail you my code if you want.
bikram singh wrote:
Alok the programmer wrote:
any what are doing in your life????
Im a s/w developer with emphasis on systems programming.
that great!! are you working in any S/W co
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
hi
i need to include .gif or any animated files into richedit box.
how it is possible .Any body know , plz tell me.
thank you.
This allows you to set your preferences for the discussion boards
|
|
|
|
|