0

My idea is building a logo image (similar to Matlab's startup one) which shows before my gui is appeared. I have the following code (it was obtained modifying the solution given by How do I make a splash screen for my MATLAB GUI application?) for it:

% 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);

I have two problems:

  • Number 1: I want the logo image's figure windows has no borders, no title and no taskbars. I have tried the WindowAPI but it does not work because I call it after the above code and because of the visibility of the window is off, then the handle of it is off too.

  • Number 2:I want that, when the logo image is disappeared, it is showed the gui window maximized. Where is the problem? The screen transition between the logo image's window and the gui window is not smoothed. I have tried to use a lot of Matlab´s applications that I found in Matlab Central's File Exchange (WindowAPI, Maxfig, Maximize, SetFigTransparency,...) without success. I realized that the problem is the visibility of my gui (I set off until all elements are created and then I change it to on). Because of the off visibility cause the handlevisibility is off too, the previous mentioned applications has no effects on the figure window that I want to maximize.

After observating the startup of Matlab, I have noticed that after the logo is showed, it appears a fullscreen image followed by the normal fullscreen of the program. So I have tried to create an maximized fullscreen windows that appears after the logo's windows is closed. However, now the problem is the transition between this last and the gui window. If I set the visibility of the gui window on and then I maximize it, during an instant it can be seen that transition that bothers me. I do not know what to do. I also think that if I could avoid that the guide window is currentfigure when I change its visibility, perhaps I would achieve it. Other solution it might be a timer that hold the white window as currentfigure while the guide window is behind changing its visibility but I do not know how to do. Thank you for your attention. Cheers.

julianfperez
  • 1,726
  • 5
  • 38
  • 69

2 Answers2

1

As I show in this answer, derived from this MathWorks newsgroup thread, you can create a window without a title, borders, etc., using Java. Here's a modification of the code from my other answer to create a splash window centered on the screen:

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

I would try this to create your splash screen and see if it also helps with the problems transitioning to the next GUI window.

Community
  • 1
  • 1
gnovice
  • 125,304
  • 15
  • 256
  • 359
  • Thank you for your answer. The given solution works to create a splash screen. I would add some statements ( `pause(3); frame.hide;` ) to control the time (3 seconds in this case) during which the image is exposed. Cheers – julianfperez Jun 11 '11 at 22:40
0

After a long research work, I have found a reasonable answer which was nearest to that I thought. If you type in "splash screen" in the File Exchange browser, you have some interesting applications designed specifically to it. I have chosen splash.m. With respect to the smooth transition, I have used these programs: WindowAPI and maximize.

The written code looks like this:

    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
julianfperez
  • 1,726
  • 5
  • 38
  • 69