I've got a code that lists the running application on a win32 box, and then displays theirs icons.
So far so good, I get the hwnd of the app, then call for GetClassLong(hwnd,GCL_HICONSM), and everything's fine.
But the case of a java apps is a pain to deal with, as the process answering to my calls is javaw.exe, and not the shiny-pimpy java application, who's got a so beautiful icon...
I gave a shot at GetWindowThreadProcessId also, but alas, it's the PID of javaw that's returned...
There's a way to do this though, as the task manager (alt+tab) displays the good icon.
I answer to my own question, thanks to PhiLho who put me on the right track: an article from Codeproject with the right algorithm to get a window icon (wether it's java or not):
//first, try:
SendMessageTimeout(WM_GETICON)
//if no icon found, try
GetClassLong(GCL_HICONSM)
//if still no icon, try
SendMessageTimeout(WM_WM_QUERYDRAGICON)
//if still no icon, you're doomed, return an error, or a void icon
For some reason a java app answers to the first call, but not to the others, which seems to be handled by javaw.exe.
Thanks again PhiLho.
Mmm, it can be done, because Process Viewer has a Show Applications button which does that (even if the main view shows the Java's icon). Alas this freeware isn't open source, so it won't tell its secret... :-(
Sysinternals' ProcMon doesn't do that, alas.
I will dig a bit more... :-)
[EDIT] Both a MS KB article and a Code Project article recommend using WM_QUERYDRAGICON if GCL_HICON fails...
Related
Dropbox has the option of adding a button to the Finder toolbar. It even appears in the 'Customize Toolbar...' window.
I can't find any documentation on how this sort of thing is done.... Does anyone know how to do this, or can anyone point me towards some documentation or sample code?
EDIT ONE:
I guess a start would be finding the location of the existing icons, and any related code.
I noticed that Dropbox has files in Library/DropboxHelperTools/Dropbox_u501 called mach_inject_bundle_stub.bundle and FinderLoadBundle which might be doing the magic. Dropbox is also putting the 'tick' badge on Finder icons. This code might be involved: github.com/rentzsch/mach_star
EDIT TWO:
A Dropbox talk by Rian Hunter about the process is here, at around 15:30
http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2011-how-dropbox-did-it-and-how-python-helped-4896698
Looking in the DropboxBundle file in the Dropbox_u501 shows the icons and some compiled code. The code suggests that Rian Hunter is the author: http://twitter.com/timeserena
Rian has his own version of the Mach Star code on his github - https://github.com/rianhunter/mach_star - tho it seems much older
EDIT THREE
There was a 'Code Injection Workshop' at Stanford a few weeks ago - http://stanfordacm.com/past/ - hosted by Rian. If anyone has notes from this please let me know!
You can use Finder Sync app extension(Starting in OS X v10.10).
A Finder Sync extension can:
Add, remove, and update badges and labels on items in a monitored folder.
Display a contextual menu when the user Control-clicks an item inside a monitored folder.
Add a custom button to the Finder’s toolbar.
Dropbox was using undocumented magic. There's no officially supported way to do this; the closest you can get without reverse engineering is Services.
(Update: As of macOS 10.11, what Dropbox was doing is no longer possible at all. System Integrity Protection now prevents code from being injected into system processes, such as the Finder.)
Rian's talk at PyCon 2011 (on blip.tv) does not explain anything more than "We reverse-engineered Finder." Although the mach_star stuff is valuable, it still doesn't explain how to get a sidebar icon working. And the Stanford 'Code Injection Workshop' has not posted any content about this method.
I've nm'd and class-dump'd both bundles that Dropbox installs for each user under /Library/DropboxHelperTools, and the output provides good insight. If I get back to it, I'll finish my research and post it. Odds are, it won't be for some time, so here's hoping this nudge helps someone else.
An easy intermediate answer that may be adequate for some people is to simply create icons that look like buttons.
e.g. I created 'new text file here' and 'new terminal here icons' for my Finder:
The method can be found here.
The disadvantage is that they must be square and do not have animations/menus or show up in 'customize toolbar' etc.
I have an application like WindowBlinds that recreates window look at all. But i'll now stuk with tray window.
I disassemble Shell_NotifyIcon() func and found it uses then Shell_NotifyIconW() func then just by ordinal (from shellw.dll) function 215 to create,modify and remove icon's.
In this funcition then I found i can find WndProc by hwnd (in disassembled code i am getting hwnd by FindWindowW(L"Shell_TrayWnd", 0);) but how?
Anybody work with this?
Please help.
Explorer just gets a WM_COPYDATA message IIRC, so you could subclass (you need to be in the same process) and catch that message, or interact with the tray icon list with toolbar messages, see the open source TraySaver app.
You could also take a look at some of the open source alternative shells, they have a lot of this undocumented stuff figured out. I linked to a couple of them in a somewhat related answer.
Hy everybody,
I'm wondering if it's possible to add a new button via C++ or C# to windows 7 explorer "context strip"(don't know if this is correct name) - like on picture below.
My reason for this is because a lot of times I'm switching on&off "Show hidden files, folders and drives" functionality under Tools->Folder option->View. Therefore i want to simplify this process with a click of a button.
I was looking into ShellExecteEx function, but I am not sure I can do that. Can Anybody direct me in right direction?
thanks,
regards
I highly recommend using AutoIt for this task. Second URL comes complete with examples of how to insert buttons in various programs - however, be sure to read complete topic for misc. updates to the provided code.
See:
http://www.autoitscript.com/forum/index.php?showtopic=9517
Btw: I misread topic to begin with; gui 'context' related material in Windows is often taken to deal with right-click menus
Edit: limit on urls for new users on Stack Overflow mean I had to cut out some of less essential links - google away.
To answer part of the question, I think it is possible as for quite some time we've seen small programs to add a "New Folder" button to the explorer. I think those still works with Win 7.
Look at http://tools.tortoisesvn.net/StExBar for example
[Edit] Forgot to clarify that Source Code for StExBar is on Google Code
I recently asked a question here about a dialog problem I had, but i discovered that the problem lies in such a different area i intentionally thought that I will rephrase my question here.
The problem is that I've been working on a DirectX10 game engine. When the engine inits there should pop up a dialog box which gives the user the possibility to choose settings. To develop this i created a separate solution (visual studio 2008) where i made the dialog resource and the proc function. I tested it there with a small winmain function and it works perfect.
Then I copied the resource and all the code to my main engine and fired it up. The only thing that happens is that the dialog pops up very shortly and it immediately closes without even waiting for user input. Also the MessageBox function does the same thing. I went through every step, but I'm really stuck.
Could any of you please look at the code for me and see if you can find what the *bleep* is going on?
There are three different folders in the zip. VKRenderer is the rending part of the engine where the VKD3D10 is a directX10 implementation of the in VKRenderer defined RenderDevice. In the VKRenderer solution also all the exported functions get exported from VKD3D10. VKD3D10 builds to a dll and VKRenderer to a .lib. Then there is StartupTest which uses the builds to try and start up the engine. The SettingsDialogTest is where i created the settings dialog and all the resources. There you can also find the working version of the settings dialog.
The ZIP file can be downloaded here. (The engine is still under development, so be kind with you comments :P ) THANKS A TON IN ADVANCE
pass = HELP
At a guess, try changing:
INT_PTR i = DialogBoxParam(hinst, L"IDD_SETTINGS", hwnd, DlgProcWrapper,(LPARAM) this );
to
INT_PTR i = DialogBoxParam(hinst, MAKEINTRESOURCE( IDD_SETTINGS ), hwnd, DlgProcWrapper,(LPARAM) this );
I'm writing a DLL that is automatically injected on load in a specific application. Because I'd like to run the program while working on it, and my users might want to load the program without it in specific cases (e.g. bug hunting), I sometimes want to prevent loading the DLL.
Currently I do this by checking GetKeyState for VK_LCONTROL, VK_LSHIFT , and VK_LMENU on load, and if all are down, I silently unload myself.
However, it can take quite a few seconds for the program to load and to see if the DLL was loaded or not, so I want to inform the users when we're unloading. I've considered a MessageBox, but that's too disruptive. I've tried MessageBeep, but that didn't seem to do anything on my setup. Currently I'm using a simple dual beep (Beep, Sleep, Beep) to indicate unloading, but that will probably become rather annoying to my co workers. I've also considered a system-tray icon, but that would introduce a lot of code and bug potential, while I'm aiming for a minimal notification as to not introduce any subtle bugs.
Would anyone else know a subtle way (preferably visual) to inform the user that their input has been succesfully received?
Given the limited scope of your goal, this might actually be an appropriate use of a taskbar notification balloon tip.
Edit: Added link the Joe posted in his concurring answer. Thanks, Joe! :)
If your app has a status bar at the bottom, you could place some message text there...
Have you considered a timed messagebox that closes itself?
http://www.codeguru.com/cpp/misc/misc/messageboxhandling/article.php/c203
You could open a window with a short message and close it automatically again after 0.5 seconds or so. It doesn't need user interaction so I don't think it's very disruptive.
Change the window title, then change it back afterwards. Then you can see the change even if the user has Alt-Tabbed over to some other program in the meanwhile, without stealing the focus from the user.
Concur with Greg D.
Look here: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/15cbdc8d-fde3-44ab-bbbc-e50cb2071674/
Two ideas:
Turn it around. Have a visual indication when the DLL is loaded, and have the absence of the indicator let you know that the DLL has been unloaded. Perhaps a suffix in the title bar. That way, you can tell at any time, not just during startup.
FlashWindowEx.