CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    LVS_NOSORTHEADER problem in Win7

    Win32API (no MFC) in Windows 7
    once a listview control is created, if I add the style LVS_NOSORTHEADER, it has no effect, is does not disable the column buttons. Anyone have any ideas?

    //Code is in OnInit dialog, and does not work
    HWND hList = GetDlgItem(hwnd,IDC_LSV1);
    LONG stl = GetWindowLong(hList,GWL_STYLE);
    SetWindowLong(hList,GWL_STYLE,stl|LVS_NOSORTHEADER);

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: LVS_NOSORTHEADER problem in Win7

    Try to set this style while creating the list control.
    Also see http://us.generation-nt.com/answer/l...-24653452.html
    Victor Nijegorodov

  3. #3
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    Re: LVS_NOSORTHEADER problem in Win7

    Thanks for the link, so I guess after creation you are stuck....
    this did work.....

    HWND hHdr = ListView_GetHeader(m_lsv1.m_hWnd);
    LONG stl = GetWindowLong(hHdr,GWL_STYLE);
    stl &= ~(HDS_BUTTONS);
    SetWindowLong(hHdr,GWL_STYLE,stl);//HDS_BUTTONS


    I have another problem now that does not make sense....
    (hwnd is my dialog, this code is in my OnInit dlg)

    Code:
        //create list view control...
        RECT rc;
        GetClientRect(hwnd,&rc);
        HINSTANCE hInst = GetModuleHandle(NULL);
        DWORD stl = WS_CHILD|WS_TABSTOP|WS_VISIBLE|WS_VSCROLL|LVS_REPORT|LVS_SINGLESEL|LVS_SHOWSELALWAYS|LVS_ALIGNLEFT;
        DWORD stlEx = WS_EX_CLIENTEDGE|WS_EX_LTRREADING|WS_EX_RIGHTSCROLLBAR|LVS_EX_LABELTIP;
        HWND hListView = CreateWindowEx(stlEx,"SysListView32","",stl,0,0,rc.right-rc.left,
                                         rc.bottom-rc.top-38,hwnd,(HMENU)IDC_LSV1,hInst,NULL);
        ListView_SetExtendedListViewStyle(hListView,stlEx);
    
        HFONT font = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
        SendMessage(hListView,WM_SETFONT,(WPARAM)font,TRUE);
    WS_EX_RIGHTSCROLLBAR does not work, scroll bar is always on the left no matter what I do
    Last edited by 12oclocker; June 4th, 2012 at 05:17 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured