如何检测Windows任务栏位置/大小的变化 [英] How to detect windows taskbar location/size change

查看:103
本文介绍了如何检测Windows任务栏位置/大小的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法可以关注Windows任务栏的状态?



我想创建一个保持最大化(并固定到其位置)的表单无论Windows任务栏状态如何变化。



可能是一个事件还是什么?

Is there any way of keeping an eye on the state of windows taskbar?

I want to create a form which remains maximised (and fixed to its location) irrespective of the windows taskbar state changes.

May be an event or something?

推荐答案

嗨Kartik ,



只需使用:



1. WindowStyle =无 - 用于显示窗口而不用最小化/最大化&关闭按钮

2. WindowStartupLocation - 用于设置位置

3. ShowInTaskbar =False - 用于防止窗口任务栏可见性。



Hi Kartik,

Just use:

1. WindowStyle="None" - for showing the window without minimize/maximize & close button
2. WindowStartupLocation - for setting the location
3. ShowInTaskbar = "False" - for preventing the window task bar visibility.

<Window x:Class="WpfApplication13.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="350" Width="525" ShowInTaskbar="False" WindowStyle="None" WindowStartupLocation="Manual" Left="200" Top="40">
    <Grid>
        
    </Grid>
</Window>


我自己得到了解决方案:)



而不是从窗口属性中更改ResizeMode(到CanMinimize)和WindowStyle(到None),在加载事件中更改它



I got the solution by myself :)

Instead of changing the ResizeMode (to CanMinimize) and WindowStyle (to None) from the window properties, i changed it in load event

Me.ResizeMode = Windows.ResizeMode.CanMinimize
Me.WindowStyle = Windows.WindowStyle.None





我也不得不重新加载show方法(因为我想使用show和hide方法将它最小化到托盘)





also i had to averload the show method (as i wanted to use show and hide methods to minimize it to tray)

Overloads Sub show()

    Me.ResizeMode = Windows.ResizeMode.CanResize
    Me.WindowStyle = Windows.WindowStyle.SingleBorderWindow

    MyBase.Show()

    Me.ResizeMode = Windows.ResizeMode.CanMinimize
    Me.WindowStyle = Windows.WindowStyle.None

End Sub





这允许Windows任务栏保持可见,因为在窗口分配给我的表单后更改了WindowStyle。



允许我有一个使用WPF默认调整大小属性的不可见父窗口。



当我从visual studio中的windows属性窗格更改ResizeMode和WindowStyle时,因为窗口样式在加载之前都没有,没有父母被分配到我的表格,因此我的申请去了kiosk。



我希望我的解释可以帮助其他人面对类似的问题:)



对于所有花时间回复并帮助我的人,非常感谢大家:)



this allowed the windows taskbar to remain visible as WindowStyle was changed after a window was assigned to my form.

This allowed me to have an invisible parent window that uses WPF's default resizing properties.

When I was changing ResizeMode and WindowStyle from windows property pane in visual studio, as window style was none before even loading, no parent was assigned to my form and thus my application went "kiosk".

I hope my explanation would help others facing similiar issues :)

And to all who took time to reply, and helped me, a big thanks guys :)


这篇关于如何检测Windows任务栏位置/大小的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆