CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Join Date
    Jul 2001
    Posts
    306

    [RESOLVED] Change item height in CListBox / CListCtrl

    Hello,

    I need a ownerdraw CListBox where I can change the item height during working with the list.
    The msdn says that I can specify the height in OnMeasureItem when the listbox will be created (ownerdrawfixed) or when an item will be inserted (ownerdrawvariable).

    Any ideas how to change the height e.g. when I click a button?

    I made also some tests with CListCtrl. There I can change the height.
    But there is only one height for all items.
    Any ideas how to set individual heights for the items?

    thx
    Ralf

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Change item height in CListBox / CListCtrl

    Quote Originally Posted by Ralf Schneider View Post
    Hello,

    I need a ownerdraw CListBox where I can change the item height during working with the list.
    The msdn says that I can specify the height in OnMeasureItem when the listbox will be created (ownerdrawfixed) or when an item will be inserted (ownerdrawvariable).

    Any ideas how to change the height e.g. when I click a button?

    I made also some tests with CListCtrl. There I can change the height.
    But there is only one height for all items.
    Any ideas how to set individual heights for the items?

    thx
    Ralf
    to change height:
    remove old item
    insert a new item (possibly with the same content as the one you just removed) with the new desired height in the same place


    ListCtrl does not support varying height items. Only ListBox supports this.


    You could Always create your own control if you need something the default controls don't provide (expect this to take quite a bit of work)

  3. #3
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    Hello OReubens,

    thank you.

    Regarding CListBox:
    when I use ownerdrawfixed, how can I change the height?

    Ralf

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

    Re: Change item height in CListBox / CListCtrl

    CListBox::SetItemHeight
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    Hello Victor,

    SetItemHeight() sounds good.
    It would solve my problems.
    But way do OnMeasureItem exist, if everything can be handled with SetItemHeight().

  6. #6
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    Hello,

    to make the best solution, I started to create my own listbox.
    Base class: CStatic.

    It works pretty good, but now I entered one problem:
    I can not detect key strokes. OnChar or OnKeyDown in my class are not called. Setting the focus in my OnLButtonDown-function has no effect.
    There is also no change if I change the base class to CWnd.

    Any hints?

    thx
    Ralf

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

    Re: Change item height in CListBox / CListCtrl

    Quote Originally Posted by Ralf Schneider View Post
    to make the best solution, I started to create my own listbox.
    Base class: CStatic.
    ...
    I can not detect key strokes. OnChar or OnKeyDown in my class are not called. Setting the focus in my OnLButtonDown-function has no effect.
    There is also no change if I change the base class to CWnd.
    I doubt it would be "the best solution".
    And I'd probably prefer CWnd, not a CStatic.

    Well, how did you implement this OnChar? Do you handle WM_CHAR? WM_KEYDOWN/WM_KEYUP? Something else?
    Victor Nijegorodov

  8. #8
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    Hello Victor,

    I put ON_WM_CHAR and ON_WM_KEYDOWN in the messagemap of CMyListCtrl.
    But the corresponding function is never called!
    If I press the arrow keys, the focus (set with OnLButtonDown) changes to other controls. I can not get it back to my listctrl with the tab-key!

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

    Re: Change item height in CListBox / CListCtrl

    Quote Originally Posted by Ralf Schneider View Post
    I put ON_WM_CHAR and ON_WM_KEYDOWN in the messagemap of CMyListCtrl.
    What does CMyListCtrl have to do with your "own listbox" derived from CStatic?
    Besides, how did you put these macros: by hand or using ClassWizard?
    Victor Nijegorodov

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

    Re: Change item height in CListBox / CListCtrl

    BTW, did you set SS_NOTIFY style to your control? Static control wont respond to a WM_LBUTTONDOWN without this style.
    And by design it is not for processing keyboard input messages,
    Victor Nijegorodov

  11. #11
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    yes, I set the notify-property for the static-control in the dialog-editor.
    I think, this is the same as SS_NOTIFY?!
    Without this there was also no call to OnLButtonDown().

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

    Re: Change item height in CListBox / CListCtrl

    Have a look at the IsDialogMessage API or CWnd::IsDialogMessage. I never used it though, but maybe it could help you somehow...
    Victor Nijegorodov

  13. #13
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    Hello Victor,

    I am near to the solution.
    I think this problem has to do with the window-styles.
    For the listbox I used the picture control in the dialog editor.
    If I use the edit control, I can detect key strokes.

    Thank you for your hints.

  14. #14
    Join Date
    Jul 2001
    Posts
    306

    Re: Change item height in CListBox / CListCtrl

    Hello again,

    it has nothing to do with the styles.
    I can use WM_KEYDOWN to detect normal keys.

    How can I detect a keystroke on the cursor keys?
    is it not WM_KEYDOWN?

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

    Re: Change item height in CListBox / CListCtrl

    What "keystroke" can't you detect?
    Victor Nijegorodov

Page 1 of 2 12 LastLast

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