Windows yes no dialog

Windows yes no dialog

In one of the applications I’m developing, I needed to display a simple Yes, No, Cancel message dialog. Something like this:

In a Universal App, the MessageDialog class is used to display an alert dialog with a set of choices for the user to make. According to the documentation, this class supports up to three commands.

Here is how one could come up with the dialog shown above with the following code:

This all works fine… except on an actual Windows Phone device!

In fact, this code crashes on a phone for no apparent reason. I have debugged and could not find a good reason why this code failed. However, I found out that if I only keep two commands for the dialog, the code works all right.

So, my conclusion is that the MessageDialog class only supports two commands on a Windows Phone device, as opposed to a Desktop or a Tablet.

Thinking about it, it makes sense to use the physical hardware back button on a Windows Phone to simulate Cancel. After all, that would be the most natural choice. So I decided to implement this with the modified code below:

The code first builds the dialog box normally, adding commands. Each time a new command is added, it sets the CancelCommandIndex property to the last one. For a Yes, No dialog, the default Cancel behavior would result in the No command being triggered.

When both a Yes and a Cancel command are present, the code needs to make a choice. If no hardware button is present – for instance, like on a Desktop – the code proceeds normally. In order to detect a feature, the code uses the ApiInformation.IsTypePresent method with “Windows.Phone.UI.Input.HardwareButtons”, which, as its name suggests, returns whether the device has physical hardware buttons.

If a physical hardware back button is present, however, the code does not add the Cancel command. Instead, it sets the CancelCommandIndex property to (uint) -1. This invalid number will make the MessageDialog.ShowAsync() method return null in that case.

After the MessageDialog.ShowAsync() method returns, the code checks to see whether the Cancel command was choosen. Since this command was not actually handled by the MessageDialog class itself, the code invokes it directly for consistency purposes.

Then it proceeds normally to handle the appropriate branch depending upon the user choice.

This code works fine and allows me to build a single App for Desktop and Mobile with the same behavior. However, this code does not produce the absolutely correct behavior when the App is used on a phone but displayed on an external display, such as when taking advantage of the Continuum feature. In that case, I would like the three buttons to be displayed on the dialog box. However, I did not find a solution for this small problem.

Please, let me know in the comments if you know or find out how to achieve this.

Yes/No Dialog on every page the printer will print

I’m doing this in a printer server. I am trying to make a program that will show up a Yes/No dialog box before proceeding to print a page printed by any application or from the network.

So far, it was easy to pause and resume a job. But haven’t found a solution to pause and resume a page to be printed.

I am using Windows 10 64bit. Any language will do.

1 Answer 1

I’m prepared to be proven wrong, but I don’t believe this is trivially possible. The print spooler doesn’t have a notion of where pages begin and end in a spooled print session.

Читайте также:  Installing gtk in linux

The location of each page is language dependent, and the print spooler can hardly be expected to parse the stream to find the start and end of each page, it would be very slow for one thing.

The alternative would be for the print processor to note the beginning and end of each page and the offset of the spool file at that moment, and then pass that information separately to the spooler.

But there are problems with that too. the ‘RAW print’ capability allows the printing application to inject ‘stuff’ straight into the print stream, bypassing the print processor altogether. This is common with page layout applications when printing to a PostScript printer for example, particularly on Windows as supporting CMYK isn’t really possible when printing on Windows, and spot colours are even harder.

The injected code can contain any number of pages and the print spooler has no way to know where each page is.

So in the general case, I don’t think this is possible, at least not in the print spooler.

How to Create a DialogBox to prompt the user for Yes/No option in WPF

I know how to do this on Windows Form App, but I couldn’t find anyway of doing so on a WPF App. How would I present the user a blocking DialogBox with Yes/No option and get/process the response from the user?

2 Answers 2

Please note that while Radu’s answer works, you cannot apply WPF styles to the MessageBox.

I took a different approach to this problem.

I created a class to serve as a View Model for my message window and I created a style for how I wanted my window to appear. Later in code I instantiated a new Window, set it’s DataContext to an instance of my View Model, and set the Window’s Style property to the style I created for the window.

I know it sounds a bit overkill, and I’m not sure how other people go about solving this same issue. but my solution is quite flexible and I’m starting to really like it.

For example, here is Dialog View Model:

Here is my style for a basic «message» window:

My CustomDialogWindow is simply a window with nothing in it:

And in the CustomDialogWindow I have the following code so that the window closes when the user clicks cancel or ok:

Now when I need to use the window I just instantiate a new CustomDialogWindow, set it’s DataContext to a new instance of the DialogViewModel class, and set it’s style to the «myMessageStyle»:

The reason why I like this approach is because I inherit from the MyDialogViewModel and provide more properties so that, for instance, I can display a bunch of options for the user to choose from. I just supply custom styles for each type of window I want to display (making sure to bind the appropriate properties). Like I said, it’s very flexible and pretty simple to implement.

Should yes/no dialogs also have a cancel?

I remember once reading an article that said whenever you present a messagebox with a Yes/No choice, you should always also provide a Cancel button, even if it does the same as No .

The rationale was that if the users know that Cancel is always the «safe» button to click if they don’t understand why the message box was displayed, or are confused by the question.

I’ve followed this advice for years (even though I can no longer remember where I originally heard it), but a number of people have complained about it, saying that they would prefer a simple Yes/No .

So now I am wondering whether it is (or ever was) in fact best practice. If a message box presents a Yes/No choice, should it also offer Cancel (in the case where Cancel and No have the same effect)?

6 Answers 6

No, I don’t think you should. Instead, you think re-think the whole idea. First of all: do you really, really need a popup dialog with a question like this? Wouldn’t an easy to use, reliable Undo option be infinitely better? In that case, you can circumvent the whole Yes/No confirmation, and avoid context switches and generally getting into the users way.

Читайте также:  How to open jar files linux

Actions on dialog buttons

And if you really need a dialog box here: instead of putting Yes and No on your buttons in there, why not put the actual action on the buttons? You can do that by rephrasing the text in the dialog (which I hope you phrased so horribly on purpose here), and then name the Yes button «Invert» and the «No» button «Cancel» instead.

In general, I think it is wrong to have two differently named actions in a UI that do the same thing. That leaves users confused as to what are their differences. After all, if there is a Cancel button, it must do something else than No, right? So what exactly is that difference? You know the answer is «none», but does your user?

I think it depends on the context in which the dialog pops up.

Context 1: A standalone/independent action is performed («Add item to favorites?»). In this case the yes/no -only options should be fine. It is a ‘safe’ situation, so there is no need for a ‘cancel’.

Context 2: The action is part of a process, or will kick-start a process (imagine this to be a ‘dangerous’ situation, depending on your definition of safe/dangerous). Let’s imagine the user is working on a text document, and closes the application without saving first. There may be many documents open at the same time, and the «process» involves looping through the open documents, and asking the user «Do you wish to save your changes to xxx.doc?». Let’s consider the options:

Scenario 1: [Yes / No / Cancel]

  • «Yes» saves changes, and (eventually) closes the app.
  • «No» doesn’t save changes and (eventually) closes the app.
  • «Cancel» doesn’t save changes (it does the same as ‘No’ in terms of the original dialog question), but doesn’t close the app. The process/loop ends immediately, and all the documents remain available for editing (app reacts as if the user didn’t try to close it).

Scenario 2: [Yes / No]

  • «Yes» saves changes, and (eventually) closes the app.
  • «No» doesn’t save changes and (eventually) closes the app.

The only difference came with the assumption that the app makes on what the user actually wants to achieve by closing the app (either clicking the close ‘x’ button, or pressing some short-cut key). Specifically, do the designers anticipate that users may close the app by accident (in general: will someone kick-off a difficult/impossible-to-reverse process, or find themselves in a ‘dangerous’ situation, and if so, should we allow them to get out of it / stop it somehow?) In this case, I think erring on the side of caution is better (include the ‘cancel’ button, even though it achieves the same effect as the ‘no’ when considering the wording of the dialog message).

As always (irrespective of «situation») I think the wording of the dialog message is the most important.

Fix Yes button disabled in UAC dialogs in Windows 10, Windows 8 and Windows 7

If you ever faced this strange issue in Windows where the Yes button is disabled in UAC dialogs, you might be very confused as to why that is, especially when your user account is already an Administrator level account. In this article, we will see how this problem can be fixed.
The issue can affect Windows 10, Windows 8.1, Windows 8 and Windows 7. If you are facing this problem in your Windows operating system, try the following steps:

This will allow you to operate your computer as Administrator.

    Now, type the following command:

This set the Administrator account’s password to the «password» word. You can use any other password of choice.

Читайте также:  Установка винды рядом с линуксом
  • Reboot and sign in as Administrator.
  • While you are signed in with the Administrator account, type the following command in an elevated command prompt:

    This will add your user account into the local «Adminstrators» group.

  • Restart the operating system and sign in with your regular credentials, assuming it is same account you specified above.
  • That’s it. This should resolve the issue and the button «Yes» in the UAC dialog should become accessible. It will no longer be greyed out.

    Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

    Share this post

    About Sergey Tkachenko

    Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

    15 thoughts on “ Fix Yes button disabled in UAC dialogs in Windows 10, Windows 8 and Windows 7 ”

    It worked like a charm! Thanks! 🙂

    you are welcome

    So I rebooted and tried to sign in as administrator, but it asked for a password??

    Have you set a password for your Administrator account?

    Thanks for getting back so quickly! No, I don’t think so. I have a password for my Microsoft Account, but that doesn’t work for the Administrator Account. Today I tried to get back into the Administrator Account using the Command Prompt, but was unsuccessful.:
    Microsoft Windows [Version 10.0.10586]
    (c) 2015 Microsoft Corporation. All rights reserved.
    C:\Users\dmcea>net user administrator password
    System error 5 has occurred.
    Access is denied.

    Yesterday here’s what I did:
    C:\Users\dmcea>net user administrator
    User name Administrator
    Full Name
    Comment Built-in account for administering the computer/domain
    User’s comment
    Country/region code 000 (System Default)
    Account active Yes
    Account expires Never
    Password last set 03/05/16 2:52:49 PM
    Password expires Never
    Password changeable 03/05/16 2:52:49 PM
    Password required Yes
    User may change password Yes
    Workstations allowed All
    Logon script
    User profile
    Home directory
    Last logon 07/22/15 3:40:49 AM
    Logon hours allowed All
    Local Group Memberships *Administrators
    Global Group memberships *None
    The command completed successfully.

    Try “password”
    I also didn’t set any password for administrator. But i tried and it opened.

    Really? Sounds weird.

    Thanks Manan, you’re the man. After countless hours and weeks searching for an answer for our problem with Windows 10 which is all f–ked up, I came across your simple, short comment and it worked. I almost fell off the chair in delight. I didn’t set any password either, and I certainly wouldn’t use password as THE PASSWORD, but I tried it and I was in as Administrator. Thanks again and Happy New Year!

    Try typing in “password”

    The default password was password, so I’ve reset it. But the User Account control on my desktop still has no Yes/No options??

    says Access Is Denied

    I am not getting yes option to make any changes in the laptop. I am even not able to run cmd command. When I am trying to run cmd as administrator it is asking for admini user name and password which I don’t have. I tried many things but nothing is working out.

    Kindly help in fixing this issue asap.

    Thanks in advance

    The command
    NET USER Administrator password
    will NOT reset the Administrator account’s password and make it empty
    instead it will reset the Administrator account’s password and make it password

    Yep you are right. Sorry. Updating the article.

    In window 10, first go to recovery mode.
    Once in recovery mode please go to :
    1. Troubleshoot > Advanced > Start up settings > press Restart > then select Safemode without networking
    2. Login to “Administrator”
    3. Press Windows key and R, and type Netplwiz
    4. Select your account and press Properties > then select Administrators > Click apply and okay

    Оцените статью