中国振动联盟

 

 

中国振动联盟进站必读 服务使用协议 行为准则| 免责声明| 禁止行为 等级与权限 | 积分获取 | 意见建议

新的开始、新的征程—本站诚聘各版版主 加入管理队伍,更好地建设振动家园 版主管理及考核| 版主推荐| 版主申请

搜索
中国振动联盟 论坛 Matlab讨论区 问:如何用语句实现matlab图形窗口的最大化
查看: 4164|回复: 6
go

[GUI界面] 问:如何用语句实现matlab图形窗口的最大化

帖子
1 
积分
威望
0 点 
体能
10 点 
发表于 2007-2-3 10:33 |显示全部帖子
图形窗口启动时为默认模式,我想用语句实现使它最大化
谢谢!
该用户还没有设置签名,暂不外售!

帖子
3307 
积分
840 
威望
509 点 
体能
333 点 

热心助人勋章 风云人物勋章 体能充沛勋章

发表于 2007-2-3 10:46 |显示全部帖子
h = figure;
set(gcf,'outerposition',get(0,'screensize'));
1

查看全部评分

  • lxq

签名已到期,被屏蔽。

帖子
5606 
积分
980 
威望
383 点 
体能
407 点 
居住城市
广东 广州 

特殊贡献勋章 优秀斑竹勋章 宣传大使勋章 金点子勋章 原创先锋勋章 热心助人勋章 论坛之星勋章 勤劳奉献勋章 振动美文勋章 体能充沛勋章 风云人物勋章

发表于 2007-2-3 11:29 |显示全部帖子
原帖由 shuishenshen 于 2007-2-3 10:33 发表
图形窗口启动时为默认模式,我想用语句实现使它最大化
谢谢!


happy教授的方法没有问题,或者使用以下方法:

  1. h = figure;
  2. set(gcf,'units','normalized','position',[0,0,1,0.9]);
复制代码


还可以参考其他方法:
http://www.simwe.com/forum/viewthread.php?tid=161775
签名已到期,被屏蔽。

帖子
30 
积分
威望
0 点 
体能
50 点 
发表于 2009-4-10 10:00 |显示全部帖子

回复 板凳 eight 的帖子

非常感谢3楼的回答
我想知道‘units’、'normalized'都表示什么意思??
能有解答的么??
不甚感激
该用户还没有设置签名,暂不外售!

帖子
7620 
积分
1249 
威望
487 点 
体能
16756 点 
研究方向
老板交代 
居住城市
台湾省 台中市 
毕业学校
IAA 

优秀斑竹勋章 热心助人勋章 活力之星勋章 论坛之星勋章 潜水大王勋章 体能充沛勋章

发表于 2009-4-10 15:38 |显示全部帖子

回复 地板 tuoniao992002 的帖子

Units                        {pixels} | normalized | inches | centimeters  | points | characters

Unit of measurement. This property specifies the units MATLAB uses to interpret size and location data. All units are measured from the lower-left corner of the screen. Normalized units map the lower-left corner of the screen to (0,0) and the upper right corner to (1.0,1.0). inches, centimeters, and points are absolute units (one point equals 1/72 of an inch). Characters are units defined by characters from the default system font; the width of one unit is the width of the letter x, the height of one character is the distance between the baselines of two lines of text.

This property affects the PointerLocation and ScreenSize properties. If you change the value of Units, it is good practice to return it to its default value after completing your operation so as not to affect other functions that assume Units is set to the default value.
笛卡尔 : 我思故我在; 抱歉无MSN/QQ, 发帖讨论! 勿发短消息询问!
http://www.chinavib.com/thread-96606-1-1.html 新手学东西赚威
http://www.chinavib.com/thread-101239-1-2.html Matlab备忘录

帖子
2 
积分
威望
2 点 
体能
19 点 
发表于 2009-5-22 09:09 |显示全部帖子
原帖由 eight 于 2007-2-3 11:29 发表


happy教授的方法没有问题,或者使用以下方法:

h = figure;
set(gcf,'units','normalized','position',[0,0,1,0.9]);


还可以参考其他方法:
http://www.simwe.com/forum/viewthread.php?tid=161775


这个问题没那么简单~
1、happy的方法实际上只是把窗口铺满屏幕,可以看见窗口的下面被Windows系统最下面的导航栏(就是含有“开始”和快速启动的那一栏)遮盖住了。
2、eight 的方法也许是想把被Windows系统最下面的导航栏遮盖住的那一部分显示出来,显然“0.9”的选值并不理想。

如果要想用命令实现如点击最大化按钮一样的效果,并不简单。
1、如果用java,那matlab的图形界面功能就无限强大。参考http://www.mathworks.fr/matlabcentral/newsreader/view_thread/149166,上面有如何使用undocumented的java来实现窗口最大化。
2、正如eight指出的 http://forum.simwe.com/viewthread.php?tid=161775给出的程序非常不错,我们也可以写出自己的.m文件来把dll包装一下。
3、也可以试试http://www.mathworks.com/matlabcentral/fileexchange/10274,其中也给出了dell文件。
2

查看全部评分

  • ChaChing

  • sogooda

该用户还没有设置签名,暂不外售!

帖子
333 
积分
153 
威望
118 点 
体能
895 点 

论坛之星勋章

发表于 2009-5-22 12:38 |显示全部帖子
不错,在mathworks的fileexchange的那个链接下有一个.c文件可以看出,老外也是写了一个C-MEX调用windows的API实现的:
  1. void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
  2. {
  3.         /* declare variables */
  4.         HWND hWnd;
  5.         long nStyle;
  6.         int strLength;
  7.         char *windowname, *resizeState;

  8.         /* length of the string */
  9.         strLength = mxGetN(prhs[0])+1;
  10.         /* allocate memory for the window name */
  11.         /* MATLAB frees the allocated memory automatically */
  12.         windowname = mxCalloc(strLength, sizeof(char));
  13.         /* copy the variable from MATLAB */
  14.         mxGetString(prhs[0],windowname,strLength);

  15.         /* length of the string */
  16.         strLength = mxGetN(prhs[1])+1;
  17.         /* allocate memory for the resize state */
  18.         /* MATLAB frees the allocated memory automatically */
  19.         resizeState = mxCalloc(strLength, sizeof(char));
  20.         /* copy the variable from MATLAB */
  21.         mxGetString(prhs[1],resizeState,strLength);


  22.         /* handle of the window */
  23.         hWnd = FindWindow(NULL,windowname);

  24.         /* get current window style */
  25.         nStyle = GetWindowLong(hWnd,GWL_STYLE);

  26.         /* make sure that the window can be resized */
  27.         SetWindowLong(hWnd,GWL_STYLE,nStyle | WS_MAXIMIZEBOX);

  28.         /* maximize window */
  29.         ShowWindow(hWnd,SW_MAXIMIZE);

  30.         /* window is not resizable */
  31.         if(strcmp(resizeState,"off") == 0)
  32.         {
  33.                 /* restore the settings */
  34.                 SetWindowLong(hWnd,GWL_STYLE,nStyle);
  35.         }

  36.         /* redraw the menu bar */
  37.         DrawMenuBar(hWnd);
  38. }
复制代码
与SCIE的程序如出一辙。SCIE还曾经写过一个很有用的,用于获得figure窗口句柄的函数:
http://forum.simwe.com/thread-779810-1-3.html

至于java的UNDOCUMENTED属性,个人建议少用或者不用,其中一些在后续版本中将被取消,例如javaframe属性。
2

查看全部评分

  • ChaChing

  • sogooda

签名已到期,被屏蔽。
你需要登录后才可以回帖 登录 | 我要加入
验证问答 换一个

Archiver|中国振动联盟 ( 黑ICP备07002574号 )

GMT+8, 2012-5-18 14:03 , Processed in 0.090240 second(s), 17 queries , Eaccelerator On.

请勿发布违反中华人民共和国法律法规的言论,会员观点不代表本站官方立场。

Powered by Discuz! X1.5 © 2001-2010 Comsenz Inc.