Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Strange effect when creating a ListView

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:

enter image description here

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!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report

0

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);
over 4 years ago · Santiago Trujillo Report

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!