Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 800
  • Last Modified:

Scrolling ListBox problem!

I have owner-draw ComboBox! I try to control scrolling with my code.
Window is scrolled normally, but WM_DRAWITEM message doesn't know that window was scrolled!!!!
How to "explain" to WM_DRAWITEM that windows was scrolled!!!! SetScrollPos
doesn't help!
I can't use SetTopIndex function, because only part of window is scrolled
(because of header)!

I have this code in my WM_VSCROLL message: (only for LINEDOWN)
****************************************
 CRect rect;

 switch(nSBCode)
 {
  case SB_LINEDOWN:
     GetClientRect(&rect);
     rect.top=rect.top+30;
     ScrollWindow(0,-15,rect,NULL);
     SetScrollPos(SB_VERT,nPos+1,TRUE);
     break;
  case SB_ENDSCROLL:
     break;
 }
****************************************

Thank you for your help!!!!

Simon

0
si124
Asked:
si124
  • 7
  • 3
  • 2
1 Solution
 
WynCommented:
Try call UpdateWindow() after ScrollWindow.
Also try check the DRAWITEMSTRUCT or WM_DRAWITEM.
Btw:not very clear with your problem.

Regards
W.Yinan
0
 
si124Author Commented:
Edited text of question.
0
 
si124Author Commented:
Edited text of question.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
si124Author Commented:
I have tried with UpdateWindow, but without success!!
What can I check in WM_DRAWITEM?

Thanks
0
 
WynCommented:

0
 
si124Author Commented:
In WM_DRAWITEM message
lpDrawItemStruct->rcItem and lpDrawItemStruct->itemData
are still connected like window woudn't be scrolled!
If I use scrolling by default everything works OK! How to fix this by manual scrolling?
0
 
si124Author Commented:
Adjusted points from 50 to 80
0
 
migelCommented:
Hi!
1 solution: call Defult() in the OnHScroll
2. manually add current scroll pos to the
pDrawItemStruct->rcItem while you handle WM_DRAWITEM message.

IMHO handling WM_VSCROLL msg in the ownerdraw wnd so unusial. What reason to do it?
0
 
si124Author Commented:
Reason is very simple.
I put a header control on the top of the listbox. So I have to scroll only part of Listbox, that header control is always on the top!
0
 
migelCommented:
hmm,
so you must manually ajust items rectangle (and index too) based on the current scroll position
0
 
si124Author Commented:
I know this solution. I thought that it could be a way to do this automatically!
0
 
migelCommented:
hm
you can not :-), since you grab scroll messages and do not path them to the default procedure you must work manually all related things :-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 7
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now