I have noticed a strange effect when I create a Listview.
When I create a ListView without also creating a Button, the selected item in the ListView have a dotted border. However, when I also create a Button, the ListView selected item don't have a dotted border anymore. This only happens when I have a manifest file that enables common controls 6:

This is the code I used to create the Window and ListView and Button:
// Create Window
HWND hWnd = CreateWindowEx(0, "WinClass", "My Window", WS_OVERLAPPEDWINDOW, 261, 172, 394, 284, NULL, NULL, hInstance, NULL);
// Create ListView
HWND hListView = CreateWindowEx(0, WC_LISTVIEW, "", WS_CHILD | LVS_REPORT | WS_VISIBLE, 0, 0, 232, 190, hWnd, 0, GetModuleHandle(NULL), NULL);
// Create Button
HWND hButtonRefresh = CreateWindowEx(NULL, "BUTTON", "OK", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 10, 200, 110, 25, hWnd, NULL, GetModuleHandle(NULL), NULL);
Note: I don't have a problem with this effect, I just want to understand why it is happening!
It's just because the button has the focus and the list view lost it, click on the list view and the dots should reappear.
I believe the dotted border is indicating the default control. In the second screenshot go to the Properties of the button and set Default Button to false and then you should see the dotted border around the text like in the first screenshot.
To do this open the dialog in Resources view, select the button and choose Properties from the right-button mouse menu. In the Properties window you should see Default Button in the Behavior section - just change it to False.
Alternatively in code try something like this:-
DWORD style = m_BtnOk.GetStyle();
// remove default push button style
style &= ~BS_DEFPUSHBUTTON;
// set the style
::SendMessage(m_BtnClose.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);
As others have indicated, it's purpose is to indicate input focus. If you Tab around any native form, you'll see the rectangle jump around the indexes set up by the developer.
The reason it appears at all is because it has a TabStop. As there is only one element in the first example, there's only one possibility for a tab stop, so it's indicated by the rectangle. Play around with the TabStop property, Tab around, see what changes.