Setup-Deployment and Initial Window Focus

A

Andy

Hi,

I have written a C# Windows application using VS 2005 and created a
Setup Project to install the software. A shortcut to the application
is placed on the user's desktop and also in a folder on the User's
program menu.

When I double-click the desktop icon, the application starts normally.

When I start the application from the program menu, the application
starts normally but the window does not have the focus i.e. the
window's title bar is grey.

I have compared the properties of the two shortcuts and they are the
same.

Can anyone explain how I can get the program menu version to behave
the same as the desktop icon?

Many thanks in advance,

Andy
 
P

Peter Duniho

Andy said:
[...]
Can anyone explain how I can get the program menu version to behave
the same as the desktop icon?

What version of Windows are you using?

Not that I actually know the answer specifically, regardless of the
version of Windows you're using, but it could be important.

I think there's at least a 50/50 chance this has nothing to do with
..NET, and everything to do with some specific behavior of the OS shell
that's launching the application. I haven't run into the behavior with
my own .NET setup-installed programs, so I can at least say that it
works some of the time. :)

It would be interesting to know if this happens with a minimal
application as well, or if you only have the problem with this specific
application. If the latter, then there may indeed be something about
your application that is causing the problem; figuring out what that is
would likely be a simple matter of a process of elimination, removing
customized behavior in your application until it starts working the way
you want it to.

Pete
 
A

Andy

Andy said:
[...]
Can anyone explain how I can get the program menu version to behave
the same as the desktop icon?

What version of Windows are you using?

Not that I actually know the answer specifically, regardless of the
version of Windows you're using, but it could be important.

I think there's at least a 50/50 chance this has nothing to do with
.NET, and everything to do with some specific behavior of the OS shell
that's launching the application. I haven't run into the behavior with
my own .NET setup-installed programs, so I can at least say that it
works some of the time. :)

It would be interesting to know if this happens with a minimal
application as well, or if you only have the problem with this specific
application. If the latter, then there may indeed be something about
your application that is causing the problem; figuring out what that is
would likely be a simple matter of a process of elimination, removing
customized behavior in your application until it starts working the way
you want it to.

Pete

Hi Pete,

Many thanks for the prompt reply.

I am using Windows XP Pro.

I have just tried copying the desktop shortcut and over-written the
program menu version but this does not change the odd behaviour.

I will create a simple Windows application and setup project from
scratch and see if this feature still happens.

Thanks,

Andy
 
A

Andy

Andy said:
[...]
Can anyone explain how I can get the program menu version to behave
the same as the desktop icon?
What version of Windows are you using?
Not that I actually know the answer specifically, regardless of the
version of Windows you're using, but it could be important.
I think there's at least a 50/50 chance this has nothing to do with
.NET, and everything to do with some specific behavior of the OS shell
that's launching the application. I haven't run into the behavior with
my own .NET setup-installed programs, so I can at least say that it
works some of the time. :)
It would be interesting to know if this happens with a minimal
application as well, or if you only have the problem with this specific
application. If the latter, then there may indeed be something about
your application that is causing the problem; figuring out what that is
would likely be a simple matter of a process of elimination, removing
customized behavior in your application until it starts working the way
you want it to.

Hi Pete,

Many thanks for the prompt reply.

I am using Windows XP Pro.

I have just tried copying the desktop shortcut and over-written the
program menu version but this does not change the odd behaviour.

I will create a simple Windows application and setup project from
scratch and see if this feature still happens.

Thanks,

Andy- Hide quoted text -

- Show quoted text -

Following on from the above, I created a simple application that
displays a form (with no added controls or code). The program menu
shortcut behaves the same way as the desktop shortcut - the window has
the focus when the application is started. Therefore I conclude that
this is not an XP issue but something to do with .NET.
 
A

Andy

Andy wrote:
[...]
Can anyone explain how I can get the program menu version to behave
the same as the desktop icon?
What version of Windows are you using?
Not that I actually know the answer specifically, regardless of the
version of Windows you're using, but it could be important.
I think there's at least a 50/50 chance this has nothing to do with
.NET, and everything to do with some specific behavior of the OS shell
that's launching the application. I haven't run into the behavior with
my own .NET setup-installed programs, so I can at least say that it
works some of the time. :)
It would be interesting to know if this happens with a minimal
application as well, or if you only have the problem with this specific
application. If the latter, then there may indeed be something about
your application that is causing the problem; figuring out what that is
would likely be a simple matter of a process of elimination, removing
customized behavior in your application until it starts working the way
you want it to.
Pete
Many thanks for the prompt reply.
I am using Windows XP Pro.
I have just tried copying the desktop shortcut and over-written the
program menu version but this does not change the odd behaviour.
I will create a simple Windows application and setup project from
scratch and see if this feature still happens.

Andy- Hide quoted text -
- Show quoted text -

Following on from the above, I created a simple application that
displays a form (with no added controls or code). The program menu
shortcut behaves the same way as the desktop shortcut - the window has
the focus when the application is started. Therefore I conclude that
this is not an XP issue but something to do with .NET.- Hide quoted text -

- Show quoted text -

Hi,

I have found a work-around: In the <Form>_Shown method I added the
line:

this.Activate();

which resolved the issue.

Thanks,

Andy
 
P

Peter Duniho

Andy said:
I have found a work-around: In the <Form>_Shown method I added the
line:

this.Activate();

which resolved the issue.

I'm glad you found a work-around. However, it would be interesting to
understand what you did in your application that requires it.

Since the minimal application works fine, obviously there's some
important difference between that minimal application and the one you're
having trouble with. Knowing what that difference is could be very
useful, and could in fact lead to a more elegant solution than calling
Activate(). :)

If you do figure out what the actual issue is, please post back here to
share with the rest of us, in case someone else has a similar problem.

Thanks,
Pete
 

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