How to save and restore last window size in Win32 API C/C++ without writing anything to system registry.
AFAIK, the best you can do is GetWindowPlacement, which will get you the restore coordinates through WINDOWPLACEMENT.rcNormalPosition.
Related
When some programs are opened they automatically cascade (when not opened in full screen), and I want to keep all documents directly on top of each other. I found this which claims that it is impossible.
I know that it can be done by having AutoHotkey watch if newly opened windows are not touching a border and moving it to the closest border, or to watch the position of the window when it is activated. Does anyone know of a good way to solve this using e.g. AutoHotkey?
The only working solution I have found so far is using DisplayFusion, which solves this using the setting
"window location". Here’s a short guide. I also found that there is a way to script it using the same program.
Say I open paint.exe from a c++ code using windows apis or just by clicking it.
After app opened up. I resized it(by hand or programmaticly) . And closed the app.
Next time I open it, it gives me the size from where I left off.
Is there a place where I can query the default size of apps(sizes when you see the apps when you first open it (for the very fist time) before you re size any windows)
And If i can, maybe I can call SetWindowPos to set the original position for that app.
Maybe this is not exactly a programming question.
This is always going to be different between applications.
Most application will remember their window size/position by using the registry. In the case of "paint", it stores this information in the registry at:
HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\View
Notepad stores similar information in HKCU\Software\Microsoft\Notepad - in an entirely different schema of registry key values.
As I understand it, when a file open dialog box (such as GetOpenFileName) is used, Windows will automatically remember where the last file was that was opened by the program, and Windows remembers these locations separately for each program. Is there a way to directly alter this, in order to cause the file picking dialog for program X to start in C:\Example\Directory?
I'm attempting to automate a program which has been programmed to work only through a GUI, and I don't have any access to the internals of this program (such as being able to alter how it calls the file picker). Instead, I'm using a mouse macro (via AutoHotkey). If I can be completely sure that the file picker will start in a particular place, I should be able to automate the rest with mouse clicks.
If you had access to the source code, I'd suggest you just change the lpstrInitialDir property of the OPENFILENAME passed to GetOpenFileName().
Outside of that, you'll want to change the registry keys for the MRUs:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32
What might make more sense, and might fix the issue you're having, is also changing the Working Directory so that the default location isn't "My Documents", if you're experiencing that.
Depending on the operating system, the results vary:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx
I am using the SHGetFileInfo api to get a handle to and display the icon associated with a particular file.
If the file has no icon associated with it Windows will return you the default one that it uses in explorer for unknown file types. In this case I don't want to display the icon.
How can I tell if the file has no associated icon and Windows is giving me back the default one?
On my system SHFILEINFO.iIcon is always equal to 3 in this case but i'm not sure how reliable that is and I expect there is a better way to check this.
Edit: I am targeting Windows XP and upwards
Thanks
Which OS versions are you targeting? If you can assume Vista and later, there's an API SHGetStockIconInfo that you may find useful.
SHGetStockIconInfo(SIID_DOCNOASSOC, SHGSI_SYSICONINDEX, &sii)
will return the icon index you're looking for in sii.iSysImageIndex.
You could try passing a fictitious filename with an unknown extension to SHGetFileInfo(), keep track of which icon index it reports, and then compare that index to your real files.
What is your biggest pet peeve related to the windbg debugger from microsoft?
(note: I actually really like windbg if I ignore the unpolished UI.)
Attempting to dock a window is almost always the wrong kind of dock the first time until :I move the mouse just right. Why can't it have the docking cues that VS2008 has?
The ridiculous behavior when you attempt to use click-drag to select text on a line that is wider than its physical window.
The pieces of the history window that I need to copy/paste into bug reports are frequently wider than the physical window. I've gotten so used to the triple-click workaround that I find myself attempting to misuse triple click in other (well behaved) applications.
Key presses are ignored while the focus is in a source window. It's not like you can edit the source code from inside windbg. At least there's the Alt-1 workaround.
How insanely slow .kdfiles copies new binaries across the 1394 connection. It can take up to one minute for a large dll.
Not being able to switch from output window to command window using a key press, I read that 'Alt+1' should work but it doesn't always so I always have to resort to using the mouse. Also sometimes it doesn't remember when I tell it not to ask me everytime if I want to save the workspace when I quit.