Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Listbox with [ENTER] and images not working
#1
In the below code you see a dialog with 2 listboxes (left and right), the right listbox is the problem.
The problem is that the right listbox is not working when the lines are activated with below comment

 ;; <============= activate this and right listbox does not render correctly

The code in the below state works and displays the listboxes and images.
But as soon as you activate one or both lines of the code with the ;; <====== comment, the right listbox does not render correctly.
This dialog also needs to restarts itself when an item in the left listbox is double clicked (or [ENTER]), that's why I already added that code. I did this just be sure it does not hamper with the code that renders the listboxes.

I added the 3 images I used as attachment.

There might be a very large problem behind this that requires to much to code, I don't know.
But if this would take to long then just skip this. But if there is a workable solution I would really love to know.


Function playlist_test
Code:
Copy      Help
;g1
;; below image resolutions: 64x64
str- imgs=
;F:\portableapps\quickmacrosportable_shared_items\_ICONS\test_image_0.png
;F:\portableapps\quickmacrosportable_shared_items\_ICONS\test_image_1.png
;F:\portableapps\quickmacrosportable_shared_items\_ICONS\test_image_2.png


str dd=
F
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 473 145 ""
;6 ListBox 0x54230151 0x200 3 2 194 131 ""
;8 ListBox 0x54230151 0x200 202 1 239 135 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

str controls = "6 8"
str lb6 lb8

lb6="list 1[]list 2[]list 3"
lb8="song 1[]song 2[]song 3"

int r=ShowDialog(dd &sub.DlgProc &controls)
if(r=3)
,goto g1
if(!r) ret

#sub DlgProc
function# hDlg message wParam lParam

ARRAY(int)-- t_act t_acb t_afont
if(DT_LbCbOwnerDraw(hDlg message wParam lParam 6 1 t_act t_acb 0xffff 0x1 t_afont)) ret 1
;if(DT_LbCbOwnerDraw(hDlg message wParam lParam 8 1 t_act t_acb 0xffff 0x1 t_afont)) ret 1  ;; <============= activate this and right listbox does not render correctly

str- imgs
CB_DrawImages hDlg message wParam lParam 8 imgs 1|16 64 64 DT_WORDBREAK

sel message
,case WM_INITDIALOG
,,;; Font style for both listboxes
,,__Font-- t_f1.Create("Tahoma" 12 1)
,,int v
,,for v 0 3
,,,t_afont[]=t_f1

,,;; Make sure [ENTER] can be used in listbox
,,SetWindowSubclass(id(6 hDlg) &sub.WndProc_Subclass_lbleft_enter 1 0)
,,;SetWindowSubclass(id(8 hDlg) &sub.WndProc_Subclass_lbright_enter 1 0) ;; <============= activate this and right listbox does not render correctly
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL

,;; In a later (final) version of this dialog needs to restart and reload the right listbox contents
,;; It's done when user double clicks (or [ENTER]) on left listbox. I already implented this so any conflicts
,;; regarding restarting dialog and rendering listboxes could be handled early on.
,case LBN_DBLCLK<<16|6
,,_i=LB_SelectedItem(lParam)
,,DT_Ok hDlg 3
,
ret 1

#sub WndProc_Subclass_lbright_enter ;;menu File -> New -> Templates -> Wndproc -> WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

sel message    
,case WM_GETDLGCODE
,sel(wParam)
,,case [VK_SPACE] ret 0
,,case [VK_RETURN] ret DLGC_WANTALLKEYS ;;please send me WM_KEYDOWN instead of closing the dialog
,
,case WM_KEYDOWN
,sel(wParam) case [VK_RETURN,VK_SPACE] SendMessage GetParent(hwnd) WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(hwnd) hwnd; ret ;;to use the same code as for double-click
,;sel(wParam) case [VK_RETURN,VK_SPACE] SendMessage GetParent(hwnd) WM_COMMAND LBN_SELCHANGE<<16|GetDlgCtrlID(hwnd) hwnd; ret ;;to use the same code as for double-click

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass_lbright_enter uIdSubclass)
,
#sub WndProc_Subclass_lbleft_enter ;;menu File -> New -> Templates -> Wndproc -> WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

sel message
,case WM_GETDLGCODE
,sel(wParam)
,,case [VK_SPACE] ret 0
,,case [VK_RETURN] ret DLGC_WANTALLKEYS ;;please send me WM_KEYDOWN instead of closing the dialog
,
,case WM_KEYDOWN
,sel(wParam) case [VK_RETURN,VK_SPACE] SendMessage GetParent(hwnd) WM_COMMAND LBN_DBLCLK<<16|GetDlgCtrlID(hwnd) hwnd; ret ;;to use the same code as for double-click
,;sel(wParam) case [VK_RETURN,VK_SPACE] SendMessage GetParent(hwnd) WM_COMMAND LBN_SELCHANGE<<16|GetDlgCtrlID(hwnd) hwnd; ret ;;to use the same code as for double-click

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass_lbleft_enter uIdSubclass)

ret R


Attached Files Image(s)
           


Messages In This Thread
Listbox with [ENTER] and images not working - by r0n - 12-23-2018, 11:16 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)