DialogResult.Cancel on Form.ShowDialog() when switching to Desktop
up vote
0
down vote
favorite
I am trying to show a UI (WinForms) via result = new Form().ShowDialog()
. The dialog pops up, works as expected but when i press Windows + D to tab away, the result
immediately returns DialogResult.Cancel
. Is there any way to keep the Form open when i am switching to desktop?
If there are any more questions or if it is unclear, please ask.
Best regards
c# winforms modal-dialog showdialog
add a comment |
up vote
0
down vote
favorite
I am trying to show a UI (WinForms) via result = new Form().ShowDialog()
. The dialog pops up, works as expected but when i press Windows + D to tab away, the result
immediately returns DialogResult.Cancel
. Is there any way to keep the Form open when i am switching to desktop?
If there are any more questions or if it is unclear, please ask.
Best regards
c# winforms modal-dialog showdialog
Do you have a keyboard accelerator which is usingD
in a Dialog's Button?
– Jimi
Nov 15 at 17:25
@Jimi No i don't, it is a basic Form with 2 buttons, one returningDialogResult.Cancel
and one returningDialogResult.OK
– Julian Peil
Nov 16 at 8:37
Well, since Win+D does not close any dialog, there's something that triggers the Cancel Button Click event (it could also be a System HotKey). Try setting theCancelButton
property of the Form to(none)
and set theDialogResult
in theButton.Click
event, with:this.DialogResult = DialogResult.Cancel;
. But keep it commented out, or set a BreakPoint there, and try again. Btw, you do know that an accelerator is defined by a letter prefixed by&
. Not necessarily set on the Button.
– Jimi
Nov 16 at 9:15
@Jimi i tried your suggestion out but it does not work for me. the breakpoint is hit when i click on the button, but is not hit when i tab to my desktop but theDialogResult
is still set somehow. I have looked at the HotKeys aswell, but could not find anything either. Guess it might not be possible then. Thank you for your help!
– Julian Peil
Nov 16 at 12:48
Since this happens, than it's possible :). If you have disabled the DialogResult related properties on the Form dialog (have you?), it's then triggered by the code the instanciate the Dialog. There's not enough code here to tell where/why.
– Jimi
Nov 16 at 13:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to show a UI (WinForms) via result = new Form().ShowDialog()
. The dialog pops up, works as expected but when i press Windows + D to tab away, the result
immediately returns DialogResult.Cancel
. Is there any way to keep the Form open when i am switching to desktop?
If there are any more questions or if it is unclear, please ask.
Best regards
c# winforms modal-dialog showdialog
I am trying to show a UI (WinForms) via result = new Form().ShowDialog()
. The dialog pops up, works as expected but when i press Windows + D to tab away, the result
immediately returns DialogResult.Cancel
. Is there any way to keep the Form open when i am switching to desktop?
If there are any more questions or if it is unclear, please ask.
Best regards
c# winforms modal-dialog showdialog
c# winforms modal-dialog showdialog
asked Nov 15 at 15:37
Julian Peil
657
657
Do you have a keyboard accelerator which is usingD
in a Dialog's Button?
– Jimi
Nov 15 at 17:25
@Jimi No i don't, it is a basic Form with 2 buttons, one returningDialogResult.Cancel
and one returningDialogResult.OK
– Julian Peil
Nov 16 at 8:37
Well, since Win+D does not close any dialog, there's something that triggers the Cancel Button Click event (it could also be a System HotKey). Try setting theCancelButton
property of the Form to(none)
and set theDialogResult
in theButton.Click
event, with:this.DialogResult = DialogResult.Cancel;
. But keep it commented out, or set a BreakPoint there, and try again. Btw, you do know that an accelerator is defined by a letter prefixed by&
. Not necessarily set on the Button.
– Jimi
Nov 16 at 9:15
@Jimi i tried your suggestion out but it does not work for me. the breakpoint is hit when i click on the button, but is not hit when i tab to my desktop but theDialogResult
is still set somehow. I have looked at the HotKeys aswell, but could not find anything either. Guess it might not be possible then. Thank you for your help!
– Julian Peil
Nov 16 at 12:48
Since this happens, than it's possible :). If you have disabled the DialogResult related properties on the Form dialog (have you?), it's then triggered by the code the instanciate the Dialog. There's not enough code here to tell where/why.
– Jimi
Nov 16 at 13:07
add a comment |
Do you have a keyboard accelerator which is usingD
in a Dialog's Button?
– Jimi
Nov 15 at 17:25
@Jimi No i don't, it is a basic Form with 2 buttons, one returningDialogResult.Cancel
and one returningDialogResult.OK
– Julian Peil
Nov 16 at 8:37
Well, since Win+D does not close any dialog, there's something that triggers the Cancel Button Click event (it could also be a System HotKey). Try setting theCancelButton
property of the Form to(none)
and set theDialogResult
in theButton.Click
event, with:this.DialogResult = DialogResult.Cancel;
. But keep it commented out, or set a BreakPoint there, and try again. Btw, you do know that an accelerator is defined by a letter prefixed by&
. Not necessarily set on the Button.
– Jimi
Nov 16 at 9:15
@Jimi i tried your suggestion out but it does not work for me. the breakpoint is hit when i click on the button, but is not hit when i tab to my desktop but theDialogResult
is still set somehow. I have looked at the HotKeys aswell, but could not find anything either. Guess it might not be possible then. Thank you for your help!
– Julian Peil
Nov 16 at 12:48
Since this happens, than it's possible :). If you have disabled the DialogResult related properties on the Form dialog (have you?), it's then triggered by the code the instanciate the Dialog. There's not enough code here to tell where/why.
– Jimi
Nov 16 at 13:07
Do you have a keyboard accelerator which is using
D
in a Dialog's Button?– Jimi
Nov 15 at 17:25
Do you have a keyboard accelerator which is using
D
in a Dialog's Button?– Jimi
Nov 15 at 17:25
@Jimi No i don't, it is a basic Form with 2 buttons, one returning
DialogResult.Cancel
and one returning DialogResult.OK
– Julian Peil
Nov 16 at 8:37
@Jimi No i don't, it is a basic Form with 2 buttons, one returning
DialogResult.Cancel
and one returning DialogResult.OK
– Julian Peil
Nov 16 at 8:37
Well, since Win+D does not close any dialog, there's something that triggers the Cancel Button Click event (it could also be a System HotKey). Try setting the
CancelButton
property of the Form to (none)
and set the DialogResult
in the Button.Click
event, with: this.DialogResult = DialogResult.Cancel;
. But keep it commented out, or set a BreakPoint there, and try again. Btw, you do know that an accelerator is defined by a letter prefixed by &
. Not necessarily set on the Button.– Jimi
Nov 16 at 9:15
Well, since Win+D does not close any dialog, there's something that triggers the Cancel Button Click event (it could also be a System HotKey). Try setting the
CancelButton
property of the Form to (none)
and set the DialogResult
in the Button.Click
event, with: this.DialogResult = DialogResult.Cancel;
. But keep it commented out, or set a BreakPoint there, and try again. Btw, you do know that an accelerator is defined by a letter prefixed by &
. Not necessarily set on the Button.– Jimi
Nov 16 at 9:15
@Jimi i tried your suggestion out but it does not work for me. the breakpoint is hit when i click on the button, but is not hit when i tab to my desktop but the
DialogResult
is still set somehow. I have looked at the HotKeys aswell, but could not find anything either. Guess it might not be possible then. Thank you for your help!– Julian Peil
Nov 16 at 12:48
@Jimi i tried your suggestion out but it does not work for me. the breakpoint is hit when i click on the button, but is not hit when i tab to my desktop but the
DialogResult
is still set somehow. I have looked at the HotKeys aswell, but could not find anything either. Guess it might not be possible then. Thank you for your help!– Julian Peil
Nov 16 at 12:48
Since this happens, than it's possible :). If you have disabled the DialogResult related properties on the Form dialog (have you?), it's then triggered by the code the instanciate the Dialog. There's not enough code here to tell where/why.
– Jimi
Nov 16 at 13:07
Since this happens, than it's possible :). If you have disabled the DialogResult related properties on the Form dialog (have you?), it's then triggered by the code the instanciate the Dialog. There's not enough code here to tell where/why.
– Jimi
Nov 16 at 13:07
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I have not come up with a solution for this exact problem. Therefore, to workaround, I used Form.Show()
instead of Form.ShowDialog()
and referenced the DialogResult property of the Form, rather than the return value of Form.ShowDialog()
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322901%2fdialogresult-cancel-on-form-showdialog-when-switching-to-desktop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I have not come up with a solution for this exact problem. Therefore, to workaround, I used Form.Show()
instead of Form.ShowDialog()
and referenced the DialogResult property of the Form, rather than the return value of Form.ShowDialog()
.
add a comment |
up vote
0
down vote
accepted
I have not come up with a solution for this exact problem. Therefore, to workaround, I used Form.Show()
instead of Form.ShowDialog()
and referenced the DialogResult property of the Form, rather than the return value of Form.ShowDialog()
.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I have not come up with a solution for this exact problem. Therefore, to workaround, I used Form.Show()
instead of Form.ShowDialog()
and referenced the DialogResult property of the Form, rather than the return value of Form.ShowDialog()
.
I have not come up with a solution for this exact problem. Therefore, to workaround, I used Form.Show()
instead of Form.ShowDialog()
and referenced the DialogResult property of the Form, rather than the return value of Form.ShowDialog()
.
answered Nov 19 at 18:24
Julian Peil
657
657
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322901%2fdialogresult-cancel-on-form-showdialog-when-switching-to-desktop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you have a keyboard accelerator which is using
D
in a Dialog's Button?– Jimi
Nov 15 at 17:25
@Jimi No i don't, it is a basic Form with 2 buttons, one returning
DialogResult.Cancel
and one returningDialogResult.OK
– Julian Peil
Nov 16 at 8:37
Well, since Win+D does not close any dialog, there's something that triggers the Cancel Button Click event (it could also be a System HotKey). Try setting the
CancelButton
property of the Form to(none)
and set theDialogResult
in theButton.Click
event, with:this.DialogResult = DialogResult.Cancel;
. But keep it commented out, or set a BreakPoint there, and try again. Btw, you do know that an accelerator is defined by a letter prefixed by&
. Not necessarily set on the Button.– Jimi
Nov 16 at 9:15
@Jimi i tried your suggestion out but it does not work for me. the breakpoint is hit when i click on the button, but is not hit when i tab to my desktop but the
DialogResult
is still set somehow. I have looked at the HotKeys aswell, but could not find anything either. Guess it might not be possible then. Thank you for your help!– Julian Peil
Nov 16 at 12:48
Since this happens, than it's possible :). If you have disabled the DialogResult related properties on the Form dialog (have you?), it's then triggered by the code the instanciate the Dialog. There's not enough code here to tell where/why.
– Jimi
Nov 16 at 13:07