Prevent manual scrolling to the "preselected" folder being required when using `TSelectDirectoryDialog` - lazarus

When I'm setting the InitialDir property of TSelectDirectoryDialog the folder will be "selected" but I still have to scroll to it if it's below the currently visible area.
Is there a way I can make TSelectDirectoryDialog not to start at the beginning? Or is it possible to use a different dialog to select an existing folder the behaves the way I'm looking for?
Currently I'm using it on a Windows 7 64bit system.

For me (Laz 1.8.4, Win 10) the TSelectDirectorydialog immediately goes to the InitialDir by default. The dialog looks like a FileOpen dialog, though. If you prefer the old dialog with the treeview alone you should turn the option ofOldStyleDialog ON and ofEnableSizing OFF (the latter is due to a bug in Windows).

Related

How to control what is shown in Windows 10 "recently added" programs list?

The Windows 10 start menu will show recently added programs after you run an installer.
In my case, the installer installs more than one program to Start Menu. For some reason it is picking one of them and showing it as "recently added", but I'd like to specify that a different one shows up there.
How can this been set / controlled?
I have tried to change the order which the installer adds entries to the start menu, but that didn't appear to have any effect.
I'm not sure how Windows internally tracks this, but at least if you are using Inno Setup it is possible to disable tracking the installed program as recently added by using a flag:
excludefromshowinnewinstall
Prevents the Start menu entry for the new shortcut from receiving a
highlight on Windows 7 and additionally prevents the new shortcut from
being automatically pinned the Start screen on Windows 8 (or later).
Ignored on earlier Windows versions.
Ref.: https://jrsoftware.org/ishelp/index.php?topic=iconssection
So it should be possible to apply this exclusionary flag to all but the program which is intended to be shown in the list.

Determining if currently renaming a file in Windows Explorer

I am trying to check a Windows Explorer view to see if a file name is currently being renamed / edited when typing.
I have a system hook installed that monitors the keyboard for specific keystrokes and fires certain events. This is done in this manner:
If the keyboard hook sees the key pressed it fires a message to another thread and continue processing other system hooks.
Other thread receives the message and checks to see if an Explorer window is active and gets the interface to the IFolderView2.
Call IFolderView2::GetFocusedItem() to get the focused item in the folder view.
Check if the focused item is being renamed / is in edit mode (SVSI_EDIT) using IFolderView2:: GetSelectionState() - this is the part that fails
If not in rename mode perform an action on that file.
I've tried everything on Windows 7 but the SVSI_EDIT flag (0x00000002 specifically) is never returned. It's always (SVSI_FOCUSED | SVSI_SELECT) regardless of if the file is being renamed. Setting the SVSI_EDIT flag with works with IFolderView::SelectItem with the flag puts it into rename mode but I want to determine if it's in this mode already.
This has only been tested on Windows 7 x64 so far.
Does anyone know a way to determine if Explorer / the IFolderView etc. is currently in the rename file state? Any sneaky method will do if it's not possible through these interfaces.
If one file in in renaming mode, Windows will create a EDIT control at the position of the item. So things got straight:
Find the currently-focused control.
Get the CLASS of the control.
Check whether it's CLASS is an EDIT.
On CodeProject there is a great example about how to find the focused control. To get the CLASS name of that control, use GetClassName API.

Firefox 10.0 disable hot keys using user.js

I'm currently working on a project where I have firefox launching in one of three modes:
normal
full - kiosk mode with only tabs, and home back and forward navigation showing.
Super - kiosk mode no tabs or anything showing just the content window (true kiosk mode)
Now due to time constraints I have implemented via pygtk rather than creating a custom Firefox extension as the requirements of the project would require a new flag adding to the command line in order to identify what mode it was to launch in. The approach I have used works beautifully, Great. . .
However the problem now is how can I disable all of the hot keys i.e. Ctrl + T, etc, without writing a extension. I am unable to use an existing extension because I need the shortcuts available when firefox is in normal mode and as firefox (for the project) can only be started via the command line programatically I would need a flag to determine weather to restrict the hot keys or not.
I was hoping to be able to achieve this using user.js which is placed programatically into the correct profiles when they are created in another bit of my application. I have tried using user.js by modifying accelKey, chromeAccess, contentAccess, generalAccessKey and menuAccessKey and setting their values to 0, which works for menu access but not for anything else.
Finally the Question
Is it possible to disable all shortcuts from user.js or can you only do it through an extension?
No, you cannot disable shortcut keys via preferences. Not all shortcut keys use the configurable Accel modifier, but even the ones that do cannot be disabled via preferences. In case you are interested, the code handling them only recognizes Meta, Alt and Ctrl as valid values, with Ctrl being the default for inputs that aren't recognized. You can try using Meta (the corresponding code is 224), it seems unmapped on PC keyboard. For anything more fancy than that you will need an extension.
I apologize if this sounds like an ad instead of an answer, it's not meant to.
If you do have time constraints and you just want to get a hold of the code you need, there is an open source kiosk project called Webconverger that has already done a lot of the heavy lifting.

IFileSaveDialog - choosing folders in Windows 7

In Vista, I have been using an IFileSaveDialog to let users pick a "save-as" folder. Users export a folder of images, say, and need to choose a new or existing target folder.
Briefly, the code goes like this:
IFileSaveDialog* dialog; // created
dialog->SetOptions(FOS_PICKFOLDERS);
dialog->Show(NULL);
dialog->GetResult(&shellItem)
In Windows 7, the FOS_PICKFOLDERS option appears to have been disallowed (and is marked as such in the API). The return value on the SetOptions call is E_INVALIDARG. If I use a IFileOpenDialog, I'm allowed to set the folders option, but the user is prompted with an error when choosing a nonexistent folder (despite my setting flags suggesting not to do this).
Is there an alternate way to get the new IFileDialog to act as a "save folder" dialog?
[To head off some comments, the SHBrowseForFolder API still exists, but is still not an acceptable solution for our UI deciders.]
The reason for this can be found in the documentation:
FOS_PICKFOLDERS: Present the Open dialog offering a choice of folders rather than files.
Using FOS_PICKFOLDERS for "save" was never supposed to be supported - but Vista didn't enforce it. Use IFileOpenDialog instead and you're good to go.
You are picking an existing folder (not specifying a folder to create), so open was always the correct choice.
I haven't played around with the Windows 7 dialogs yet, but downloaded the Windows® API Code Pack just this morning as I am implementing the Thumbnail Toolbar and Icon Overlay in the application I am working on. It'll probably point you in the right direction.

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Resources