Sometimes it's difficult to tell an audience to look at a particular area of the screen. Whether it's for a product demo, presentation, screencast or a lecture. MouseLight tries to eliminate this problem.
This utility puts a "spotlight" and dims the surrounding area which enables your audience to effortlessly follow your path of movement on the screen.
Our goal solves the problem that we need to know the 2 concepts given below:
LayeredWindow - Windows APIs support a layered window made transparent for a dialog. We will create a dialog with size equal to desktop and use this technique to blur the surrounding area.
Region - We can change the shape of the dialog based on
Region. With this technique, we can make a spotlight with different shapes such as Round, etc.
How To Make SpotLight
First, we will create a dialog with a size equal to desktop window. We must go to the resource mode of that dialog, set properties of dialog - border = none, so this dialog will be removed in the title bar. And we will blur this dialog by making transparent with specified percent rate. So we still see different windows although our dialog is topmost, as you see the code below (also see my 2 WndShadow h/cpp files):
HMODULE hSysDll = LoadLibrary(_T("USER32.DLL"));
if (NULL == s_UpdateLayeredWindow)
GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
return s_SetLayeredWindowAttributes (hWnd,
RGB(255, 0, 255),
To make spotlight, we use the
Region technique. Create a memory DC/Bitmap with a size equal to desktop window and draw Round, etc. at some position and then convert BitmapToRegion (you can see my 2 Region cpp/hpp files) and set
Region to our dialog as below:
CRect cRectRound(0, 0, m_cCurrentFocusSize.cx, m_cCurrentFocusSize.cy);
&m_cRoundVideoMemDC, 0, 0, SRCCOPY);
CRect cRectRound2(0, 0, m_cCurrentFocusSize.cx+SIZE_BORDER,
&m_cRoundBgMemDC, 0, 0, SRCCOPY);
HRGN hRgn = BitmapToRegion(m_cVideoMemDC.m_hDC, 0, 0,
int iRes = this->SetWindowRgn(hRgn, FALSE);
SpotLight will move to follow the mouse position changes. In my old version, I used Mouse event as left clickup/down and mousemove on Dialog to move SpotLight. Now, I wrote a DLL to monitor
MouseMove action (also see
SetWindowHook in MSDN).
LRESULT CMouseLightDlg::OnMouseHook(WPARAM wParam, LPARAM lParam)
if (wParam == WM_MOUSEMOVE)
if (g_bSaved == FALSE)
g_bSaved = TRUE;
if (Point != g_cSavedPoint)
g_cSavedPoint = Point;
We can also draw an image background on that dialog and an image around SpotLight. So it is easy for an audience to look at a particular area of the screen. (Also see another article here.)
Points of Interest
Windows APIs support
SetLayeredWindowAttributes function to make a dialog transparent. So we can use this function to make our application "beautifully".
- Version 22.214.171.124
- Use the
MouseHook technique to monitor
- Version 126.96.36.199
- Allow to zoom in/out by Ctrl +
- Look better