WindowAPI

Versione 1.5.0 (24,4 KB) da Jan
Set figure size, top-most, transparency and pixel mask, multi-monitor etc by Windows API
5,9K download
Aggiornato 23 feb 2022

Visualizza la licenza

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:

Cita come

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

Compatibilità della release di MATLAB
Creato con R2016b
Compatibile con R2014b e release successive
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
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