By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

SendKeys cannot run inside this application

P: n/a
Hi,
We are launching .net window from vb6 form. In .net form tabbing(tab out
from one control to another control) was not working. for that i have written
a code like Sendkeys.send("{TAB}") in the textbox keypress event. I got the
following error msg:
{"SendKeys cannot run inside this application because the application is not
handling Windows messages. Either change the application to handle messages,
or use the SendKeys.SendWait method."}

Any help would be appreciated.

Regards,
Sriman.
Oct 8 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I've never had the problem, so this is just a guess:

Try setting the Form's KeyPreview property to true?!?!?!

Cheers,
Johnny J.


"Sriman" <Sr****@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
Hi,
We are launching .net window from vb6 form. In .net form tabbing(tab out
from one control to another control) was not working. for that i have
written
a code like Sendkeys.send("{TAB}") in the textbox keypress event. I got
the
following error msg:
{"SendKeys cannot run inside this application because the application is
not
handling Windows messages. Either change the application to handle
messages,
or use the SendKeys.SendWait method."}

Any help would be appreciated.

Regards,
Sriman.

Oct 9 '07 #2

P: n/a
Sriman wrote:
We are launching .net window from vb6 form. In .net form tabbing(tab out
from one control to another control) was not working.
This is pretty basic to a Forms application so, if it's not working,
there's something very, /very/ wrong that needs fixing first.

How are you launching the .Net Form? .ShowDialog? Application.Run()?
For that i have written a code like Sendkeys.send("{TAB}") in the
textbox keypress event.
SendKeys is going to give you ever-increasing problems, especially under
Vista; Id suggest using the TextBox's SelectNextControl method instead.
I got the following error msg:
{"SendKeys cannot run inside this application because the application is not
handling Windows messages. Either change the application to handle messages,
or use the SendKeys.SendWait method."}
There's no Windows Message pump running so your .Net app doesn't think
it's a Forms application.

HTH,
Phill W.
Oct 9 '07 #3

P: n/a
Hi,
We are launching .net window from vb6 form. In .net form tabbing(tab out
from one control to another control) was not working. for that i have written
a code like Sendkeys.send("{TAB}") in the textbox keypress event. I got the
following error msg:
{"SendKeys cannot run inside this application because the application is not
handling Windows messages. Either change the application to handle messages,
or use the SendKeys.SendWait method."}
Sendkeys is always a hack.. I would avoid it.

I have not touched VB6 in 5 years, so, take this for what it is worth.

1) Sounds like you have 2 forms? This seems wrong.
Make your .Net form a control, then host that in the vb6 form.

It sounds like you have 2 message loops running, one in each version of VB,
and that they are not coordinating the messages correctly.

2) If you already are using a control then step back and think what sendkeys is.
It basically puts a windows message in a given progs message queue.

In this case the VB6 parent form is handling the msg Q and is delegating a subset of
the events to your control. Also consider that all of this is happening in one
thread. So you have vb6, a BIG wall, then .NET.

With sendkeys, you are trying to throw a message over the wall.
But there is only one thread. 2 seperate apps would be no prob, should work fine.
With one thread, you are throwing the message, and waiting for a response, but
you are halting the thread waiting, so there can be no response.

So, like the error message says, DONT DO THAT. Use SendWait..

Further, I suspect this will not work :)

After all, vb6 ALREADY GOT the tab message, and then nicely delegated it to you..
Sending the same message back is not going to help. You will just go into a ping pong state.

On your control, you may want to expose a public property called NextControl.
whether a vb6 control is a valid .Net "control" with numerous interfaces, I dunno.

Maybe you have to pass an hWnd. But vb6 made it hard to get to hWnds, didnt it?!?

Anyway, inside your .Net code, if you are on the last control, then set focus to NextControl..
Set NextControl in your VB6 form load event..
Hope that helps.

Oct 9 '07 #4

P: n/a
Thanks for the responses.
We are launching the windows as modeless i.e .show() .. if i use
showdialog() no problem to me(able to tab out). but we should launch the
form as modeless form only(this is the requirement).

"Phill W." wrote:
Sriman wrote:
We are launching .net window from vb6 form. In .net form tabbing(tab out
from one control to another control) was not working.

This is pretty basic to a Forms application so, if it's not working,
there's something very, /very/ wrong that needs fixing first.

How are you launching the .Net Form? .ShowDialog? Application.Run()?
For that i have written a code like Sendkeys.send("{TAB}") in the
textbox keypress event.

SendKeys is going to give you ever-increasing problems, especially under
Vista; Id suggest using the TextBox's SelectNextControl method instead.
I got the following error msg:
{"SendKeys cannot run inside this application because the application is not
handling Windows messages. Either change the application to handle messages,
or use the SendKeys.SendWait method."}

There's no Windows Message pump running so your .Net app doesn't think
it's a Forms application.

HTH,
Phill W.
Oct 9 '07 #5

P: n/a
I got the solution

http://support.microsoft.com/kb/839076/
"Johnny J." wrote:
I've never had the problem, so this is just a guess:

Try setting the Form's KeyPreview property to true?!?!?!

Cheers,
Johnny J.


"Sriman" <Sr****@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
Hi,
We are launching .net window from vb6 form. In .net form tabbing(tab out
from one control to another control) was not working. for that i have
written
a code like Sendkeys.send("{TAB}") in the textbox keypress event. I got
the
following error msg:
{"SendKeys cannot run inside this application because the application is
not
handling Windows messages. Either change the application to handle
messages,
or use the SendKeys.SendWait method."}

Any help would be appreciated.

Regards,
Sriman.


Oct 9 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.