WindowAPI

Versión 1.5.0 (24,4 KB) por Jan
Set figure size, top-most, transparency and pixel mask, multi-monitor etc by Windows API
6K Descargas
Actualizado 23 feb 2022

Ver licencia

WINDOWAPI - Set window properties using the Windows API
There are a lot of functions in the FEX to set the figure properties, e.g. maximized, minimized, always-on-top, level of transparency (using Java).
This submission adds some new features:
1. Maximize a window with or without visible taskbar or menu bar.
2. Set transparency level of figure and stencil-color: pixels of a this color are 100% transparent.
3. Placing figures on multi-monitor setups.
4. Clip region: draw only pixles inside a specified rectangle (e.g. splash screen).
5. Lock cursor: Especially for games it can be useful to keep the mouse cursor in a specified rectangle.
WindowAPI(FigH, Command)
INPUT:
FigH: Matlab's figure handle or Windows HWND
Command:
TopMost: Window is topmost even if the focus is lost
NoTopMost: Disable the topmost state
Front: Move window on toptemporarily
Minimize: Minimize the window
Restore: Restore to former size
Maximize: Full screen, taskbar and menubar visible
XMax, YMax: Maximize figure horizontally or vertically only
Position: Set inner figure position to 'work' (taskbar visible), 'full' (taskbar hidden),
or [X,Y,Width,Height].
Monitor index can be specified also
OuterPosition: As Position, but with figure border and titlebar
Flash: Short flashing
Alpha: Set the figure's transparency between 0.0 and 1.0.
4th input [R,G,B]: Pixels with this color are 100% transparent in addition
Opaque: Release memory needed for alpha blending
Clip: Draw only pixels inside a rectangle
ToScreen: Move figure completely to nearest monitor
SetFocus: Gain keyboard focus to figure (figure(FigH) is buggy)
LockCursor: Limit the cursor motion to a rectangle
SetFocus: Activate figure
Enable: Enable or disable all GUI elements
Hide, Show: Hide the window without changing its Os handle
Button: Set visibility of Max, Min, Close buttons in the window border
Reply = WindowAPI(FigureHandle, Command)
GetStatus: Replies 'maximized', 'minimized' or 'restored'.
GetHWnd: Reply the Windows handle of the figure.
Position/OuterPosition: If used with 2 inputs, the position relative to current monitor and the monitor index is replied.
Monitor: Get index and position of monitor.
NOTES:
This function calls Windows-API functions => No Linux, no MacOS - sorry.
The function is written in C and must be compiled before using by the mex command. See WindowAPI.c for instructions.
The automatic compilation creates a Mex function for the running Matlab version.
Do not run a Mex compiled for <= R2014b in a higher Matlab version and vice-versa.
EXAMPLES:
Maximize the current figure:
WindowAPI(gcf, 'maximize')
A semi-transparent figure with through-looking background:
FigH = figure('Color', ones(1,3));
plot(1:10);
WindowAPI(FigH, 'Alpha', 0.5, [255,255,255]);
Draw a button without surrounding figure ("splash button"):
FigH = figure;
ButtonH = uicontrol('Style', 'PushButton', 'String', 'Bye', ...
'Units', 'pixels', 'Callback', 'delete(gcbf)');
WindowAPI(FigH, 'Clip', get(ButtonH, 'Position'));
Tested: Matlab 6.5, R2015b/32&64, R2016b, R2018b, MSVC, BCC
See also:
ShowWindow, Matthew Simoneau:
Window Manipulation, Phil Goddard:
api_showwindow, Mihai Moldovan:
maxfig, Mihai Moldovan:
setFigTransparency, Yair Altman:

Citar como

Jan (2024). WindowAPI (https://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2016b
Compatible con cualquier versión desde R2014b
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y MATLAB Answers.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.5.0

No automagic support of Matlab < R2014b anymore.

1.4.0.0

Lock cursor, tested with Win7/64 also.
Demo did not run due to a bug.
HG1/HG2 compatibility.

1.3.0.0

Bug in uTest_WindowAPI: 'crop' -> 'clip'. No changes in the main function.

1.2.0.0

Multi-monitor handling, Clip region, ToScreen, XMax, YMax
Position command replaces Screen and FullScreen commands.

1.1.0.0

FullScreen: improved placement and not topmost anymore (thanks Marc!)

1.0.0.0