Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dialog: how to change edit to static?
#1
Can I change the edit to static under some conditions in the same dialog?

for example, under some conditions, I want to "input" data in 4, and some conditions, I don't want to let it "input" any data.

Function SM_About
Code:
Copy      Help
str sm_dialog_definition=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 215 "About"
;2 Button 0x54030001 0x4 204 198 54 14 "Close"
;11 Edit 0x54030844 0x4 10 6 248 62 ""
;3 Edit 0x54030844 0x4 10 80 246 34 ""
;13 Edit 0x54030844 0x4 10 115 246 34 ""
;4 Edit 0x54030080 0x204 10 150 246 14 ""
#2
Function Dialog136
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "4"
str e4
if(!ShowDialog("Dialog136" &Dialog136 &controls)) ret

str sm_dialog_definition=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 215 "About"
;4 Edit 0x54030080 0x204 10 150 246 14 ""
;3 Button 0x54012003 0x0 10 134 48 10 "Readonly"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3 SendMessage id(4 hDlg) EM_SETREADONLY but(3 hDlg) 0
ret 1
#3
Thanks, Gintaras.
I modify the code as below:
Function Dialog136
Code:
Copy      Help
;messages2
sel wParam
,case 3 SendMessage id(4 hDlg) EM_SETREADONLY !but(3 hDlg) 0
ret 1

I thinks it should not input any thing for id 4 firstly, but I start the dialog, the id 4 can "input", but I check/un-check one time for id 3, the id 4 will not "input", did I need to modify the code?

BTW, can I directly get the code from "Dialog Editor"?
Function Dialog136
Code:
Copy      Help
SendMessage id(4 hDlg) EM_SETREADONLY !but(3 hDlg) 0
#4
In dialog editor select the Edit control, press Styles button, select ES_READONLY.
Dialog Editor does not create the SendMessage code.
#5
I write one simple example: I change the styles from BS_AUTOCHECKBOX to BS_AUTORADIOBUTTON and dialog code as below, if under condition i=0 and i=1 , one dialog can "input" and the other can not "input", they will reach my goal. Big Grin
But I use the same method to your "Shareware macros" for SM_about, it does not work.... Sad , I don't know the root cause...

Function Dialog2
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4"
str c3Che e4

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

str sm_dialog_definition=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 156 "Dialog"
;3 Button 0x54012009 0x0 34 34 48 10 "Check"
;4 Edit 0x54030080 0x200 34 54 96 14 ""
;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 IDCANCEL
,case 3
,int i=0
,if i=0
,,SendMessage id(4 hDlg) EM_SETREADONLY !but(3 hDlg) 0
,else
,,out "1"
,,SendMessage id(4 hDlg) EM_SETREADONLY but(3 hDlg) 0
ret 1

and

Function Dialog2
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4"
str c3Che e4

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

str sm_dialog_definition=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 156 "Dialog"
;3 Button 0x54012009 0x0 34 34 48 10 "Check"
;4 Edit 0x54030080 0x200 34 54 96 14 ""
;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 IDCANCEL
,case 3
,int i=1
,if i=0
,,SendMessage id(4 hDlg) EM_SETREADONLY !but(3 hDlg) 0
,else
,,out "1"
,,SendMessage id(4 hDlg) EM_SETREADONLY but(3 hDlg) 0
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)