- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a dialog with three buttons -
Overwrite, Append & Cancel
Normally Overwrite is the default and is checked as being the default button.
For some applications I want the Append button to be the default.
I added iret=SetFocus(GetDlgItem(hWnd,IDC_APPEND))
Now the Overwrite button has a thicked border, the Append button has a dashed line around it but when I press Return Overwrite is activated.
I then tried adding a invisible default button IDC_RETURN but this does not help.
How can I change the default button?
Thanks,
David
Overwrite, Append & Cancel
Normally Overwrite is the default and is checked as being the default button.
For some applications I want the Append button to be the default.
I added iret=SetFocus(GetDlgItem(hWnd,IDC_APPEND))
Now the Overwrite button has a thicked border, the Append button has a dashed line around it but when I press Return Overwrite is activated.
I then tried adding a invisible default button IDC_RETURN but this does not help.
How can I change the default button?
Thanks,
David
integer*4 function OverwriteProc(hwnd, message, wParam, lParam)
!**********************************************************
!MS$ATTRIBUTES STDCALL, ALIAS : '_OverwriteProc@16' :: OverwriteProc
! for Overwrite Dialog
use dfwin
include 'resource.fd'
integer*4 hwnd, message, wParam, lParam
integer*4 iret,iCtrl,imess,idControl
logical*4 lret
! Unreferenced variables
lparam = lparam
select case (message)
case (WM_INITDIALOG)
OverwriteProc = 1
return
case (WM_SHOWWINDOW)
if (wParam) then
iret=SetFocus(GetDlgItem(hWnd,IDC_APPEND))
iret=ShowCursor(.TRUE.)
endif
OverwriteProc = 1
return
case (WM_COMMAND) ! message: received a command
iCtrl=LOWORD(wParam)
iMess=HIWORD(wParam)
OverwriteProc = 1
if (imess==EN_SETFOCUS) then
IDControl=iCtrl ! for Return
elseif (imess==EN_CHANGE) then
OverwriteProc = 0
IDControl=iCtrl ! for Return
return
end if
select case (iCtrl)
case (IDC_OVERWRITE)
lret=EndDialog(hWnd,2)
OverwriteProc = 1
case (IDC_APPEND)
lret=EndDialog(hWnd,1)
OverwriteProc = 1
case (IDCANCEL)
lret = EndDialog(hWnd, 0)
OverwriteProc = 1
case (IDC_RETURN) ! pressed Return
select case (IDControl)
case (IDC_OVERWRITE)
lret=SendMessage(hwnd,WM_NEXTDLGCTL,GetDlgItem(hWnd,IDC_OVERWRITE),.true.)
case (IDC_APPEND)
lret=SendMessage(hwnd,WM_NEXTDLGCTL,GetDlgItem(hWnd,IDC_APPEND),.true.)
case (IDCANCEL)
lret=SendMessage(hwnd,WM_NEXTDLGCTL,GetDlgItem(hWnd,IDCANCEL),.true.)
end select
end select
case default
OverwriteProc=0
end select
return
end function OverwriteProc
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add/remove BS_DEFPUSHBUTTON style using SetWindowLong(GWL_STYLE)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...the reason I put the question mark at the end of my last post was because I knew that SetWindowLong(GWL_STYLE) does not always work. See here for a possible workaround.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the suggestions.
BS_DEFPUSHBUTTON looked as if it might be what I wanted, but the documentation was in C and I wasn't sure where to make the call.
I ended up just replacing the SetFocus call in WM_SHOWWINDOW with a WM_NEXTDLGCTL call.
That mow seems to work.
Thanks,
David
BS_DEFPUSHBUTTON looked as if it might be what I wanted, but the documentation was in C and I wasn't sure where to make the call.
I ended up just replacing the SetFocus call in WM_SHOWWINDOW with a WM_NEXTDLGCTL call.
That mow seems to work.
Thanks,
David
integer*4 function OverwriteProc(hwnd, message, wParam, lParam)
!**********************************************************
!MS$ATTRIBUTES STDCALL, ALIAS : '_OverwriteProc@16' :: OverwriteProc
! for Overwrite Dialog
use dfwin
include 'resource.fd'
integer*4 hwnd, message, wParam, lParam
integer*4 iret,iCtrl
logical*4 lret
! Unreferenced variables
lparam = lparam
select case (message)
case (WM_INITDIALOG)
OverwriteProc = 1
return
case (WM_SHOWWINDOW)
if (wParam) then
lret=SendMessage(hwnd,WM_NEXTDLGCTL,GetDlgItem(hWnd,IDC_APPEND),.true.)
iret=ShowCursor(.TRUE.)
endif
OverwriteProc = 1
return
case (WM_COMMAND) ! message: received a command
iCtrl=LOWORD(wParam)
select case (iCtrl)
case (IDC_OVERWRITE)
lret=EndDialog(hWnd,2)
OverwriteProc = 1
case (IDC_APPEND)
lret=EndDialog(hWnd,1)
OverwriteProc = 1
case (IDCANCEL)
lret = EndDialog(hWnd, 0)
OverwriteProc = 1
end select
case default
OverwriteProc=0
end select
return
end function OverwriteProc
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page