SendKeys cannot run inside this application

G

Guest

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.
 
J

Johnny J.

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

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

Cheers,
Johnny J.
 
P

Phill W.

Sriman said:
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.
 
R

Robert

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.
 
G

Guest

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top