Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Merge the code for the two dialog functions
#3
It seems impossible to completely separate the same code

I put DlgProc in a separate function and there is a problem: the subfunction right_menu cannot output

Function C  
Code:
Copy      Help
str t="A"

str dd=
F
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "{t}_Dialog" "4"
;3 Edit 0x54030080 0x200 68 52 96 13 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &DlgProc &controls)) ret

Function DlgProc
Code:
Copy      Help
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetTimer hDlg 1 100 0 ;;Edit
,case WM_TIMER
,sel wParam
,,case 1 ;;Edit
,,int ec=id(3 hDlg); if(ec=0) ret
,,SetWindowSubclass(ec &sub.WndProc_Subclass_Edit 3 0)
,,KillTimer hDlg wParam
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

#sub WndProc_Subclass_Edit ;;Edit
function# hwnd message wParam lParam uIdSubclass dwRefData

;OutWinMsg message wParam lParam ;;uncomment to see received messages
sel message
,case WM_CONTEXTMENU
,sub.right_menu hwnd
,ret

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass_Edit uIdSubclass)
ret R

#sub right_menu v
function hwnd
str s=
;1 1    A test1
;2 2    A test2
;3 3    A test3

MenuPopup m.AddItems(s)
int i=m.Show
str s1 s2
if(i and m.GetItemText(i s1 s2))
,EditReplaceSel hwnd 0 s2 1|2|4


Messages In This Thread
RE: Merge the code for the two dialog functions - by Davider - 12-27-2022, 10:53 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)