Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with ShowWindow() and losing focus

Problem with ShowWindow() and losing focus

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    s_k
    wrote on last edited by
    #1

    Hi, I have MFC application with splitter window that divides client area to two views, both are CListView-derived classes. Because I want to keep columns to have stable proportions all the time, I'm catching CMyListView::OnSize() and executing this code: void CMyFileView::OnSize(UINT nType, int cx, int cy) { int my_cx = cx; INT iWidth = 0; RECT viewRect; ::ZeroMemory(&viewRect, sizeof(RECT)); GetClientRect(&viewRect); INT iViewLen = viewRect.right - viewRect.left; CMultiColumnSortListView::OnSize(nType, cx, cy); // disable horizontal scroll bar GetListCtrl().ShowScrollBar(SB_HORZ, FALSE); INT iColWidth = 0; if (cx != old_cx) { GetListCtrl().ShowWindow(SW_HIDE); for (INT i = 0; i < (COLUMN_NUM - 1); i++) { iColWidth = viewRect.right * COLUMN_WIDTHS[i]; iWidth += iColWidth; GetListCtrl().SetColumnWidth(i, (viewRect.right * COLUMN_WIDTHS[i])); } GetListCtrl().SetColumnWidth((COLUMN_NUM - 1), (iViewLen - iWidth)); GetListCtrl().ShowWindow(SW_SHOW); } } old_cx = cx; } I call ShowWindow() in order to stop flickering, it helped. The problem is, calling ShowWindow() deselectes selected item (selected before with SetItemState()). I tried to call SetItemState() again after ShowWindow(SW_SHOW), but it doesn't work as expected, it highlights item, but it doesn't select and focus it 100% (it just draw grey rectangle aroung the item, but doesn't display dark blue rectangle which appears in normal case). Does somebody know what to do to select and focus the item again successfully? Thanks for any suggestion.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups