Disabling visual styles in manifest while retaining Common Controls functionality - visual-studio

I'm using pure WINAPI, and need to send the TB_GETMETRICS message. However, that message only works if you add a manifest file to your application with a reference to Common Controls version 6.0. I added it, the message is working, but now my application is using Vista/Windows 7 visual styles, which I do not want.
Is there any way to keep the Common Controls 6.0 reference while using Classic theme, either by modifying the manifest file or by calling some API function?
Note: I tried SetWindowTheme but the result was a mix of Classic and Aero.
EDIT: I hadn't read the SetWindowTheme function correctly, so I was thinking calling it for the parent hWnd would automatically call it for all its child. It turns out I need to call it for each control I want to use Windows Classic. It's working as it should now.

To disable visual styles for all controls, call SetThemeAppProperties(STAP_ALLOW_NONCLIENT) or SetThemeAppProperties(0) before you create your main window.
To disable visual styles per HWND you can call SetWindowTheme(hwndControl,L"",L"")
If you need to support systems without v6 common controls you can probably figure out which system metrics (or hardcoded values) are used in the toolbar control by playing with the system metric values and system DPI.

Solved by using SetWindowTheme (with L"" as parameters) properly: all I had to do was call it for each and every control my application creates. It feels hackish but gets the job done.

Related

Does Outlook, as a Drop Target, support IAsyncOperation?

I am playing with Creating something from nothing, asynchronously [Developer-friendly virtual file implementation for .NET improved!].
This brilliant article demonstrates how to create a customized DataObject implementing delayed data extract on drop/paste and asynchronous data trnasfer on background thread.
It worked perfectly untill I tried to drop a file into Outlook 2016. It still works but the UI is not responsive despite the fact that my dataobject has "IsAsynchronous" set to true.
After debugging I found when dropped to Outlook IAsyncOperation.GetAsyncMode is not called and IDataObject.GetData is called on the UI thread.
My question is does Outlook support IAsyncOperation? If it does what am I missing? If it does not support IAsyncOperation, is there a workaround or different solution?
Regards
Xiao

Multiple "panes" view in single document Windows application

I'm trying to write an editor for game scenes. So far, I'm able to present results in a single window. However, I would like to have several "panes", for example for material properties or resources preview.
The good example would be Blender layout:
I know MFC and WinAPI, I wouldn't rather use Qt, since it's not free.
I did it on a commercial application and it works fine:
Create a Single Document application
Read about CDockablePane, then look into the MFC Feature Pack exanples.
Finally implement the CDockablePanes and their contents
Arrange them the way you want by docking them to your own CFrameWndEx-derived class.

What is imgMain control in visual Basic 6?

I'm using a VB6 application as a reference and have come across imgMain. I'm assuming its an image control, however, I cannot find the object on any of the forms. It's used to load the image. I'm just not sure what's going on with this. I'm assuming its an IMAGE CONTROL, but I cannot find this on any of the forms? it's mentioned a lot of times in teh application as it lets you view incoming faxes and stuff.
Without having a look on source code i assume It might be custom user control that was created for some reasons probably to extend basic picturebox control.
One thing i can advise you is to further inspect code and dig to code of this custom control. If code for this control is not available then see what methods and properties instances of that particular control uses and compare them with regular picturebox.

Theme-ing applications in Delphi XE

Does anyone know if it is possible to apply custom themes to Delphi applications. Example, changing the default colour, font, tab styles, etc. of a whole application (i.e. set of forms) at once. Kind of like css files for webpages.
Change the color and font of most of the vcl controls is relative easy to do, you can iterate over all the controls of a form and then set the propertiesFont and Color for each control. Now to customize the drawing of a VCL control you must owner draw each control your self. Another way is using a skinning library which do this for you, for example try the VCLSkin component which let you skin the entire application with no need for modifications in your VCL controls. Btw the new incoming version of Delphi (XE2) has great changes in this area introducing FireMonkey and VCL Styles.
Devexpress has something like that, ExpressSkins for VCL
Try Alphaskins it is easy and have a lite free version but make the work you want...

How can I filter by file type in an IExplorerBrowser in Windows 7 Libraries?

I've created an instance of IExplorerBrowser in my code to create a custom I/O view in one of my dialogs. I've implemented the IServiceProvider and ICommDlgBrowser interfaces in my host class. I use the IExplorerBrowser::BrowseToIDList method to fill the view.
I would like to filter the file types displayed (ex. only PNG files). If I call BrowseToIDList with FOLDERID_Pictures (i.e. "My Pictures") I can use the ICommDlgBrowser::IncludeObject method or IFolderFilter::ShouldShow to restrict which files I allow to be displayed. However, if I browse to the Picture Library on Windows 7 (FOLDERID_PicturesLibrary), neither ICommDlgBrowser::IncludeObject nor IFolderFilter::ShouldShow are ever called.
Is there some limitation to filtering files in libraries on Win7 that I'm unaware of? Perhaps I'm missing an interface or maybe I've specified the wrong flag somewhere.
Any ideas would be greatly appreciated.
I've had a chance to research this further, including asking a few questions to some Microsoft developers. It would appear, unfortunately, that filtering does not work with query backed views (i.e. Libraries).
An alternative to my approach would be to use the Common Item Dialog with application added controls (via IFileDialogCustomize).
(http://msdn.microsoft.com/en-us/library/bb776913(VS.85).aspx)
In my specific case, I'm unable to use a Common Item Dialog, but I thought it might be worthwhile to post this information here for future reference.
If in the future I find any way to filter an IExplorerBrowser control, I'll post that back here too.
I encountered this issue myself.
Yet I have investigated it a little bit further. IExplorerBrowser creates (on my Windows 7 x64 machine) window of ExplorerBrowserControl class. Which itself creates a window of DUIViewWndClassName class. And the very same window (DUIViewWndClassName) is used as a control by dialog created by IFileOpenDialog. Even window procedures are same so there is no subclassing (but I haven't checked each and every subwindow of that control).
And file dialogs are able to filter by file type even in the library folders. So I guess the IExplorerBrowser (or the control it uses) does allow that only Microsoft does not share knowledge how to do that. Or if it does then its somewhat hidden knowledge.
But I got it with IFolderFilterSite (interface supported by IExplorerBrowser from CLSID_ExplorerBrowser). IFolderFilter::ShouldShow isn't called in such cases for library folders. I wasn't able to get ICommDlgBrowser::IncludeObject called (even if I didn't set any IFolderFilter).
EDIT: I managed to get ICommDlgBrowser::IncludeObject called. Somehow I forgot that I have to provide ICommDlgBrowser through IServiceProvider::QueryService rather than through IUnknown::QueryInterface. But still ICommDlgBrowser::IncludeObject is not called for library folders.
I tried using IShellFolderViewDual3->FilterView().
But it's search results.
Thank you.
IShellView *pShellView;
IDispatch *pDSFV;
IShellFolderViewDual3 *pSFVD3;
m_pExplorerBrowser->GetCurrentView(IID_PPV_ARGS(&pShellView));
pShellView->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pDSFV));
pDSFV->QueryInterface(IID_PPV_ARGS(&pSFVD3));
pSFVD3->FilterView(bstrVal);

Resources