Thread: Resize Listview

  1. #1
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183

    Resize Listview

    Hi,

    I have a realizable window with a list view in it. When the window resizes, I'd like to resize it as well. Is there an automatic way to do this, or do I have to do it manually? Thanks.

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by mikeman118 View Post
    Hi,

    I have a realizable window with a list view in it. When the window resizes, I'd like to resize it as well. Is there an automatic way to do this, or do I have to do it manually? Thanks.
    That depends on the programming language. In Delphi for example, you could set design-time Anchor attributes and it would happen automatically at runtime.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I create the listview as a ratio of the window size (ie 90% height, 30% width)

    I process WM_SIZE (OnSize) msgs and call SetWindowPos() with the new ratio.

    Some owner draw can cause issues with this though, in which case I destroy the listview and create a new one.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    Quote Originally Posted by novacain View Post
    I create the listview as a ratio of the window size (ie 90% height, 30% width)

    I process WM_SIZE (OnSize) msgs and call SetWindowPos() with the new ratio.

    Some owner draw can cause issues with this though, in which case I destroy the listview and create a new one.
    So how do you set up the window as a ratio? Or are you just saying you look at it and set it that way? Also, how do you know how much to change it? Does the WM_SIZE message contain the amount of change?

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I decide at design time how big the controls need to be to look good and fit the data. I adjust the controls ratio (percentage) accordingly and hard code it. I get the ratio by trial and error (looking at it).

    The WM_SIZE contains the new width and height of the window.

    I calc the controls new width and height using the ratio and the new size. Then use SetWindowPos() to change the size of the control.

    I do not need the 'amount' of change, just the new width and height.

    This also ensures that my app looks proportional at any resolution and window size.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ListView disappearing on resize!?
    By Viper187 in forum Windows Programming
    Replies: 3
    Last Post: 06-09-2008, 05:05 PM
  2. png Image Resize
    By bhupesh.kec in forum C Programming
    Replies: 3
    Last Post: 12-06-2007, 07:52 AM
  3. Prevent listview column resize
    By Stabbsy in forum Windows Programming
    Replies: 2
    Last Post: 05-30-2007, 11:03 PM
  4. Troubles with ListView and Toolbar
    By cornholio in forum Windows Programming
    Replies: 8
    Last Post: 11-14-2005, 01:26 AM
  5. Listview??
    By SuperNewbie in forum C# Programming
    Replies: 4
    Last Post: 02-13-2003, 03:34 AM