Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modify button style at run-time (BS_DEFPUSHBUTTON)
#1
Is there a way to modify a button's style at run-time, especially I wanted to modify a button in order to become the default button at run-time.
Thanks in advance
#2
SetWinStyle
#3
Dear Gintaras,

Thanks for a very prompt, as usually, reply.

Actually, I used :

SetWinStyle id(1, hDlg) BS_DEFPUSHBUTTON 1

but it didnot work.

Therefore I came to the following solution which it worked. I created two exactly similar entries, ie

1 Button 0x54030000 0x0 18 16 82 18 "Use O/S Scan S/W"
2 Button 0x54030001 0x0 18 16 82 18 "Use O/S Scan S/W"

one with the BS_DEFPUSHBUTTON set and another one unset, and I hide the appropriate button using, for examle

ShowWindow(id(1, hDlg) SW_HIDE)


I would appreciate it if you kindly comment.

Best regards
#4
In this case, changing style does not work or is difficult. Use DM_SETDEFID.

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

str controls = "5"
str lb5
lb5="3[]4"
if(!ShowDialog("Dialog59" &Dialog59 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032000 0x0 6 74 48 14 "Button 3"
;4 Button 0x54032000 0x0 58 74 48 14 "Button 4"
;5 ListBox 0x54230101 0x200 4 16 102 48 ""
;6 Static 0x54000000 0x0 4 2 100 12 "Set default button:"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case LBN_SELCHANGE<<16|5
,_i=LB_SelectedItem(lParam)
,sel _i
,,case 0
,,SendMessage hDlg DM_SETDEFID 3 0
,,case 1
,,SendMessage hDlg DM_SETDEFID 4 0
,
,case 3
,out 3
,
,case 4
,out 4
,
,case IDOK
,case IDCANCEL
ret 1
#5
Many thanks, it is perfect.


Forum Jump:


Users browsing this thread: 4 Guest(s)