News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Listbox problem

Started by FlySky, January 08, 2011, 05:46:10 PM

Previous topic - Next topic

FlySky

Hey guys,

Got this weird listbox problem.

Consider this WindowProc

WndProc Frame hWin, uMsg, wParam, lParam

   Cmp D[uMsg], WM_INITDIALOG
   Jne >
      Invoke GetDlgItem, [hWin], ID_LISTBOX_WINDOWS      ;Retrieve the handle to our listbox receiving windows
      Mov [ListBoxHandleWindows], Eax                      ;Store our listbox handle
      Invoke EnumWindows, Offset EnumWnd, NULL           ;Retrieve the active processes
   Invoke GetDlgItem, [hWin], ID_LISTBOX_SCANRESULT   ;Retrieve the handle to our listbox receiving scan result
   Mov [ListBoxHandleScanResult], Eax               ;Store listbox handle
:

      Cmp D[uMsg], WM_CLOSE
      Jne >
      Invoke ExitProcess, NULL

:

   Cmp D[uMsg], WM_COMMAND                       ;This message function checks if we pressed any buttons
   Jne > @end
   Cmp D[wParam], ID_SCAN_BUTTON                     ;Did we press the scan button?
   Jne > SelChanged

SelChanged:
   Mov Edx, [wParam]
   Shr Edx, 16
   Cmp Dx, LBN_SELCHANGE                  ;Did we change sells?
   Jne > StopSelChange
   Mov Eax, Edx          ---> THIS SPOT IS NEVER REACHED!! WEIRDO
   Jmp > @end
StopSelChange:
   Ret

@end:
   Xor Eax, Eax
   Ret

EndF

In the above code I have a simple dialogbox with an edit control and a listbox. When the DialogBox is created I am storing a handle to the listbox and add to the Listbox all current visible windows. Now I am trying to let the EditBox receive the string from the Listbox.
So when I change the Item in the listbox it would show the new item in the EditBox. The problem is it never detects if sells are changed. I stuck in the mov eax, edx just as a marker so I could set a breakpoint there. But it never breaks and EDX never reaches the value 1 after the shift right instruction. Is my listbox created wrong or what on earth could be the problem.
Thanks in advance.

wjr

Perhaps a problem without style and a solution with style... the LBN_SELCHANGE notification code is sent only by a list box that has the LBS_NOTIFY style.

dedndave

wow, Wayne - nice to see you visit us   :bg

FlySky

It looks like it's a problem with Easy Code. On Easy Code resource builder I can see that the Notify tab is set to TRUE. But when compiling and opening the compiled resource script in reshacker LBS_NOTIFY is not enabled. Looks I have to use a .BAT file to get this compiled correctly.

FlySky

Sorry for double post but I am not allowed to edit my earlier post.

The error was indeed LBS_NOTIFY. Somehow when using EasyCode IDE to create the dialogbox with the listbox and setting the listbox Notify attribute to TRUE it's not compiling with LBS_NOTIFY enabled.
I've done it manually by setting LBS_NOTIFY in the .rsrc file and than compiling using a build.bat and everything is working fine.