| 
		
	
	
	
		
	Posts: 57Threads: 17
 Joined: Dec 2008
 
	
	
		ok how do i save my listbox info so that when i reopen the dialog the info is saved it i want it to be?
	 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		can use rset to save listbox contents in registry 
and rget to get from registry
 
This is similar but with combo box. Should work with listbox if you replace everything that begin with CB_ to LB_. 
Function dlg_combobox_and_registry \Dialog_Editorfunction# hDlg message wParam lParam
 if(hDlg) goto messages
 
 ;Dialog with a combo box. You can add/remove items. Saves all in the registry.
 
 str controls = "3"
 str cb3
 rget cb3 "cb" "\test\test"
 if(!ShowDialog("dlg_combobox_and_registry" &dlg_combobox_and_registry &controls)) ret
 
 ;BEGIN DIALOG
 ;0 "" 0x90C80A44 0x100 0 0 223 135 "Name List"
 ;1 Button 0x54030001 0x4 2 110 48 14 "OK"
 ;2 Button 0x54030000 0x4 60 110 48 14 "Cancel"
 ;3 ComboBox 0x54230641 0x0 6 16 96 56 ""
 ;5 Button 0x54032000 0x0 104 16 18 14 "+"
 ;6 Button 0x54032000 0x0 104 32 18 14 "-"
 ;4 Button 0x54020007 0x0 2 2 126 96 "Employee Names "
 ;END DIALOG
 ;DIALOG EDITOR: "" 0x2030001 "" "" ""
 
 ret
 ;messages
 sel message
 ,case WM_INITDIALOG
 ,case WM_COMMAND goto messages2
 ret
 ;messages2
 sel wParam
 ,case 5 ;;+
 ,str s.getwintext(id(3 hDlg))
 ,s.trim; if(!s.len) ret
 ,CB_Add id(3 hDlg) s
 ,;SendMessage id(3 hDlg) CB_ADDSTRING 0 s ;;use this instead of the above line if CB_Add is unavailable
 ,
 ,case 6 ;;-
 ,int i=CB_SelectedItem(id(3 hDlg))
 ,if(i<0) ret
 ,SendMessage id(3 hDlg) CB_DELETESTRING i 0
 ,
 ,case IDOK
 ,int j h=id(3 hDlg); str s1 s2
 ,for j 0 CB_GetCount(h)
 ,,CB_GetItemText h j s1
 ,,s2.addline(s1)
 ,rset s2 "cb" "\test\test"
 ,
 ,case IDCANCEL
 ret 1
 
	
	
	
		
	Posts: 57Threads: 17
 Joined: Dec 2008
 
	
	
		Ok tyvm bro that solves my problem, but i cant get it to work with my dialog? but it works with yours? could you take a look at mine? and see why? \Dialog_Editorfunction# hDlg message wParam lParam
 if(hDlg) goto messages
 lpstr PROTECTION=
 ;BEGIN DIALOG
 ;0 "" 0x90CA0A44 0x100 0 0 126 121 "Employee List"
 ;3 ComboBox 0x54230641 0x0 10 14 104 58 ""
 ;6 Button 0x54032000 0x0 64 78 48 14 "Delete"
 ;7 Button 0x54032000 0x0 12 78 48 14 "Add"
 ;5 Button 0x54032000 0x0 12 96 48 14 "Save"
 ;9 Button 0x54032000 0x0 64 96 48 14 "Clear"
 ;4 Button 0x54020007 0x0 4 2 116 114 "List"
 ;END DIALOG
 ;DIALOG EDITOR: "" 0x2030001 "" "" ""
 str controls = "3"
 str cb3
 rget cb3 "cb" "\test\test"
 if(!ShowDialog(PROTECTION &MAIN_DIALOG 0 0 0 0 0 0 0 0)) ret
 
 ret
 ;messages
 sel message
 ,case WM_INITDIALOG
 
 / OPEN DIALOG IN LAST POSTION
 ,RegWinPos hDlg _s.getmacro(getopt(itemid) 1) "\mydialogpos" 0
 
 / CREATE MENU INSIDE DIALOG
 ,int hmenu
 ,hmenu=DT_CreateMenu("MAIN_DIALOG")
 ,DT_SetMenu hDlg hmenu
 
 / CREATE AND ASSIGN TOOLTIPS
 ,class CToolTip m_htt
 ,CToolTip-- tt
 ,tt.Create(hDlg)
 ,tt.AddTool(hDlg 5 "Save The Info In The Account List.")
 ,tt.AddTool(hDlg 6 "Delete An Account From The Account List.")
 ,tt.AddTool(hDlg 7 "Add An Account To Account List.")
 ,tt.AddTool(hDlg 9 "Clear The Entire Account List.")
 
 / SET CURSOR FOR TOOLTIPS
 ,case WM_SETCURSOR
 ,,tt.OnWmSetcursor(wParam lParam)
 
 ,case WM_DESTROY
 
 / SAVE DIALOGS LAST POSITION
 ,RegWinPos hDlg _s.getmacro(getopt(itemid) 1) "\mydialogpos" 1
 
 ,case WM_COMMAND goto messages2
 ret
 ;messages2
 sel wParam
 
 / MENU MACRO CASES
 ,case 100 out "Macro 1"
 ,case 101 out "Macro 2"
 
 ;/ SAVE LISTBOX INFORMATION
 ,case 5
 ,int j h=id(3 hDlg); str s1 s2
 ,for j 0 CB_GetCount(h)
 ,,CB_GetItemText h j s1
 ,,s2.addline(s1)
 ,rset s2 "cb" "\test\test"
 
 / DELETE ACCOUNT FROM LISTBOX
 ,case 6
 ,int Del=CB_SelectedItem(id(3 hDlg))
 ,if(Del<0) ret
 ,SendMessage id(3 hDlg) CB_DELETESTRING Del 0
 ,str ClearEditInListBox = ""; ClearEditInListBox.setwintext(id(1001 hDlg))
 
 / ADD ACCOUNT TO LISTBOX
 ,case 7
 ,str Add.getwintext(id(3 hDlg))
 ,Add.trim; if(!Add.len) ret
 ,SendMessage id(3 hDlg) CB_ADDSTRING 0 Add
 
 / CLEAR ALL INFO IN LISTBOX
 ,case 9
 ,SendMessage id(3 hDlg) CB_RESETCONTENT 0 0
 
 ,case IDOK
 ,case IDCANCEL
 ret 1
 
 ;BEGIN MENU
 ;>&File
 ,;Macro 1 : 100 0 0
 ;<
 ;>&Setup : 104 0 0
 ,;Macro 2 : 101 0 0
 ;<
 ;END MENU
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		rset will create "\test\test" key if it does not exist. Actually it is "software\gindi\qm2\user\test\test" in HKEY_CURRENT_USER. You can use some other key.
	 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		if(!ShowDialog(PROTECTION &MAIN_DIALOG &controls 0 0 0 0 0 0 0)) ret
	 
	
	
	
		
	Posts: 57Threads: 17
 Joined: Dec 2008
 
	
	
		Ok Tyvm for the help again bro. i owe ya
	 |