Announcement

Collapse
No announcement yet.

Preventing ListView Column Resizing?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Preventing ListView Column Resizing?

    I'm pretty excited, I actually got the listview control to work in my program without any reference to the BBS for help (yes it's the simple things that make me happy).

    Of course, as Murphy would have it I have hit a stumbling block.

    How do you prevent the columns from being resized?

    It looks like you can intercept a header notification called HDN_BEGINTRACK and I'm pretty sure the listview control is comprised of that sub-control. Does that mean I need to sub-class?


    ------------------
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

  • #2
    I think I found the answer on the web...

    But I'm still not sure of the sub-classing. I unfortunately am not at my desk at work to test it, does anyone know for sure if you need/don't need to sub-class?

    BTW, found a good site about listview controls..

    http://zeus.eed.usv.ro/misc/doc/prog...tview_toc.html

    ------------------
    George W. Bleck
    Senior System Engineer
    KeySpan Corporation
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

    Comment


    • #3
      George,

      A small tip, anytime you have a Notification message, they are
      always sent to the Parent window, so you don't have to subclass the
      control in this case.

      An example for just a plain header control. This should give you enough
      info to get you started on the ListView.


      Code:
      '---
      %ID_HEADCONTROL        = 500   
       
      '---
      local hdnptr      as HD_NOTIFY PTR
      local hdiptr      as HD_ITEM   PTR
      local hditem      as HD_ITEM     
      local lo          as HD_LAYOUT  
      '---
       
       ...
       
      '---
          CASE %WM_NOTIFY
       
           select case lowrd(wParam)
       
             case %ID_HEADCONTROL
                   hdnptr = lParam
                   hdiptr = @hdnptr.pitem
       
               select case @hdnptr.hdr.code
       
                     case %HDN_ENDTRACK
       
                           If (@hdiptr.cxy < %MINWIDTH)  THEN
                               @hdiptr.cxy = %MINWIDTH
                               Columns(@hdnptr.iItem) = %MINWIDTH
                           Else
                               Columns(@hdnptr.iItem) = @hdiptr.cxy
                               Call GetClientRect(ghWndMain,rc)
                               rc.ntop = HeaderHeight
                               Call InvalidateRect(ghWndMain,rc,%TRUE)
                               'UpdateWindow ghWndMain
                           End if
       
                           'Function = 0
                           'Exit Select
       
                     case %HDN_TRACK
       
                           Call GetClientRect(ghWndMain,rc)
       
                              If(@hdiptr.cxy < %MINWIDTH) THEN
                                 @hdiptr.cxy = %MINWIDTH
                                 Columns(@hdnptr.iItem) = %MINWIDTH
       
                              Else
                                 Columns(@hdnptr.iItem) = @hdiptr.cxy
                                 rc.ntop = HeaderHeight
                                 'Call InvalidateRect(ghWndMain,rc,%TRUE)
                                 'UpdateWindow ghWndMain
                              End If
       
                          'Function = 0
                          'Exit Select
       
                     case %HDN_ITEMCLICK
       
                           hditem.mask = %HDI_WIDTH
                           Call SendMessage(ghHeadWnd, %HDM_GETITEM, @hdnptr.iItem, VARPTR(hditem))
                           hditem.cxy = %DEFWIDTH
                           Columns(@hdnptr.iItem) = %DEFWIDTH
                           Call SendMessage(ghHeadWnd, %HDM_SETITEM, @hdnptr.iItem, VARPTR(hditem))
                           Call GetClientRect(ghWndMain,rc)
                           rc.ntop = HeaderHeight
                           Call InvalidateRect(ghWndMain,rc,%TRUE)
                           UpdateWindow ghWndMain
       
                           'Function =0
                           'Exit Select
       
                     case %HDN_ITEMDBLCLICK
       
                           hditem.mask = %HDI_WIDTH
                           Call SendMessage(ghHeadWnd, %HDM_GETITEM, @hdnptr.iItem, VARPTR(hditem))
                           hditem.cxy = hditem.cxy + hditem.cxy
                              If (hditem.cxy > %MAXWIDTH) THEN
                                  hditem.cxy = %MAXWIDTH
                              End If
       
                           Columns(@hdnptr.iItem) = hditem.cxy
                           Call SendMessage(ghHeadWnd, %HDM_SETITEM, @hdnptr.iItem, VARPTR(hditem))
                           Call GetClientRect(ghWndMain,rc)
                           rc.ntop = HeaderHeight
                           Call InvalidateRect(ghWndMain,rc,%TRUE)
                           UpdateWindow ghWndMain
       
                           'Function = 0
                           'Exit Select
       
               End Select
       
           End Select

      HTH
      Regards, Jules




      [This message has been edited by Jules Marchildon (edited September 05, 2000).]

      Comment

      Working...
      X