简体   繁体   English

Windows形成背景图片,最大化

[英]Windows form background Image, make bigger on maximise

I am creating a timer solution. 我正在创建一个计时器解决方案。 User enters hrs, mins secs, into text boxes and then clicks button to start. 用户在文本框中输入小时,分钟和秒,然后单击按钮开始。 I wanted the timer to be small so it can be hidden at the top corner of the screen. 我希望计时器较小,以便可以将其隐藏在屏幕的顶部。 I have sized a background image to this size so it fits nicely in the small form. 我已将背景图片的大小调整为该大小,因此非常适合小尺寸形式。 However I also want the user to be able to maximise the form and take up the whole screen if they want. 但是,我还希望用户能够最大化表单并在需要时占据整个屏幕。 However the image obviously stays at the original size. 但是,图像显然保持原始尺寸。 Is there any possible way to avoid this (ie can i add an image which will be used if maximise is pressed. Hopefully i have made sense with this question. 有什么可能的方法来避免这种情况(例如,如果按下最大化按钮,我是否可以添加将要使用的图像。希望我对这个问题有道理。

Thanks - Colly 谢谢-科利

I think you should have two images in resources. 我认为您应该在资源中有两个图像。 Use smaller one if app is in smaller mode and use bigger one if app is in maximized mode. 如果应用处于较小模式,则使用较小的一个;如果应用处于最大化模式,则使用较大的一个。

Form.SizeChanged event is raised every time there is any change in form size. Form.SizeChanged表单大小发生任何更改时,都会引发Form.SizeChanged事件。 You can handle this event and based on parameters you can find out whether you should change the image or not 您可以处理此事件,并根据参数确定是否应更改图像

挂钩Form.SizeChanged事件或Resize事件应该起作用。

将表单的BackgroundImageLayout设置为Stretch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM