xoblite™ / Blackbox for Windows bb5 | RC6 preview | 0.25.2.14
http://xoblite.net/
PopupDialog.cpp File Reference
#include "PopupDialog.h"

Functions

LRESULT CALLBACK PopupDialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

const char szPopupDialogName [] = "BBPopupDialog"
 
PopupDialogpPopupDialog
 
SettingspSettings
 
BImagepBImage
 
int popupDialogMessageSubscription [] = { BB_RECONFIGURE, BB_POPUPMESSAGE, 0 }
 

Function Documentation

◆ PopupDialogProc()

LRESULT CALLBACK PopupDialogProc ( HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam )
126{
127
128 switch (message)
129 {
130 //====================
131
132 case BB_POPUPMESSAGE:
133 {
134 if ((wParam == NULL) && (lParam == NULL))
135 {
136 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_HIDE);
137 pPopupDialog->PopupDialogHidden = true;
138 }
139 else
140 {
141// strncpy(pPopupDialog->message.title, (LPCSTR)wParam, sizeof(pPopupDialog->message.title));
142// strncpy(pPopupDialog->message.body, (LPCSTR)lParam, sizeof(pPopupDialog->message.body));
143 strncpy_s(pPopupDialog->message.title, sizeof(pPopupDialog->message.title), (LPCSTR)wParam, _TRUNCATE);
144 strncpy_s(pPopupDialog->message.body, sizeof(pPopupDialog->message.body), (LPCSTR)lParam, _TRUNCATE);
145 pPopupDialog->message.title[sizeof(pPopupDialog->message.title)-1] = '\0';
146 pPopupDialog->message.body[sizeof(pPopupDialog->message.body)-1] = '\0';
147
148 if (!_strnicmp(pPopupDialog->message.body, "@xoblite", 8) || !_strnicmp(pPopupDialog->message.body, "@GoToURL", 8)) pPopupDialog->PopupTypeYesNo = true;
149 else pPopupDialog->PopupTypeYesNo = false;
150
151 pPopupDialog->PopupDialogHidden = false;
152 pPopupDialog->UpdatePopupDialog();
153
154 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_SHOWNOACTIVATE);
155// if (pPopupDialog->PopupTypeYesNo) SetWindowPos(pPopupDialog->hPopupDialogWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOOWNERZORDER);
156// else
157// {
158// SetWindowPos(pPopupDialog->hPopupDialogWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOOWNERZORDER);
159// SetWindowPos(pPopupDialog->hPopupDialogWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOOWNERZORDER);
160// }
161 SetWindowPos(pPopupDialog->hPopupDialogWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOOWNERZORDER);
162
163 if (pPopupDialog->PopupTypeYesNo) SetForegroundWindow(pPopupDialog->hPopupDialogWnd); // Move the focus to the popup dialog window to allow Yes/No selection via the keyboard... (see WM_KEYDOWN below)
164 }
165 }
166 break;
167
168 //===========================================================================
169
170 case BB_RECONFIGURE:
171 case WM_DISPLAYCHANGE:
172 {
173 if (!pPopupDialog->PopupDialogHidden) pPopupDialog->UpdatePopupDialog();
174 }
175 break;
176
177 case WM_SETTINGCHANGE:
178 {
179 if (!pPopupDialog->PopupDialogHidden)
180 {
181 // Update the [centered] popup dialog window's position if the work area changes...
182 // (e.g. if the Explorer taskbar is moved to another screen edge)
183 if (wParam == SPI_SETWORKAREA) pPopupDialog->UpdatePopupDialog();
184 }
185 return 0;
186 }
187
188 //====================
189
190 case WM_CLOSE:
191 return 0;
192
193 //====================
194
195 case WM_NCHITTEST:
196 {
197 RECT r;
198 GetWindowRect(hwnd, &r);
199 int relativeY = HIWORD(lParam) - r.top; // Get y position relative to the window... (nb. lParam x/y position is relative to the *screen*)
200 if (relativeY <= pPopupDialog->PopupDialogTitleHeight) return HTCAPTION;
201 else return HTCLIENT;
202 }
203 break;
204
205 //====================
206
207 case WM_LBUTTONUP:
208 {
209 if (pPopupDialog->PopupTypeYesNo)
210 {
211 POINT pt;
212 pt.x = LOWORD(lParam);
213 pt.y = HIWORD(lParam);
214
215 // Did the user click the "Yes" button?
216 if (PtInRect(&pPopupDialog->popupYesRect, pt))
217 {
218 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_HIDE);
219 pPopupDialog->PopupDialogHidden = true;
220// PlaySoundFX(SFX_TASKBAR_MINIMIZE);
221 BBSmartExecute(pPopupDialog->message.body);
222 break;
223 }
224 else if (PtInRect(&pPopupDialog->popupNoRect, pt))
225 {
226 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_HIDE);
227 pPopupDialog->PopupDialogHidden = true;
228// PlaySoundFX(SFX_TASKBAR_MINIMIZE);
229 break;
230 }
231 }
232 else
233 {
234 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_HIDE);
235 pPopupDialog->PopupDialogHidden = true;
237 }
238 }
239 break;
240
241 //====================
242
243 case WM_KEYDOWN:
244 {
245 if (pPopupDialog->PopupTypeYesNo)
246 {
247 if (wParam == VK_RETURN) // Return key -> Equivalent to clicking the "Yes" button...
248 {
249 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_HIDE);
250 pPopupDialog->PopupDialogHidden = true;
251// PlaySoundFX(SFX_TASKBAR_MINIMIZE);
252 BBSmartExecute(pPopupDialog->message.body);
253 }
254 else if ((wParam == VK_ESCAPE) || (wParam == VK_DELETE)) // Escape of Delete key -> Equivalent to clicking the "No" button...
255 {
256 ShowWindow(pPopupDialog->hPopupDialogWnd, SW_HIDE);
257 pPopupDialog->PopupDialogHidden = true;
258// PlaySoundFX(SFX_TASKBAR_MINIMIZE);
259 }
260 }
261
262 return 0;
263 }
264 break;
265
266 //====================
267
268 default:
269 return DefWindowProc(hwnd, message, wParam, lParam);
270
271 //====================
272 }
273 return 0;
274}
void BBSmartExecute(LPSTR inputString)
Definition BBApi.cpp:1767
#define BB_RECONFIGURE
Definition BBApi.h:147
#define BB_POPUPMESSAGE
Definition BBApi.h:166
PopupDialog * pPopupDialog
Definition Blackbox.cpp:44
void PlaySoundFX(int sound)
Definition Sounds.cpp:40
@ SFX_TASKBAR_MINIMIZE
Definition Sounds.h:51

Variable Documentation

◆ szPopupDialogName

const char szPopupDialogName[] = "BBPopupDialog"

◆ pPopupDialog

PopupDialog* pPopupDialog
extern

◆ pSettings

Settings* pSettings
extern

◆ pBImage

BImage* pBImage
extern

◆ popupDialogMessageSubscription

int popupDialogMessageSubscription[] = { BB_RECONFIGURE, BB_POPUPMESSAGE, 0 }