Re: Dialog vs dialog (mfc)
Quote:
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.
Re: Dialog vs dialog (mfc)
Bring Dialog B to the foreground and use SendInput.
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
Re: Dialog vs dialog (mfc)
Quote:
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.
Re: Dialog vs dialog (mfc)
Oups! :sick:
Quote:
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 :)
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
Re: Dialog vs dialog (mfc)
Using SendInput is the way to go.
Re: Dialog vs dialog (mfc)
Quote:
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?
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
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
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.
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.
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. ;)
Re: Dialog vs dialog (mfc)
@Ajay - pretty sure the OP can't modify the source to Dialog B.
Re: Dialog vs dialog (mfc)
Hello thanks again,
all works fine, using sendinput or keyboard_event.
but hitting a new problem......
the editcontrol of dailog -B- can handle only 5 chars. (Then it hops to the NEXT button)
so when I shoot over "bunny" the edit control is full.
when I shoot over "horse" at this time, funny things are happening, this what I
described earlier. And the bunny is still there. So how do I clear the content
of the editcontrol before I can send over the "horse".
tried SetWindowtext(""), not satisfied (maybe in combination with ...)
regards,
ger
Re: Dialog vs dialog (mfc)
Since you are essentially automating the application, I would approach the problem from an automation point of view.
I would use Active Accessability to manipulate the controls (button clicks, tab clicks, selecting items and so on). For edit boxes I would use SendInput.
Sending characters to perform window navigation isn't reliable (as you have found out).
Re: Dialog vs dialog (mfc)
@Arjay,
That is going to be difficult, new challenge........
anyway.
Do you have any examples on the UIAutomation, not necessary related to my problem.
the ones I found are C#
on the other hand do I really have to go that far, as I only have to reset tab order.
the state on the initdialog, and/or clear the editcontrol.
thanks,
ger
Re: Dialog vs dialog (mfc)
Hi All,
to circum navigate the UIautomation....
did some digging, using sendinput() or the keyb_event()
will do the job.
But there is one small item...
I need an init state, like the one on initdialog.
so I found out, I need to find the BS_DEFAULT button!
how can this be comp.
If, I can use GetButtonStyle()
how do I implement this?
regards,
ger