2011-06-09 40 views
0

我的想法是构建一个logo图像(类似于Matlab的启动程序),在我的GUI出现之前显示。我有以下代码(它得到修改由How do I make a splash screen for my MATLAB GUI application?给出的解决方案)吧:Matlab图形窗口转换(屏幕转换 - 图形用户界面设计)

% create a figure1 that is not visible yet, and has minimal titlebar properties 
fh = figure('Visible','off','MenuBar','none','NumberTitle','off',... 
    'DockControls','off'); 
% put an axes in it 
ah = axes('Parent',fh,'Visible','on'); 
% put the image in it 
ih = imshow('SIS.gif','Parent',ah); 
% set the figure1 size to be just big enough for the image, and centered at 
% the center of the screen 
imxpos = get(ih,'XData'); 
imypos = get(ih,'YData'); 
set(ah,'Unit','Normalized','Position',[0,0,1,1]); 
figpos = get(fh,'Position'); 
figpos(3:4) = [imxpos(2) imypos(2)]; 
set(fh,'Position',figpos); 
movegui(fh,'center') 
% make the figure1 visible 
set(fh,'Visible','on'); 
pause(3); 
close(fh); 

我有两个问题:

  • 数1:我想要的标志图像的身影窗口已经没有边界,没有标题和任务栏。我已经尝试了WindowAPI,但它不起作用,因为我在上面的代码之后调用它,并且因为窗口的可见性已关闭,所以它的句柄也不起作用。

  • 编号2:我想要的是,当徽标图像消失时,它显示gui窗口最大化。哪里有问题?徽标图像的窗口和gui窗口之间的屏幕过渡不平滑。我试图在Matlab Central的文件交换(WindowAPI,Maxfig,Maximize,SetFigTransparency等)中找到很多Matlab的应用程序,但没有成功。我意识到问题在于我的GUI的可见性(我启动了,直到创建了所有元素,然后将其更改为开启)。由于不可见性导致可视性不佳,前面提到的应用程序对我想要最大化的数字窗口没有影响。

观察Matlab的启动后,我注意到在显示徽标后,它显示一个全屏图像,然后是该程序的正常全屏。所以我试图创建一个最大化的全屏窗口,在标志的窗口关闭后出现。但是,现在的问题是这个最后一个和gui窗口之间的转换。如果我将GUI窗口的可见性设置为最大,然后将其最大化,那么在瞬间可以看到困扰我的转换。我不知道该怎么办。我还认为,如果我可以避免当我改变其可见性时指南窗口是当前的图形,也许我会实现它。其他解决方案它可能是一个计时器,将白窗口保持为当前状态,而引导窗口正在改变其可见性,但我不知道该怎么办。感谢您的关注。干杯。

回答

1

正如我在this answer中显示的,从this MathWorks newsgroup thread派生的,您可以使用Java创建一个没有标题,边界等的窗口。下面是我的其他答案的代码进行修改,以创建居中显示在屏幕上的启动画面:

img = imread('peppers.png'); %# A sample image to display 
jimg = im2java(img); 
frame = javax.swing.JFrame; 
frame.setUndecorated(true); 
icon = javax.swing.ImageIcon(jimg); 
label = javax.swing.JLabel(icon); 
frame.getContentPane.add(label); 
frame.pack; 
imgSize = size(img); 
frame.setSize(imgSize(2),imgSize(1)); 
screenSize = get(0,'ScreenSize'); %# Get the screen size from the root object 
frame.setLocation((screenSize(3)-imgSize(2))/2,... %# Center on the screen 
        (screenSize(4)-imgSize(1))/2); 
frame.show; %# You can hide it again with frame.hide 

我会尝试这个创建闪屏,看看它是否也与过渡到下一个GUI的问题帮助窗口。

+0

谢谢您的回答。给定的解决方案可以创建一个启动画面。我会添加一些语句('pause(3); frame.hide;')来控制图像曝光的时间(在这种情况下为3秒)。干杯 – julian 2011-06-11 22:40:07

0

经过长期的研究工作,我找到了一个最接近我想的合理答案。如果您在File Exchange浏览器中输入“启动画面”,则会有一些专门为其设计的有趣应用程序。我选择了splash.m。关于平稳过渡,我已经使用了这些程序:WindowAPImaximize

书面的代码如下所示:

logoh = splash('logo.jpg'); %# Appear the logo image 
    fh = figure('Visible','on','Name','MyGUI','Position',[-1000,-1000,... 
    1000,500],'Menu','none','Toolbar','none','NumberTitle','off'); 
    %# Put the figure window outside the screen (see Position property) because 
    %# its visibility is on 
    WindowAPI(fh,'Alpha',0); %# Make the figure window invisible 
    ... 
    movegui(fh,'center'); %# Move the figure window to center 
    maximize(fh);% Maximize it 
    WindowAPI(fh,'Alpha',1); %# Make the figure window visible totally 
    pause(2); %# time during which the logo image is exposed 
    splash(logoh,'off'); %# Disappear the logo image