a made window with LVS_NOSCROLL and my ListView headers just disappeared, it's it's it's just wrong :( What should i do :confused:
Posted on 2003-05-23 10:10:47 by AceEmbler
MS knowledge base
PRB: ListView with LVS_NOSCROLL Won't Display Header
Last reviewed: September 30, 1995
Article ID: Q137520
The information in this article applies to:
Microsoft Win32 Software Development Kit (SDK) versions 3.51, 4.0
Microsoft Win32s version 1.3

SYMPTOMS
In report view, the header control is not displayed for a ListView control created with the LVS_NOSCROLL style.

CAUSE
The ListView control positions the header control when the scrolling is updated. When the LVS_NOSCROLL style is specified, the control is never scrolled, so the header control is not positioned.

RESOLUTION
Call following function at the appropriate time to position the header control properly. To use the function, create the ListView without the LVS_NOSCROLL style, and then call this function whenever the ListView is created, resized, the view is changed, or the parent window receives the WM_SYSPARAMETERCHANGE message. Creating the control without the LVS_NOSCROLL style will ensure that the first item in the list won't be obscured by the header control. The function will automatically detect which view is currently set and act appropriately.
GetClientRect(hwndListView, &rc);

hdLayout.prc = &rc;
hdLayout.pwpos = &wpos;

Header_Layout(hwndHeader, &hdLayout);

SetWindowPos( hwndHeader,
wpos.hwndInsertAfter,
wpos.x,
wpos.y,
wpos.cx,
wpos.cy,
wpos.flags | SWP_SHOWWINDOW);

Sorry for the C++ but it was with the article
Posted on 2003-05-23 10:31:38 by donkey
K sorry for that lame post but my MSDN CD f***ed. Btw avoid burning CDs with that Roxio burning software with this special UDF format. I made that mistake and after instaling first one, CD-ROM refused to open. I had to open it manualy by pushing long object into this strange hole :tongue: . But CD was still working so it scratched my CD and it's not working any more. Btw i cracked another 2 CDs becouse i was in a need of this stuff. But after about a week i had to delete MSDN becouse of low space.
Posted on 2003-05-23 15:51:43 by AceEmbler
The post wasn't lame at all. I just happen to have run into the same problem and after a long search found this article. My first instinct isn't to search the KB either, usually I just post the problem too.;)
Posted on 2003-05-23 16:46:52 by donkey
I created ListView with 2 columns. But we can resize headers to obtain 3 columns. Who knows how to prevent this ?? (damn it only custom ListView is usefull as i see)
Posted on 2003-05-25 06:13:43 by AceEmbler
AceEmbler,

.if uMsg == WM_CREATE
" "
" "
;after you create your listview
; add this
invoke SendMessage,hListView, LVM_GETHEADER, 0, 0
mov hHeader,eax

; add this to WM_NOTIFY

.elseif uMsg==WM_NOTIFY
mov edi,lParam
assume edi:ptr NMHDR
mov eax,.hwndFrom

.if eax == hHeader ; may be ".elseif" if you have other stuff in wm_notify
return TRUE
.endif

.endif

this is the simpliest solution to it. There is anoher way, is to subclass your header
and use WM_LBUTTONDOWN || uMsg == WM_LBUTTONDBLCLK and return TRUE.

Regards,

Guy
Posted on 2003-05-25 07:23:36 by Guy
i will try it thx :)
Posted on 2003-05-25 10:04:45 by AceEmbler

AceEmbler,

.if uMsg == WM_CREATE
" "
" "
;after you create your listview
; add this
invoke SendMessage,hListView, LVM_GETHEADER, 0, 0
mov hHeader,eax

; add this to WM_NOTIFY

.elseif uMsg==WM_NOTIFY
mov edi,lParam
assume edi:ptr NMHDR
mov eax,.hwndFrom

.if eax == hHeader ; may be ".elseif" if you have other stuff in wm_notify
return TRUE
.endif


Regards,

Guy



It's not working
Posted on 2003-06-23 04:12:19 by AceEmbler
First off how can a user add a column to your listview ? If you're talking about resizing and an apparent 3rd column appears that's just because the two columns have been made too small to fit the list view. If that's the problem then process the HDN_ITEMCHANGING message and don't allow the total width of the header control to decrease to less than your listview width. You can just return TRUE to stop the size change if it gets too small.
Posted on 2003-06-23 04:39:51 by donkey
First off where did i use "add" word ??
Posted on 2003-06-23 08:23:08 by AceEmbler
That was not a flame AceEmbler, maybe badly worded but not meant the way you took it. I was asking how a user can get a third column. Obviously if he had two and then there were three there was one "added". Since the third one is empty space and you said it was a column I assumed that you meant there was a third column not 2 columns and some empty space.

"I created ListView with 2 columns. But we can resize headers to obtain 3 columns."
Posted on 2003-06-23 10:48:15 by donkey
Theoretically this "space" is a column since it has got a header (empty one :tongue:).
Posted on 2003-06-23 11:43:39 by AceEmbler
Oh welll, whatever. At any rate HDN_ITEMCHANGING is your answer.
Posted on 2003-06-23 11:48:58 by donkey
.ELSEIF uMsg == WM_NOTIFY

mov eax,lParam
mov eax,[eax].NMHDR.code
.IF eax == HDN_ITEMCHANGING
invoke SendMessage,hListView,LVM_GETHEADER,0,0
mov hHdr,eax
mov eax,lParam
mov edi,[eax].HD_NOTIFY.iItem
mov HDI.imask,HDI_WIDTH
invoke SendMessage,hHdr,HDM_GETITEM,edi,ADDR HDI
mov eax,HDI.lxy
mov OldSize,eax
.ELSEIF eax == HDN_ITEMCHANGED
invoke GetClientRect,hListView,ADDR rect
invoke SendMessage,hListView,LVM_GETHEADER,0,0
mov hHdr,eax
invoke SendMessage,hHdr,HDM_GETITEMCOUNT,0,0
mov ecx,eax
mov HDRSize,0
.REPEAT
push ecx
dec ecx
mov HDI.imask,HDI_WIDTH
invoke SendMessage,hHdr,HDM_GETITEM,ecx,ADDR HDI
mov eax,HDI.lxy
add HDRSize,eax
pop ecx
.UNTILCXZ
mov eax,rect.right
.IF eax > HDRSize
mov HDI.imask,HDI_WIDTH
mov eax,OldSize
mov HDI.lxy,eax
mov eax,lParam
mov edi,[eax].HD_NOTIFY.iItem
invoke SendMessage,hHdr,HDM_SETITEM,edi,ADDR HDI
.ENDIF
.ENDIF
You'll need to declare a few variables OldSize should be global. The following are the local declarations for DialogProc:
LOCAL hHdr		:DWORD

LOCAL HDI :HD_ITEM
LOCAL HDRSize :DWORD
LOCAL rect :RECT
Posted on 2003-06-23 18:31:33 by donkey