Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to distinguish syslink?
#1
Hello. Big Grin
Always thank you for help.

I'd like to print out each message using syslink.

For example:
Google link clicking message output "google" and Bing link clicking message output "Bing"

How can separately output a message?

Function dlg_link_test
Code:
Copy      Help
\Dialog_Editor

function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_link_test" &dlg_link_test 0)) 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 Button 0x54032000 0x0 4 6 48 14 "Button"
;4 SysLink 0x54030000 0x0 66 6 130 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case 3 ;;button click
,_s.getfile("$desktop$\dlg.txt") ;; <a>Google</a> <a>Bing</a>
,_s.setwintext(id(4 hDlg))
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 4 ;;syslink control
,sel nh.code
,,case [NM_CLICK,NM_RETURN] ;;link click or Enter
,,;run "http://www.google.com"
#2
Function dlg_link_test
Code:
Copy      Help
\Dialog_Editor

function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_link_test" &dlg_link_test 0)) 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 Button 0x54032000 0x0 4 6 48 14 "Button"
;4 SysLink 0x54030000 0x0 66 6 130 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3 ;;button click
,,_s.getfile("$desktop$\dlg.txt") ;; <a>Google</a> <a>Bing</a>
,,_s.setwintext(id(4 hDlg))
,case 4 ;;link clicked. lParam is 0 for first link, 1 for second, and so on.
,,;out F"lParam = {lParam}"
,,sel lParam
,,,case 0: run "http://www.google.com"
,,,case 1: run "http://www.bing.com"
,case IDOK
,case IDCANCEL
ret 1
#3
If does not work, need a newer QM version. This dialog is created with QM 2.3.3 (0x2030300).
#4
Thank you for answer.
I'll turn the question.

For example:
out "%i %s" di.item.iItem di.item.pszText
%i -> 0 or 1 output but %s-> empty string
How clicking get link name?


Function dlg_link_test2
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;4 SysLink 0x54030000 0x0 32 12 96 13 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,_s.getfile("$desktop$\dlg.txt")
,_s.setwintext(id(4 hDlg))

,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3

ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 4 ;;syslink control
,NMLVDISPINFO* di=+nh
,sel nh.code
,,case [NM_CLICK,NM_RETURN] ;;link click or Enter
,,,out "lParam=%i TEXT=%s" di.item.iItem di.item.pszText
#5
Function dlg_link
Code:
Copy      Help
\Dialog_Editor

;SysLink control.
;The control shows text with links that can open web pages, files, or execute any other code.
;Link click notifications can be received in two ways:
;;;The easy way: In recent QM versions, if the link does not have id/href attributes, on click the dialog procedure receives WM_COMMAND message where wParam is link control id and lParam is 0-based index of the link in that control.
;;;The standard way: In any QM version, on click the dialog procedure receives WM_NOTIFY message with code NM_CLICK. It then can get link control id, link index and link attribute text. More info in MSDN Library.


str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;4 SysLink 0x54030000 0x0 32 12 96 20 "<a>Zero</a> <a>One</a>[]<a href=''two''>Two</a> <a href=''three''>Three</a>"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040304 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,;Link text can be set in dialog definition or with setwintext:
,;_s="<a href=''go''>Google</a> <a href=''bi''>Bing</a>"
,;_s.setwintext(id(4 hDlg))
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3

ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;link clicked
,out "link index=%i" lParam
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 4 ;;syslink control
,NMLINK* di=+nh
,sel nh.code
,,case [NM_CLICK,NM_RETURN] ;;link clicked
,,str url.ansi(&di.item.szUrl)
,,out "link index=%i, text=%s" di.item.iLink url


Forum Jump:


Users browsing this thread: 1 Guest(s)