|
-
April 30th, 2010, 01:07 PM
#1
Dialog vs dialog (mfc)
hello,
the story;
I have two dialogs (they belong to diff. processes)
Dialog -A- has the focus (Dialog -B- is also on the screen),
when I press a (control)-button in dialog -A- a text string has to be send
to the edit control of Dialog -B-, using the keyboard event.
but has Dialog -B- does not has the focus, nothing happens.
Well, not what I want.
quest;
what can I do to make it work?
regards,
ger
-
April 30th, 2010, 01:08 PM
#2
Re: Dialog vs dialog (mfc)
 Originally Posted by TBBW
hello,
the story;
I have two dialogs (they belong to diff. processes)
Dialog -A- has the focus (Dialog -B- is also on the screen),
when I press a (control)-button in dialog -A- a text string has to be send
to the edit control of Dialog -B-, using the keyboard event.
but has Dialog -B- does not has the focus, nothing happens.
Well, not what I want.
quest;
what can I do to make it work?
regards,
ger
::SendMessage (WM_USER_MSG, ...) from A to B.
-
April 30th, 2010, 01:21 PM
#3
Re: Dialog vs dialog (mfc)
Bring Dialog B to the foreground and use SendInput.
-
April 30th, 2010, 01:27 PM
#4
Re: Dialog vs dialog (mfc)
@ Alin, tell a little bit more on the SendMessage
@Arjay, I only control Dialog -A-
I can do a FindWindow and set the focus to it.
ger
-
April 30th, 2010, 01:50 PM
#5
Re: Dialog vs dialog (mfc)
 Originally Posted by Alin
::SendMessage (WM_USER_MSG, ...) from A to B.
...where WM_USER_MSG is a registered window message, isn't it? 
@To TBBW: Why do you want to send text from an edit control in a procss to an edit control in another process by using "using the keyboard event" ?.
There are many other better methods.
The easier one is sending WM_SETTEXT message.
Last edited by ovidiucucu; April 30th, 2010 at 04:33 PM.
Reason: typo
-
April 30th, 2010, 01:53 PM
#6
Re: Dialog vs dialog (mfc)
Oups! 
 Originally Posted by TBBW
@ Alin, tell a little bit more on the SendMessage
Here is the story: http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx
-
April 30th, 2010, 02:24 PM
#7
Re: Dialog vs dialog (mfc)
I'm not transferring text from an edit control to an edit control.
pushing a control button will send a static text string to the edit control of the other dialog.
that is why i'm using the keyboard event, to simulate user input.
as i'm still learning I do not know all options, I will have a go using the mention options.
ger
-
April 30th, 2010, 02:31 PM
#8
Re: Dialog vs dialog (mfc)
Using SendInput is the way to go.
-
April 30th, 2010, 04:28 PM
#9
Re: Dialog vs dialog (mfc)
 Originally Posted by TBBW
I'm not transferring text from an edit control to an edit control.
pushing a control button will send a static text string to the edit control of the other dialog.
Please, excuse my ignorance!
Why doing that via sending WM_SETTEXT is not possible?
Last edited by ovidiucucu; April 30th, 2010 at 04:31 PM.
-
April 30th, 2010, 08:00 PM
#10
Re: Dialog vs dialog (mfc)
Call SetForegroundWindow before SendInput.
See DiLascia's C++ Q&A from January 2005: "Sending Keystrokes to Any App" at http://msdn.microsoft.com/msdnmag/is...A/default.aspx
Mike
-
May 1st, 2010, 04:31 PM
#11
Re: Dialog vs dialog (mfc)
Thank you guys for all the much appriciated input !!
the SetForegroundWindow() did the trick.
tested both SendInput() and Keyboard_event()
I could not observe any major diff. between them
apart from the lines of codes needed.
the only thing I observed, using the SendInput. Also the next, back buttons of the receiving
dialog (Dialog -B-) are 'touched'. (this is the case if the control button sending the text is hit more
than once.
using the keyboard event did not created this problem.
ger
-
May 1st, 2010, 05:11 PM
#12
Re: Dialog vs dialog (mfc)
This unwanted behavior is an artifact of how you are using SendInput.
Without seeing your code we can only speculate on what you are doing wrong.
-
May 4th, 2010, 01:35 PM
#13
Re: Dialog vs dialog (mfc)
Why not just get the pointer of first dialog in second dialog?
A constructor of second dialog can take pointer of first dialog, and directly set the control's text.
Yes, the appropriate control variable should be accessible to second dialog-class.
-
May 4th, 2010, 01:37 PM
#14
Re: Dialog vs dialog (mfc)
Oops. My bad! They are in different processes!
You can use WM_SENDDATA to silently send the data to second dialog (application). The application would understand it, and would display the content.
Please note that with Windows Vista and higher, UIPI and integrity may prevent sending messages from lower integrity process to higher integrity process!
I would use named-pipes in this case.
-
May 4th, 2010, 01:41 PM
#15
Re: Dialog vs dialog (mfc)
@Ajay - pretty sure the OP can't modify the source to Dialog B.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|