Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog ListBox change
#1
Hey there peeps,
I'm trying to do something that is kinda simple but I don't know how to do it.
I want to, depending on what I have selected on my list box, change the information on the fields on the right.

The fields on the right will be filled with information from an excel file, but for now they're just with text for test porpuses.

This is my code:

Function Dialog3
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "1 8 10 12 15 17 20"
str lb1 e8Ped e10 e12 e15 e17 e20wor

lb1="SITE01[]SITE02[]SITE03[]SITE04[]SITE05[]SITE06[]SITE07[]SITE08"

if(!ShowDialog("Dialog3" &Dialog3 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 307 286 "CAs Alarmados"
;1 ListBox 0x54230101 0x200 8 44 96 200 ""
;3 Static 0x54000000 0x0 30 28 40 13 "Sites"
;4 Static 0x54000000 0x0 85 0 500 40 "    Lista de sites []alarmados com CA"
;5 Button 0x54032000 0x0 10 248 48 14 "Add site"
;6 Button 0x54032000 0x0 10 266 48 14 "Delete site"
;7 Static 0x54000000 0x0 160 54 100 13 "Adicionado por:"
;8 Static 0x54800000 0x20000 154 68 96 14 "Pedro"
;9 Static 0x54000000 0x0 160 94 100 10 "Adicionado às:"
;10 Static 0x54800000 0x20000 154 108 96 14 "15:33:02"
;11 Static 0x54000000 0x0 120 192 60 10 "Hora de fim"
;12 Static 0x54800000 0x20000 112 206 80 12 "02:03:49"
;13 Static 0x54000000 0x0 216 220 48 13 "Regional"
;14 Button 0x54032000 0x0 62 248 40 32 "Activar Reminder"
;15 Static 0x54800000 0x20000 216 236 50 13 "TNO"
;16 Static 0x54000000 0x0 184 130 48 15 "C.A."
;17 Static 0x54800000 0x20000 112 168 80 12 "0112359966"
;18 Static 0x54000000 0x0 115 154 80 12 "Número da C.A."
;19 Static 0x54000000 0x0 208 174 90 12 "Tempo restante"
;20 Static 0x54800000 0x20000 206 190 90 12 "(work in progress...)"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""



/*boxes de edit: 8 10  12 15 17 20*/

ret
;messages
sel message
,case WM_INITDIALOG

/---Fontes e cores dos items---
,__Font-- f1.Create("Arial" 18 1) f2.Create("Arial" 15 1) f3.Create("Arial" 10 1) f4.Create("Arial" 12 1)
,f1.SetDialogFont(hDlg "4")
,f2.SetDialogFont(hDlg "3 16")
,f3.SetDialogFont(hDlg "8 10")
,f4.SetDialogFont(hDlg "7 9 11 13 18 19")
,DT_SetTextColor(hDlg 0x990099 "4")
,DT_SetTextColor(hDlg 0x0099FF "3 16")
,DT_SetTextColor(hDlg 0x000000 "8 10")
,DT_SetTextColor(hDlg 0x00CCCC "7 9 11 13 18 19")


,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Thank you very much one more time!
#2
In dialog editor select the listbox, click Events, LBN_SELCHANGE. It inserts some code, where you can write more code.
Example: Multiple listboxes with different actions.
#3
I already read the example you gave me, but didn't help a lot because what I'm trying to do is a little different.
I'll try to go from here and I'll ask away some questions whenever I have doubts along the way.

Thanks!
#4
Isn't this supposed to give me the selection name on the list?

Function Dialog3
Code:
Copy      Help
,case LBN_SELCHANGE<<16|1
,_i=LB_SelectedItem(lParam)
,_s=LB_GETCURSEL
,out _s

I also tried:

LB_GETITEMDATA ; LB_GETSELITEMS ; LB_GETTEXT ; LB_GETITEMDATA

It always return a number, and the thing is, the number is always the same, it changes with the function but not with the item index on the list Cry
Any help would be appreciated. Thanks!! Smile
#5
Look for functions in the edit box above the code editor. For example, type get listbox item text and press Enter.
#6
Many thanks! Smile
#7
I was able to do the whole app no problem, thanks again.

Just have a little question: Is there a way to make the edit fields have a minimum required number of characters?

Thanks again
#8
Function Dialog135
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str e3
if(!ShowDialog("Dialog135" &Dialog135 &controls)) ret
out e3

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 Edit 0x54030080 0x200 84 10 96 14 ""
;4 Static 0x54000000 0x0 2 12 80 10 "Minimum 4 characters"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,str s
,s.getwintext(id(3 hDlg))
,if s.len<4
,,mes "Minimum 4 characters"
,,ret 0 ;;return 0 to not close dialog on OK
,case IDCANCEL
ret 1
#9
Cool !
Gracias


Forum Jump:


Users browsing this thread: 1 Guest(s)