How can I create a "Yes To All" Button using WinAPI? - winapi

We have a legacy application written in C that uses WinAPI. We'd like to add a "Yes to All" button to a few of our dialog boxes. Unfortunately, the existing MessageBox function does not allow for custom buttons or button captions.
What's the best way to do so? Is there a slick hack to easily add a custom button? Or should we create our own MessageBox replacement?

Something like that maybe? http://www.codeproject.com/KB/dialog/CRHYesNoToAllDialog.aspx
Or this: Using Windows Hooks to Enhance MessageBox in .NET
Marc

There is another kind of a message box in WinAPI, since Windows 2000. It's SHMessageBoxCheck.
It allows you to display a standard MB_OKCANCEL/MB_YESNO/MB_OK-type MessageBox with the option to Never show it again, by specifying which the default option in that case is.
Maybe it's not exactly what you're looking for, but it's fairly consistent with Windows UI.
In Vista most of the shell's "Yes to all" dialogs actually work this way - there's no additional button saying "Yes/No to all" - there's a "Perform chosen action on all items" checkbox instead.
However the Note in documentation worries me:
This function is available through Microsoft Windows XP and Windows Server 2003. It might be altered or unavailable in subsequent versions of Windows.

You may also need to take care of the text wrapping to make it similar to MessageBox. Also MessageBox uses a different font compared to the default GUI font. And don't forget to play the sound when the dialog pops up :)

We ended just creating our own DIALOGEX replacement resource template, then simply call DialogBox() and check the return value.
Reference: http://msdn.microsoft.com/library/ms644996(v=VS.85).aspx#modal_box

Related

Applications hook

I would like to make some hook in windows programs. For instance, Vodafone application have some MSN like popup that can't be hiddent. So, in that way, I would like to create my option to hide or not this popups. Can anybody tell me some tutorials (basic first) how to do that?
Thanks in advice.
You have to create system wide windows hook with SetWindowsHookEx with first param WH_CBT. You can hook on HCBT_CREATEWND event and return non zero value and window will be destroyed, but first you have to somehow recognize that this is right window, maybe according to window title or something inside that title.
Another thing is that you can't use managed code and C# for system wide hooks, since you have to make unmanaged dll in witch hook will reside. So you have to use C++ or Delphi, and if you are not experienced in win32 programming that would probably be very complicated task.

How to use AutoIt to click a window dialog in a different language

On Windows 7, when we install an unsigned driver, it will pop-up a Windows security dialog. It is easy to have it be clicked on by AutoIt. Just search the window dialog with the specified window title.
But now, I want to use it on another platform with a different language. The window title will be changed to the local language, not the 'Windows security'.
How can I create the AutoIt script, which can handle the Windows security dialog in different language?
Fix this issue by finding a child handle from the security window class.
Try to use a class on Tittle. Title = [CLASS:notepad]
for more information visit here http://autoitsourcecode.blogspot.com/2013/04/autoit-control-send.html
Use the "AutoIt v3 Window Information" Tool provided by the "AutoIt full installation" and try to get some unique information like a Class name which is occuring in each different language dialog window as descirbed in advanced window descriptions. Then use these to search for the proper security window.
I'd suggest, you use the WinWaitActive("[REGEXPTITLE:Windows Security|Windows Sicherheit]") function with regular expressions for being able to wait for multiple windows with different titles.

How can I override or customize the delete confirmation dialog in Windows?

When we press Shift+Delete key, a delete confirmation dialog is generated. I want to handle this dialog according my need or change its message. Can anyone tell me what thing is responsible for that dialog?
I either need to know the code which handles the delete confirmation dialog generated by the Shift+Delete key sequence in Windows XP, or the code by which we can control this operation.
I don't think what you want to do is going to be fun.
Im guessing you have to intercept the SHFileOperation function (and the IFileOperation interface for Vista onward)
Here what my google-fu got me on winapi interception:
http://www.codeproject.com/kb/system/hooksys.aspx
You might want to look at this : http://easyhook.codeplex.com/
This project supports extending
(hooking) unmanaged code (APIs) with
pure managed ones, from within a fully
managed environment like C# using
Windows 2000 SP4 and later...
Good Luck! =)
If you only want to mess with the dialog (change the displayed text, image, etc.) you can try to modify the resources with a free tool such as Resource Hacker.
The "delete" dialog resources are in shell32.dll in Windows XP (you mentioned only that version of Windows); fire up the Resource Hacker and open shell32.dll, then search for the warning text "Are you sure you want to delete" and you'll find:
CONTROL "Are you sure you want to delete '%1'?", 12295, STATIC, SS_LEFT | SS_NOPREFIX | WS_CHILD | WS_VISIBLE | WS_GROUP, 41, 10, 220, 28
Now that's only the static text, but the whole dialog definition (buttons etc.) should be here. I think this way you can make it a simple warning dialog--e.g. "You're forbidden to delete anything!" and only a "Cancel" button.
One way to address file deletion restrictions could be by employing NTFS security descriptors.
Security Descriptors
Security Descriptor Operations
That way, you change it in one place and not have to worry about covering all cases to prevent deleting a file.

How can I use standard WiX to create a streamlined installer experience?

Background:
Currently, we have created a wizard by WiX UI. The user should click next, next and next...
But suddenly, we found that there's nothing should be interacted with user, user just need keep clicking next. So..
Here is the desired behavior:
We automatically switch to the next dialog page after all the stuff (such as pre-check and so on) done in the current page. Once there are errors in installation process, we show the error page to the user. That makes for a streamlined installer experience for the user. One click, everything done.
Can WIX do this kind of stuff purely, or should I need some other work to do to implement this?
No, you'll need to define your own external UI handler (like the MS Office installer does) if you want something "fancy" - why not just remove the UI altogether? We do this for a number of setups....
Take a look at WixUI_Mondo, WixUI_Minimal and other predefined UIs that come with WiX. Otherwise you can define your own dialogs and their sequence.
You can try with Wix_minimal or you can go for your own customized dialog boxes.
You can also customize the sequences of the dialog boxes by your own need. I suggest you to do the second option.

Is there a simple way to change the text of the 'Open' button on the windows file dialog to 'Select'?

We're using the file picker dialog to allow users to add documents into our application. The word 'Open' doesn't make a lot of sense in this case.
Thanks.
I would browse the code found here, which shows how someone extended the OpenFileDialog. Admittedly, this is overkill for you. But I think there is code within to change the button label.
Not really no.
Given the standardization of this dialog it's extremely likely that your users will have used it many times in the past to "add" files to applications. The chances are they will be quite familiar with the implications of the word, changing it may be more confusing to them.
The standardness of the dialog is why it's called a "Common File Dialog". If you want to change it for your app, you'll have to write your own dialog.
Having said that, there are apps out there that can pull a form out of a DLL, modify it, and stick it back in. However, this is a per-machine hack and downright bad form.

Resources