6 Replies - 2847 Views - Last Post: 17 November 2012 - 03:29 PM

#1 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

double click at listbox

Posted 15 November 2012 - 09:18 AM

hey all, today i got some problems with listbox control. i added some strings to it, and i want when the user dubble clicked at one of these strings, a messagebox is displayed.
i found some examples which are using WM_NOTIFY, but this not working for me because i never reach that message.
so i found a other one for WM_COMMAND, but this one also not work.

can somebody help me?

 .if uMsg == WM_COMMAND
	mov eax,wParam

	.elseif eax == IDC_LST
		shr  eax,16                  
			.if ax==LBN_DBLCLK
				invoke MessageBox, hWnd, Addr msg1, Addr msg1, MB_OK
			.endif
.endif


This post has been edited by Latias: 15 November 2012 - 09:19 AM


Is This A Good Question/Topic? 0
  • +

Replies To: double click at listbox

#2 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,282
  • Joined: 28-March 11

Re: double click at listbox

Posted 16 November 2012 - 08:44 PM

This works fine:
	.elseif uMsg == WM_COMMAND
		mov	edx, wParam
		movzx	eax, dx
		shr	edx, 16
		; edx will contain any notification messages sent 
		.if edx == LBN_DBLCLK
		    .if eax == IDC_LST  ; eax will contain the ID of control
	                 invoke  MessageBox, 0, 0, 0, 0
		    .endif
	    .endif

Was This Post Helpful? 1
  • +
  • -

#3 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: double click at listbox

Posted 17 November 2012 - 04:49 AM

for some reason it didnt work. actually im making a mp3 player, i want when the user clicks on a mp3 filename of the listbox, the mp3 will be played. this function doesnt work even when im using a messagebox when the user dubble clicked in the listbox.

maybe you can see what the error is in my project?

This post has been edited by Latias: 17 November 2012 - 10:42 AM

Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,282
  • Joined: 28-March 11

Re: double click at listbox

Posted 17 November 2012 - 09:32 AM

Without even looking at your code, I will take a guess at what is wrong.... If you aren't getting notification messages, then you don't have the listbox notify flag set.

All the docs for the LBN* codes state in the remarks:

Quote

This message is sent only by a list box that has the LBS_NOTIFY style.


Check and fix that, and let me know what happens. When something is not working, the first place to look is in the documentation :stuart:
Was This Post Helpful? 1
  • +
  • -

#5 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: double click at listbox

Posted 17 November 2012 - 10:45 AM

oooww yeah its working now! :whistling:/>

but i hope you can still take a look in my project because now i have to dubble click 2 times before a new mp3 will be played.
so i want when a user dubble click in the listbox the mp3 is played immediately, im sure you can help me with that master :)

http://rghost.net/41634435

This post has been edited by Latias: 17 November 2012 - 10:47 AM

Was This Post Helpful? 0
  • +
  • -

#6 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,282
  • Joined: 28-March 11

Re: double click at listbox

Posted 17 November 2012 - 02:48 PM

Code looks fine, maybe your not clicking fast enough? Problems with mouse maybe?

There is one change I would make, I would consolidate the checks for the control ID to one if/elseif block:
.elseif uMsg == WM_COMMAND
    mov     edx, wParam
    movzx   eax, dx
    .if eax == IDC_LST
        shr     edx, 16
        .if edx == LBN_DBLCLK
            invoke mciSendCommand,Mp3DeviceID,MCI_CLOSE,0,0
		    invoke SendDlgItemMessage,hWnd, IDC_LST, LB_GETCURSEL,0,0
		    invoke SendDlgItemMessage,hWnd, IDC_LST,LB_GETTEXT,eax, Addr FileName
		    invoke PlayMp3File, hWnd, ADDR FileName
        .endif
        
    .elseif  eax == IDC_Play
		.if PlayFlag == 0
			mov PlayFlag,1  
			invoke SendDlgItemMessage,hWnd, IDC_LST, LB_GETCURSEL,0,0
			invoke SendDlgItemMessage,hWnd, IDC_LST,LB_GETTEXT,eax, Addr FileName
			invoke PlayMp3File, hWnd, ADDR FileName
		.endif   
    
    .elseif eax == IDC_Stop
		invoke mciSendCommand,Mp3DeviceID,MCI_CLOSE,0,0
		mov PlayFlag,0
		
    .elseif eax == IDC_Exit
		invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
    .endif

Was This Post Helpful? 1
  • +
  • -

#7 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: double click at listbox

Posted 17 November 2012 - 03:29 PM

none mouse problems :P

your code works very well... compared your code with my and now i know why it ddidnt work. it was just i thought i had to add these lines
 .elseif uMsg == MM_MCINOTIFY
                        invoke mciSendCommand,Mp3DeviceID,MCI_CLOSE,0,0
                        mov PlayFlag,0


but without this it runs nice.
so thanks again master !
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1