Anuya
Anuya

Reputation: 8350

Setting location of the form using c#

I have a form which has only tab control in it. I want to fix the location of the form on windows desktop according to the screen size of the users pc.

The form looks like windows task bar and it should be docked on top of windows desktop. For this i set dock = top property in my form. But still it is not perfectly on top.

How to over come these melodramatically.

Upvotes: 0

Views: 2717

Answers (2)

Franci Penov
Franci Penov

Reputation: 75981

you can use the SHAppBarMessage API (C# definition) to register your form as an application bar. This would properly change the desktop workspace size to ensure other programs don't obscure your app. This approach though requires a bit more work to implement it properly.

If you just want to position yourself at the top, you can also use the Form.DesktopLocation property (as @phoenix also mentioned). You will also have to calculate your size based on the primary monitor size. And if you don't want to be at the primary monitor you will have to do some additional calculations. For these, you will need to use the proper Multiple Display Monitor functions.

Upvotes: 2

rahul
rahul

Reputation: 187030

You can use the

Form.DesktopLocation Property

Upvotes: 3

Related Questions