Skip to content

Commit b9d53c5

Browse files
committed
SpoutMessageBoxPosition
01.07.24 - Increase SpoutMessageBox combo width for NDI sender names - Add "SpoutMessageBoxModeless" to warning caption if SpoutPanel not found 02.07.24 - Add SpoutMessageBoxPosition
1 parent 4268960 commit b9d53c5

2 files changed

Lines changed: 51 additions & 8 deletions

File tree

SPOUTSDK/SpoutGL/SpoutUtils.cpp

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@
193193
Correct conditional definition of EndTiming in header file
194194
Allow mingw to define USE_CHRONO if available
195195
Include <math.h> to fix mingw build
196-
196+
01.07.24 - Increase SpoutMessageBox combo width for NDI sender names
197+
- Add "SpoutMessageBoxModeless" to warning caption if SpoutPanel not found
198+
02.07.24 - Add SpoutMessageBoxPosition
199+
197200
198201
199202
*/
@@ -1122,7 +1125,7 @@ namespace spoututils {
11221125
errmsg += "to enable modeless function for SpoutMessageBox.\n\n\n";
11231126
bool oldmode = bModeless;
11241127
bModeless = false;
1125-
SpoutMessageBox(NULL, errmsg.c_str(), "Warning", MB_ICONWARNING | MB_OK);
1128+
SpoutMessageBox(NULL, errmsg.c_str(), "SpoutMessageBoxModeless - Warning", MB_ICONWARNING | MB_OK);
11261129
bModeless = oldmode;
11271130
return;
11281131
}
@@ -1140,6 +1143,13 @@ namespace spoututils {
11401143
hwndMain = hWnd;
11411144
}
11421145

1146+
// ---------------------------------------------------------
1147+
// Function: SpoutMessageBoxPosition
1148+
// Position to centre SpoutMessageBox
1149+
void SPOUT_DLLEXP SpoutMessageBoxPosition(POINT pt)
1150+
{
1151+
TDcentre = pt;
1152+
}
11431153

11441154

11451155
// ---------------------------------------------------------
@@ -2027,6 +2037,10 @@ namespace spoututils {
20272037
// Use before calling any of the SpoutMessagebox functions
20282038
hTaskIcon = nullptr;
20292039

2040+
// Clear dialog user position
2041+
TDcentre.x = 0;
2042+
TDcentre.y = 0;
2043+
20302044
// Return button pressed
20312045
// IDCANCEL, IDNO, IDOK, IDRETRY, IDYES
20322046
// or custom button ID
@@ -2056,11 +2070,27 @@ namespace spoututils {
20562070
SendMessage(hwnd, WM_SETICON, ICON_BIG, NULL);
20572071
SendMessage(hwnd, WM_SETICON, ICON_SMALL, NULL);
20582072

2059-
// Set topmost
2060-
if (bTopMost) {
2061-
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
2073+
// Dialog Window size and position
2074+
RECT rect;
2075+
GetWindowRect(hwnd, &rect);
2076+
int x = rect.left;
2077+
int y = rect.top;
2078+
int w = rect.right-rect.left;
2079+
int h = rect.bottom - rect.top;
2080+
2081+
// Centre the taskdialog window on the point
2082+
// if SpoutMessageBoxPosition has been used
2083+
if (TDcentre.x > 0 || TDcentre.y > 0) {
2084+
// Offset to the centre of the window
2085+
x = TDcentre.x - (w/2);
2086+
y = TDcentre.y - (h/2);
20622087
}
20632088

2089+
if (bTopMost)
2090+
SetWindowPos(hwnd, HWND_TOPMOST, x, y, w, h, SWP_NOSIZE);
2091+
else
2092+
SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, w, h, SWP_NOSIZE);
2093+
20642094
// Edit text control
20652095
if (bEdit) {
20662096

@@ -2106,15 +2136,23 @@ namespace spoututils {
21062136

21072137
// Taskdialog client size
21082138
int h = rect.bottom-rect.top;
2109-
int x = rect.left+70;
2139+
int x = rect.left+20;
21102140
int y = rect.top;
2141+
int w = 395;
2142+
21112143
// Allow for increased height with an icon
2112-
if(h > 90) y += 20;
2113-
int w = 300;
2144+
// and position further right
2145+
if (h > 90) {
2146+
y += 20;
2147+
x += 40;
2148+
w -= 40;
2149+
}
2150+
21142151
// Combo box inital height. Changed by content.
21152152
h = 100;
21162153

21172154
// Position in the footer area if there is message content
2155+
// Less width due to buttons
21182156
if (*pTimeout && *pTimeout == 1000000) {
21192157
x = rect.left+10;
21202158
y = rect.bottom-40;

SPOUTSDK/SpoutGL/SpoutUtils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ namespace spoututils {
275275
// Window handle for SpoutMessageBox where not specified
276276
void SPOUT_DLLEXP SpoutMessageBoxWindow(HWND hWnd);
277277

278+
// Position to centre SpoutMessageBox
279+
void SPOUT_DLLEXP SpoutMessageBoxPosition(POINT pt);
280+
278281
// Copy text to the clipboard
279282
bool SPOUT_DLLEXP CopyToClipBoard(HWND hwnd, const char* caps);
280283

@@ -362,6 +365,8 @@ namespace spoututils {
362365
bool OpenSpoutPanel(const char* message);
363366
// Application window
364367
HWND hwndMain = NULL;
368+
// Position for TaskDialog window centre
369+
POINT TDcentre = {};
365370
// For topmost
366371
HWND hwndTop = NULL;
367372
bool bTopMost = false;

0 commit comments

Comments
 (0)