2012一月6
DUI-控制窗口最大最小化屏幕区域
在Windows中,无论什么时候以何种方式改变窗口的尺寸或大小,是拖拽窗口边缘也好,或是在代码中调用改变窗口尺寸的函数也好,总之不管你用什么方法,Windows都会首先发送WM_GETMINMAXINFO消息。大多数应用程序都不用显式处理这个WM_GETMINMAXINFO消息(也就是说让DefWindowProc窗口过程进行缺省处理),而Windows在进行缺省处理时是不会让一个窗口视图比屏幕还大的,所以我们会碰上前面讲的那个问题。
WM_GETMINMAXINFO WPARAM wParam//This parameter is not used. LPARAM lParam;//MINMAXINFOstructure that contains the default maximized position and dimensions, and the default minimum and maximum tracking sizes. An application can override the defaults by setting the members of this structure.
解决的方法是:不要让Windows对WM_GETMINMAXINFO消息进行缺省处理,而是由我们自己处理,方法如下:主要是控制窗口显示时的大小(ptMaxSize),最大化时的位置(ptMaxPosition),鼠标控制窗口大小的最大(ptMaxTrackSize)、最小(ptMinTrackSize)位置
View Code CPP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | case WM_GETMINMAXINFO: MINMAXINFO *mminfo; mminfo=(PMINMAXINFO)lParam; mminfo->ptMinTrackSize.x=200; mminfo->ptMinTrackSize.y=200; mminfo->ptMaxSize.x=300; mminfo->ptMaxSize.y=300; mminfo->ptMaxPosition.x=0; mminfo->ptMaxPosition.y=0; mminfo->ptMaxTrackSize.x=300; mminfo->ptMaxTrackSize.y=300; break; |
利用以上的代码就可以控制窗口的大小(300,300),最大化后会出现在(0,0)位置处,鼠标拖动改变窗口大小时,最大为(300,300),最小为(200,200)。其中的单位都是像素。
文章作者:hgy413
本文地址:https://hgy413.com/1870.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!
Thank you a lot for sharing this with all of us you really know what you are talking about!
Bookmarked. Please additionally consult with my website =).
We may have a link change agreement among us
Helpful info. Fortunate me I discovered your website by accident, and I am surprised why
this coincidence didn’t came about earlier! I bookmarked it.
Wow! After all I got a web site from where I know how to truly get valuable facts concerning my study and
knowledge.
I must thank you for the efforts you’ve put in writing this blog.
I’m hoping to check out the same high-grade content by you later on as
well. In fact, your creative writing abilities has inspired me to get my
own site now 😉
Hi I am so delighted I found your blog page, I really found you
by accident, while I was browsing on Google for something else,
Regardless I am here now and would just like to say kudos for a marvelous post and a all round entertaining blog
(I also love the theme/design), I don’t have time to browse it all at the moment but I have saved
it and also added in your RSS feeds, so when I have time
I will be back to read much more, Please do keep up the awesome work.
We are a gaggle of volunteers and starting a brand new scheme in our community.
Your site provided us with useful information to
work on. You’ve done an impressive task and our whole community shall be grateful to
you.
I’m impressed, I have to admit. Seldom do I come across a blog that’s both equally educative and interesting, and
without a doubt, you have hit the nail on the head.
The problem is something which not enough men and women are
speaking intelligently about. Now i’m very happy I
came across this during my hunt for something
regarding this.
Do you have a spam problem on this blog; I also am a blogger, and I was curious
about your situation; many of us have developed some nice
procedures and we are looking to exchange strategies with other folks, why not
shoot me an e-mail if interested.
Hello, Neat post. There is a problem along with your web site in internet explorer, would check this?
IE nonetheless is the market leader and a huge component of people will pass over your magnificent writing because of this problem.
If you want to improve your knowledge only keep
visiting this site and be updated with the hottest information posted here.
Hello, i think that i noticed you visited my site thus i came to
go back the want?.I am trying to in finding issues
to enhance my web site!I assume its adequate to use a few of
your ideas!!
It’s an amazing post in favor of all the internet users; they will obtain benefit
from it I am sure.
magnificent submit, very informative. I’m wondering why the other specialists of this sector don’t notice this.
You should continue your writing. I am sure, you have a huge readers’ base already!
Greetings! I know this is kinda off topic but I
was wondering which blog platform are you using for this website?
I’m getting fed up of WordPress because I’ve had problems with hackers and I’m looking at options
for another platform. I would be great if you could point me in the direction of a good platform.
I do not even know how I ended up here, but I thought this post was good.
I don’t know who you are but certainly you are going to a famous blogger if you aren’t already 😉 Cheers!
Its not my first time to pay a visit this web site, i
am browsing this site dailly and get pleasant facts from here every
day.
Hi, Neat post. There’s an issue together with your website in internet explorer, may check this?
IE still is the marketplace chief and a large component of people will pass over
your excellent writing due to this problem.
This page really has all of the info I wanted about this subject and didn’t
know who to ask.
I’m not sure exactly why but this website is loading very slow for me.
Is anyone else having this issue or is it a issue on my end?
I’ll check back later and see if the problem still exists.
Hi there to all, how is the whole thing, I think every one is getting more from this web page, and your views
are nice designed for new users.