In the software I maintain I plan to replace the old MessageBox by TaskDialog as suggested by Microsoft UI guidlines already quite some time ago.
The main issue I need to resolve is following:
The old message box invoked via MessageBox(... ,MB_OK) (thus containing only an OK button) can be dismissed by pressing the Esc key.
But a TaskDialog containing only an OK button cannot be dismissed by pressing Esc. This might have a negative impact on the user experience.
I tried to use TaskDialogIndirect using the pfCallback field, but if the there is no Cancel button in the task dialog, the callback function doesn't even get called.
Any ideas what can be done so Esc will dismiss such a task dialog?
The MSDN documentation for the TASKDIALOGCONFIG structure says the following about the TDF_ALLOW_DIALOG_CANCELLATION flag (the dwFlags member):
Indicates that the dialog should be able to be closed using Alt-F4, Escape, and the title bar's close button even if no cancel button is specified in either the dwCommonButtons or pButtons members.
This flag also gives the dialog box a system menu (Alt+Space), so you can also close it by pressing Alt+Space and the underlined character in the system menu's "Close" item.
Related
I have to use USB barcode scanner in application running on remote desktop. This scanner is being recognised by Windows as keyboard. When I try to scan barcode however, every 3th or 4th character is being changed to another one. When I type numbers by hand, they are being correctly written. The question is: is there any way to programmatically produce "lag" on keyboard globally? I would like to create for example a half second gap between keyboard input events and a result on the screen. Some time ago I worked with Windows hooks, and I was able to change keyboard input globally, but I remember I had problems with delaying it. Is there any other way?
you can make an autohotkey script to listen to a keyboard input, wait and then press the same keyboard button.
once you have intalled AHK(autohotkey) , you can do a AHK script whit the intructions that are in the ahk documentation.
Right-Click on your desktop.
Find "New" in the menu.
Click "AutoHotkey Script" inside the "New" menu.
Give the script a new name. Note: It must end with a .ahk extension. Ex. MyScript.ahk
Find the newly created file on your desktop and Right-Click it.
Click "Edit Script".
A window should have popped up, probably Notepad. If so, SUCCESS!
i::
sleep, 500 ;
Send, i
Return
(you can change the "i" for other keyboard keys).
a function would reduce the amount of code that you use, but i don't know how to do it in a AHK script
My app uses a 3rd party DLL for image processing, which opens a file dialog to choose an image file. For continuity and usability reasons, I use a separate thread to change the dialog after it appears (change the icon and title, and remove the system menu and context help button). I also introduce my own WNDPROC to capture the button clicks, which I can re-route to my app if I choose.
I want to do some specific processing of certain image types, but I need to know when one of these has been picked. Is there a way to get hold of the full file path and pass it back to my app? (The third party file dialog is not the default Windows dialog, but seems to be based on it).
In my WNDPROC, after catching the IDOK WM_COMMAND message, I used SendMessage and CDM_GETFILEPATH to get what I'm after!
Edit:
Actually, it seems I'm better off catching the WM_DESTROY message - in case the user double-clicks or presses enter instead of the 'OK' button.
When I create SHBrowseForFolderW dialog the default control is OK, what I need to do is make SysTreeView32 active so a user can right on use arrow keys to adjust the desired folder. I tried to use this code : http://comp.newsgroups.archived.at/os.ms-windows.programmer.win32/200505/05053122835.html which wokrs ok in finding the HWND of the dialog but using WM_NEXTDLGCTL has no effect on the window.
Maybe I should send TAB keystrokes to the window, or I don't know any other opions ? Are there swiches in creating the browse dialog what control will be highlighted when the window create ?
Ok, the thing is difference between PostMessage and SendMessage. I mistakenly used the later here. They are not the same!
I am using AutoIT within Internet Explorer to navigate from one web page to another
The code I am using is:
_IENavigate($oIE, "http://www.google.co.uk")
However the web page that it is coming from displays a JavaScript popup box. I would like to click the OK button to allow the Navigation to proceed
I have tried using the following code:
ControlClick("Windows Internet Explorer", "", "[CLASS:Button; TEXT:OK; Instance:1;]")
However this doesn't work due to the fact that when the dialogue box appears the AutoIT process seems to pause itself.
The title on the dialogue box is "Windows Internet Explorer" and there are two buttons. The button I would like to click has the text of "OK"
Has anyone else come across this before? If so how can I solve this problem?
_IENavigate by default waits until the page is fully loaded. The dialog box may prevent a page to be fully loaded. The correct solution would be to:
_IENavigate the page without waiting for the page to fully load
Wait until the dialog box appears and close it
Wait for the page to fully load
The parameters for _IENavigate are like this, and you need to set $f_wait to 0:
_IENavigate(ByRef $o_object, $s_url [, $f_wait = 1])
To wait for the dialog box to appear, you will probably simply repeatedly attempt to click it until the ControlClick function returns it did so successfully.
I'm looking for an event which gets called when the user switches to another app (without closing Excel) and when he switches back to Excel again. I need to know this to stop a timer triggered event which isn't necessary when app isn't active or nothing is changed.
I would use it to implement an autosave-method which shouldn't save the file if its in the background and therefore not been changed.
There's an excellent article on how to find what events are available here
http://www.cpearson.com/excel/Events.aspx
"Open the Object Browser in the VBA Editor (press F2 or choose Object Browser from the View menu. In the Classes list, scroll down and select Worksheet. Right-click anywhere in the primary window and choose Group Members on the pop up menu. Then scroll down in the Members Of "Worksheet" list until you see items with yellow lightening bolts next to them. These are the events for the Worksheet objects. Do the same for the Workbook and Application objects."
I am not sure whether you will be able to find EXCEL events that capture your needs, as jumping to another application is not an EXCEL mechanism, but a general Windows mechanism. In fact you try to capture a kind of "LostFocus" event of the Excel application itself. Excel however gives you only event triggers for events that are "local to the Excel application".
What about calling your external program by pressing an Excel Button which contains code to
set a global status variable to "I JUMPED OFF"
stop the timer
start the external application (Shell or similar), minimize the window or whatever
plus a global Selection_Change trigger that
examines the status variable, and if it was set to "I JUMPED OFF"
set it back to "I AM HERE"
restart the timer
Of course this is a bit weak and the user can trick you out by simply manoevering with the mouse or Alt-TAB, but if you maximize the window on Startup you can motivate the user to use the Buttons.