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

si124Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
migelConnect With a Mentor Commented:
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
 
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
si124Author Commented:
Edited text of question.
0
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.