问:如何用语句实现matlab图形窗口的最大化
图形窗口启动时为默认模式,我想用语句实现使它最大化谢谢! h = figure;
set(gcf,'outerposition',get(0,'screensize')); 原帖由 shuishenshen 于 2007-2-3 10:33 发表
图形窗口启动时为默认模式,我想用语句实现使它最大化
谢谢!
happy教授的方法没有问题,或者使用以下方法:
h = figure;
set(gcf,'units','normalized','position',);
还可以参考其他方法:
http://www.simwe.com/forum/viewthread.php?tid=161775
回复 板凳 eight 的帖子
非常感谢3楼的回答我想知道‘units’、'normalized'都表示什么意思??
能有解答的么??
不甚感激
回复 地板 tuoniao992002 的帖子
Units {pixels} | normalized | inches | centimeters| points | charactersUnit 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. 原帖由 eight 于 2007-2-3 11:29 发表 http://www.chinavib.com/forum/images/common/back.gif
happy教授的方法没有问题,或者使用以下方法:
h = figure;
set(gcf,'units','normalized','position',);
还可以参考其他方法:
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文件。 本帖最后由 coohit 于 2016-8-16 10:05 编辑
不错,在mathworks的fileexchange的那个链接下有一个.c文件可以看出,老外也是写了一个C-MEX调用windows的API实现的:void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
/* declare variables */
HWND hWnd;
long nStyle;
int strLength;
char *windowname, *resizeState;
/* length of the string */
strLength = mxGetN(prhs)+1;
/* allocate memory for the window name */
/* MATLAB frees the allocated memory automatically */
windowname = mxCalloc(strLength, sizeof(char));
/* copy the variable from MATLAB */
mxGetString(prhs,windowname,strLength);
/* length of the string */
strLength = mxGetN(prhs)+1;
/* allocate memory for the resize state */
/* MATLAB frees the allocated memory automatically */
resizeState = mxCalloc(strLength, sizeof(char));
/* copy the variable from MATLAB */
mxGetString(prhs,resizeState,strLength);
/* handle of the window */
hWnd = FindWindow(NULL,windowname);
/* get current window style */
nStyle = GetWindowLong(hWnd,GWL_STYLE);
/* make sure that the window can be resized */
SetWindowLong(hWnd,GWL_STYLE,nStyle | WS_MAXIMIZEBOX);
/* maximize window */
ShowWindow(hWnd,SW_MAXIMIZE);
/* window is not resizable */
if(strcmp(resizeState,"off") == 0)
{
/* restore the settings */
SetWindowLong(hWnd,GWL_STYLE,nStyle);
}
/* redraw the menu bar */
DrawMenuBar(hWnd);
}与SCIE的程序如出一辙。SCIE还曾经写过一个很有用的,用于获得figure窗口句柄的函数:
http://forum.vibunion.com/thread-147956-1-1.html
至于java的UNDOCUMENTED属性,个人建议少用或者不用,其中一些在后续版本中将被取消,例如javaframe属性。
页:
[1]