Listicon ITEMACTIVATE message

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Justin.

I'm trying to catch the LVN_ITEMACTIVATE notification using the windows callback, this message is sent in a WM_NOTIFY msg, the lparam of this msg is a pointer to a NMHDR structure, the code member is the notification message.

I can't think of a way to access the NMHDR structure through the pointer returned in the lparam of WM_NOTIFY, how it's done this in PB?

Here is the structure:
typedef struct tagNMHDR {
HWND hwndFrom;
UINT idFrom;
UINT code;
} NMHDR;

And a detailed explanation of the LVN_ITEMACTIVATE msg:
http://msdn.microsoft.com/library/defau ... Styles.asp
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

You can try it this way:

Code: Select all

*ptr.NMHDR = lparam
; now you can access the structure like this:
hwnd.l = *ptr\hwndFrom ; same method for other members in the structure
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Justin.

Thanks, that works fine with the LVN_ITEMACTIVATE msg, but it seems that is sent when double clicking on the item.

To catch the select event i had to do this:

#LVN_ITEMCHANGED=-101

Structure NMLISTVIEW
hdr.NMHDR
iItem.l
iSubItem.l
uNewState.l
uOldState.l
uChanged.l
ptAction.l
lParam.l
EndStructure

Procedure callback(hwnd,msg,wParam,lParam)
ret=#PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*ptr.NMLISTVIEW=lparam
If *ptr\hdr\code=#LVN_ITEMCHANGED
If *ptr\uNewState=3 : setwindowtext_(hwnd,"Selected: "+Str(*ptr\iItem)) : EndIf
ret=0
EndIf
EndSelect
ProcedureReturn ret
EndProcedure

hWnd=OpenWindow(0,10,10,300,200,#PB_Window_SystemMenu,"Selected:")
CreateGadgetList(hWnd)

ListIconGadget(1,10,10,280,180,"",100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
For x=1 To 10
AddGadgetItem(1,x,Str(x))
Next

SetWindowCallback(@callback())

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow

Note that i just guessed the uNewState value, i could not find any declared value of 3 in the LVIS_ constants, LVIS_SELECTED was 2. ¿?
Post Reply