|
includeh10 wrote: how to implement the user function post_message(100)?
You have to build (or use and existing) communication path between the two objects. Do both objects exist in the same application and thread, or are these disconnected objects?
|
|
|
|
|
They are in same app, sender is in a thread, receiver is in main process - not in thread.
Any more info to implement?
|
|
|
|
|
I am not sure if this is an answer to your question but take a look at PostThreadMessage[^], you do not need to have a window for that, only a message queue in the given thread. You could use that + somekind of mechanism to route the incoming message to the correct instances, like have some identifier or handle in the wParam and the sent integer in the lParam, then on the receiving side you use wParam to identify the instance and call some member function feeding it lParam. Be careful with posting because it might happen that the targeted object gets destroyed before the message arrives and then when you try to call the method of the destroyed instance you get a crash. This of course depends on the implementation. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I agree, this seems the optimum solution.
|
|
|
|
|
|
Kushagra Tiwari wrote: Or you can broadcast the message using flag WM_BROADCAST, if you have made a custom Windows message (eg. WM_SAMPLE_APP (you should have a handler for the same. Also you can internally have the code for things you wanted to do in the handler))rather than posting athread message. Doing this everry active window will recieve this message but since only your application has has handled that message you will be able to get the desired functionality
That doesn't make any sense at all.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Will you stop behaving like a child? I don't care about low votes, but not on a programming forum. Because that counts against my contributions here. Your answer was completely senseless, so how about answering only those queries that you have some clue about?
And how about accepting it when someone says you are wrong, instead of acting like a coward and low-voting them? For the record, yes, I just had to mark your answer as "Bad Answer".
You repeat this nonsense and I know where to take it.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hello Sir,
I am sorry for that , but I marked it bad by mistake , and I completely respect you . May be I wasnt able to explain my ans to the fullest . I wanted to mark ur ans as good but by wrong click marked as Bad. Plz Ignore and thre are no hard feelings
Have a very gud day ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Rajesh R Subramanian wrote:
And how about accepting it when someone says you are wrong, instead of acting like a coward and low-voting them? For the record, yes, I just had to mark your answer as "Bad Answer".
But that was really harsh from your side .. You could have asked first that was it by mistake or I did it intentionally .
Anyways , I think now the misunderstanding will perish .Thanks for guiding me .
Kushagra
|
|
|
|
|
Well, there's no 'harshness' - I just had to express my opinion on your act.
And I'm not sure you had to mark a reply to *you* (which isn't an answer to the OP) as good or bad. Especially, given that there are no "Good Answer" or "Bad Answer" buttons and that you have to specifically click on a number... Now I see it's changed to 5.
However, I'm over it and please don't call me "Sir".
Thank you!
PS: Deleting your message is considered rude on this forum, especially after people have replied to it.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Derive that class from CWinThread. This will provide the class with a message pump and message mapping mechanism, and then you could use PostThreadMessage to post a message to it (actually to the thread). Have a message map entry added for all the messages of your interest.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Using shared memory might be another way to do what you want to implement.
|
|
|
|
|
hi every body ....
i have some problem in my project...
i.e convertion of word(or)excel to pdf ?
this project is developed in vc++6.0
please help me.......
thanks in advance....
|
|
|
|
|
soo preety wrote: convertion of word(or)excel to pdf ?
You need a PDF library or writer; try Google, there are many options available.
|
|
|
|
|
Is this[^] helpful ?
Regards,
Paresh.
|
|
|
|
|
Hi
I am a newbie in MFC and VC++. I have a tab dialog application with five edit boxes expecting user entry. Everything works fine till the application is in focus. Once the application goes out of focus and comes back the edit boxes refuse to accept the key inputs from the user.
I will explain the procedure in which I found the issue: Application is running and user inputs numbers into the edit box - here it works. User presses Win key + D to show desktop. Application disappears since there is no task bar icon for the application, we need to restore any other window (of any other application) available and minimise it to make my application visible. This is also not desirable but then the edit boxes no longer accept the key inputs. Once i minimise the application to tray and restore, then everything works fine. I need to fix this two issues
I am not sure where to look for a bug in the code. Please help
Sorry for the long problem description.
Thanks in advance
Deepak
PS:
1. I have a pre translate message function to filter out ESC and ENTER key to avoid closing the application by these keys.
2. It has a hidden dialog to avoid showing up in the taskbar area while the application is visible in desktop.
3. It is a tray residing application.
4. All these 3 functionality codes are from CP articles. Is there chance of having an issue in these codes?
|
|
|
|
|
what do you mean about "key press missing"? can not detect chars or keys in WM_CHAR or WM_KEYDOWN? if so, use PreTranslateMessage(), MFC dialog blocks some key events - I don't know why MFC does this.
|
|
|
|
|
includeh10 wrote: what do you mean about "key press missing"?
No characters appearing in the edit field when we type something in the keyboard. My PreTranslateMessage() filters out only the ESCand ENTER characters in my app.
Thank you
Deepak
|
|
|
|
|
Hi All,
I am using a software to run a occupancy report manually by clicking a button in the software.
I would like to automate this task by writing MFC application to programatically click the button every hour. So I dont know how to activate other application's button by my program.
Could anyone please suggest me some possible solution for this?
I am not sure where to start and how to proceed. Any piece of information will help me a lot.
Thanks in advance.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: So I dont know how to activate other application's button by my program.
Why not just use a timer in the main application so it sleeps for an hour and then runs its activities? Alternatively you could probably use the Windows Task Scheduler.
|
|
|
|
|
Hi Thanx for your reply.
Timer function wise, i have no problem.
But my problem is how to activate other application's button using my own program.
I used FindWindow() method to get the other application's window handle.
But How to get the control of the button to send message to that button?
This is the biggest issue to me now.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: But How to get the control of the button to send message to that button?
I think you need to enumerate all the child windows until you find the button, then post a message to the button's HWND. However this seems a very complicated way of going about solving what is really a simple timer issue.
|
|
|
|
|
Can you please tell me the easiest way to do this?
Thanks
Regards,
Ram
|
|
|
|
|
Richard MacCutchan wrote: Why not just use a timer in the main application so it sleeps for an hour and then runs its activities?
I think it's a 3rd-party application that he's wanting to run and simulate a button click within.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Use FindWindow() and then EnumChildWindows() to find that button .Refer MSDN for both functions.That will surely help u. Mark this ans as good if u feel it helped.
Kushagra
|
|
|
|