Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with listbox
#1
Hi there,

I'm trying to make something with a listbox: you give information in a editbox, select the task in the listbox. The information in the editbox should be copied to the clipboard but the form is shutdown so nothing can be copied, and the macro should stay 'alive'

How to solve this?

TIA
#2
The dialog should stay alive, or close it and store the edit box text to the clipboard?
#3
Dialog should stay alive, info in editbox should be copied to clipboard but dialog is closed so nothing can be copied and error is: window not found
#4
You need to create smart dialog. Example:

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

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 222 134 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ListBox 0x54230101 0x200 6 6 96 48 ""
;4 Edit 0x54231044 0x200 106 6 96 48 ""
;5 Button 0x54032000 0x0 6 62 48 14 "Copy"
;END DIALOG
;DIALOG EDITOR: "" 0x2020001 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam) ;;*
,ret 1 ;;*
,case WM_DESTROY DT_DeleteData(hDlg) ;;*
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5 ;;Copy button clicked
,int i=LB_SelectedItem(id(3 hDlg))
,str s.getwintext(id(4 hDlg))
,s.setclip
,
,;debug
,str ss.from("item " i)
,mes s ss
,
,case IDOK
,DT_Ok hDlg ;;*
,case IDCANCEL DT_Cancel hDlg ;;*
ret 1

;* - not necessary in QM >= 2.1.9

Macro
Code:
Copy      Help
str controls = "3 4"
str lb3 e4

lb3="&A[]B[]C"

if(!ShowDialog("Dialog28" &Dialog28 &controls)) ret
#5
OK thx, this works. I have another question if i may

How can i jump to different actions is 'A' or 'B' is selected?

If you can help me with this you are this KING !

TIA
#6
After ,int i=LB_SelectedItem(id(3 hDlg)) , variable i contains listbox item index. You can use for example sel.

,sel i
,,case 0 ;;A
,,...
,,...
,,case 1 ;;B
,,...
,,...
,...
#7
Thank you, i figured it out myself in the minute you posted it but thx anyway your my KING for today!

Big Grin Big Grin Big Grin
#8
Is it possible to make helptexts for listboxitems? If yes how can i do this?
#9
Tooltips? Would be quite difficult. Better something like status bar.

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

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 221 133 "Form"
;3 ListBox 0x54230101 0x200 6 6 96 48 ""
;4 Edit 0x54231044 0x200 106 6 96 48 ""
;5 Button 0x54032000 0x0 6 62 48 14 "Copy"
;6 Static 0x54000000 0x0 4 82 198 30 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2020001 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam) ;;*
,PostMessage hDlg WM_COMMAND LBN_SELCHANGE<<16|3 id(3 hDlg)
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg) ;;*
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|3
,_i=LB_SelectedItem(lParam)
,str sh
,sel _i
,,case 0 sh="help text 0"
,,case 1 sh="help text 1"
,,case 2 sh="help text 2"
,sh.setwintext(id(6 hDlg))
,
,case 5 ;;Copy button clicked
,int i=LB_SelectedItem(id(3 hDlg))
,str s.getwintext(id(4 hDlg))
,s.setclip
,
,case IDOK
,DT_Ok hDlg ;;*
,case IDCANCEL DT_Cancel hDlg ;;*
ret 1

;* - not necessary in QM >= 2.1.9
#10
This adds tooltips to a list box, search qm forum for the attachment for the tooltip functions

Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4"
str lb3 e4
lb3 = "hey[]boo[]too[]joo"
if(!ShowDialog("Dialog2" &Dialog2 &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ListBox 0x54230101 0x200 4 42 96 48 ""
;4 Edit 0x54030080 0x200 4 26 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,class CToolTip m_htt
,CToolTip-- tt
,tt.Create(hDlg)
,tt.AddTool(hDlg 3 "Select One")
,case WM_DESTROY
,case WM_SETCURSOR tt.OnWmSetcursor(wParam lParam)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|3
,str t
,_i=LB_SelectedItem(lParam t)
,sel _i
,,case else tt.AddTool(hDlg 3 t)
,case IDOK
,case IDCANCEL
ret 1


now the problem i have is when using keyboard UP/DOWN inside the list box the tooltips wont update, unless i actually click on the list item, is there a way to do it when keyboard has focus on the list box using UP/DOWN keys.

Thanks.
#11
Tooltip text is updated but the tooltip is not displayed. To display tooltip immediately, use TTM_POPUP message. Mouse must be in the listbox. Also, TTM_POPUP is not available on win 2000.

Function Function53
Code:
Copy      Help
,case LBN_SELCHANGE<<16|3
,str t
,_i=LB_SelectedItem(lParam t)
,tt.AddTool(hDlg 3 t 2)
,SendMessage tt.m_htt TTM_POPUP 0 0
#12
thank you once again.
#13
freggel99 Wrote:Is it possible to make helptexts for listboxitems? If yes how can i do this?

Is this what you where asking for?

problem with listbox
#14
Hi Gintaras, I see how to do tooltips for a listbox from http://www.quickmacros.com/forum/showthr...p?tid=1352 but you have to select the item first. Is it possible to get tooltip for item just on hover-over without actually selecting the item?
Thanks,
Stuart
#15
Function dlg_listbox_hover_tooltips
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str lb3
lb3="one[]two[]three"
if(!ShowDialog("dlg_listbox_hover_tooltips" &dlg_listbox_hover_tooltips &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 ListBox 0x54230101 0x200 12 18 96 48 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "*" "" ""

ret
;messages
#compile __CToolTip
CToolTip-- t_tt
sel message
,case WM_INITDIALOG
,int-- t_tt_item=-1
,ARRAY(str)-- t_tt_text="one tooltip[]two tooltip[]three tooltip"
,t_tt.Create(hDlg)
,t_tt.AddTool(hDlg 3 "-")
,
,case WM_SETCURSOR
,if GetDlgCtrlID(wParam)=3
,,POINT p; xm p wParam 1
,,_i=SendMessage(wParam LB_ITEMFROMPOINT 0 MakeInt(p.x p.y))
,,if _i<t_tt_text.len and _i!=t_tt_item
,,,t_tt.AddTool(hDlg 3 t_tt_text[_i] 2)
,,,t_tt.OnWmSetcursor(wParam lParam)
,,t_tt_item=_i
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Will need CToolTip class: Tooltips. For QM < 2.3.4.
#16
Hey Gintaras, THis works fanatastic!!!
The listbox contents change but a global array variable keeps the tooltips updated. I also wanted the tooltips to come up for some types of text but not others so I placed this code in too:
Code:
Copy      Help
if findrx(ResultsWithSourceArray[0 _i] "from \[")=-1;
works great. THanks!!!

Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)