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. ListView control

ListView control

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
6 Posts 3 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.
  • H Offline
    H Offline
    hitokiribattousai
    wrote on last edited by
    #1

    hi! can anyone tell me how to prevent the user from resizing the listview column header? i'm using MFC btw. thx!

    M K 2 Replies Last reply
    0
    • H hitokiribattousai

      hi! can anyone tell me how to prevent the user from resizing the listview column header? i'm using MFC btw. thx!

      M Offline
      M Offline
      Mark Swann
      wrote on last edited by
      #2

      I have not used column headers in a list view before but let me hazard a guess. Try subclassing the listview and capturing the LVM_SETCOLUMNWIDTH message. Replace the new column width with your own hard-coded width then send the LVM_SETCOLUMNWIDTH message to the default control proc. Tell me if it works.

      H 1 Reply Last reply
      0
      • M Mark Swann

        I have not used column headers in a list view before but let me hazard a guess. Try subclassing the listview and capturing the LVM_SETCOLUMNWIDTH message. Replace the new column width with your own hard-coded width then send the LVM_SETCOLUMNWIDTH message to the default control proc. Tell me if it works.

        H Offline
        H Offline
        hitokiribattousai
        wrote on last edited by
        #3

        umm, how do i catch the LVM_SETCOLUMNWIDTH message? it's not available in the ClassWizard event list...

        M 2 Replies Last reply
        0
        • H hitokiribattousai

          umm, how do i catch the LVM_SETCOLUMNWIDTH message? it's not available in the ClassWizard event list...

          M Offline
          M Offline
          Mark Swann
          wrote on last edited by
          #4

          You should be able find LVM_SETCOLUMNWIDTH in the ClassWizard. Open the Class Wizard and (in the Message Maps tab) look at the list box labeled "Object IDs:". By default the class name of the dialog will be selected. Search further down the list until you find the resource ID of your ListView control then select it. The "Messages:" list box to the right will then show the messages appropriate for ListView controls. Search through the list to find the one you want. Good luck.

          1 Reply Last reply
          0
          • H hitokiribattousai

            umm, how do i catch the LVM_SETCOLUMNWIDTH message? it's not available in the ClassWizard event list...

            M Offline
            M Offline
            Mark Swann
            wrote on last edited by
            #5

            I must appologize. I went through the steps that I previously gave you and didn't find LVM_SETCOLUMNWIDTH. After further thought I feel that you will have to subclass the ListView control (CListCtrl) with your own class that inherits from CListCtrl. Override the WindowProc function. (You'll find WindowProc in class CWnd.) The prototype should look as follows: (I hope all this formatting doesn't get lost. I'll double space to be certain.) LRESULT CYourClass::WindowProc(UINT message, WPARAM wParam, LPARAM lParam); And the body should appear somewhat as follows: (I have not actually done this with CListCtrl but it should work.) // Begin Body { int nFixedWidth = 100; // Hard-coded width switch ( message ) { case LVM_SETCOLUMNWIDTH: // override lParam lParam = MAKELPARAM( nFixedWidth, 0); break; } return CListCtrl::WindowProc(message, wParam, lParam); } // End body The value assigned to nFixedWidth is in list view coordinates. It looks fairly simple. I hope this works for you

            1 Reply Last reply
            0
            • H hitokiribattousai

              hi! can anyone tell me how to prevent the user from resizing the listview column header? i'm using MFC btw. thx!

              K Offline
              K Offline
              Kurt 0
              wrote on last edited by
              #6

              Hi I think you should use the HDN_* notification messages, together with HD_HITTESTINFO and may be WM_MOUSEMOVE and then if conditions are fullfilled just not route these messages any further. Kurt

              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