how to inject custom window into windows explorer - windows

RT.as the picture below.
I try several ways as below, but not work :
Explorer Bars, Tool Bands, and Desk Bands, see here
Namespace extensions,see here
Implementing a Folder View, see here
I have resolve this problem, just resize the folder view window and create a new custom window and move it to the right postion, show below, this code will show custom window in top of folder view window:
HWND phwnd = (HWND)explorer SHELLDLL_DefView handle;
HWND chwnd = (HWND)explorer DirectUIHWND handle;
RECT *rcClient = new RECT();
GetClientRect(phwnd, rcClient);
MoveWindow(chwnd, rcClient->left, rcClient->top+39, rcClient->right, rcClient->bottom-39, TRUE);
HWND haddwnd = ::CreateDialogParam(hInst,
MAKEINTRESOURCE(IDD_DIALOG1),
phwnd,
(DLGPROC)About,
(LPARAM)rcClient);
ShowWindow(haddwnd, SW_SHOWNOACTIVATE);
MoveWindow(haddwnd, 0, 0, rcClient->right, 39, TRUE);
<pre>

Related

Is there a way to create a Windows 10 app that reside in taskbar similar to People App?

I would like to create a solution that will be like an icon on the taskbar and once clicked it will open as a small popup above the taskbar which will not interrupt the user or other windows similar to the Microsoft People app that will show on the bottom right as the following image:
This question has a similar title to my question but it's different subject where the asker was asking for the AppBar of the UWP app which is not my intention.
Other question
Is there a way to do that for normal developers, enterprise companies, or Microsoft partners?
Update 3rd :
Recently I tried to build the App, shared in this repo https://github.com/ejabu/TrayApp
things to note :
WindowStyle
to get Borderless window like People App.
<!-- MainWindow.xaml -->
<Window
....
WindowStyle="None">
<Grid/>
</Window>
ShowInTaskbar
ShowInTaskbar -> False
to prevent it appears on Taskbar
<!-- MainWindow.xaml -->
<Window
....
ShowInTaskbar="False"
...>
<Grid/>
</Window>
Use Hide Method
/// MainWindow.xaml.cs
private void Hide_Window()
{
this.Hide(); /// Minimize Window
}
Adjust Position according to Taskbar
/// MainWindow.xaml.cs
private void AdjustWindowPosition()
{
Screen sc = Screen.FromHandle(new WindowInteropHelper(this).Handle);
if (sc.WorkingArea.Top > 0)
{
Rect desktopWorkingArea = SystemParameters.WorkArea;
Left = desktopWorkingArea.Right - Width;
Top = desktopWorkingArea.Top;
}
else if ((sc.Bounds.Height - sc.WorkingArea.Height) > 0)
{
Rect desktopWorkingArea = SystemParameters.WorkArea;
Left = desktopWorkingArea.Right - Width;
Top = desktopWorkingArea.Bottom - Height;
}
else
{
Rect desktopWorkingArea = SystemParameters.WorkArea;
Left = desktopWorkingArea.Right - Width;
Top = desktopWorkingArea.Bottom - Height;
}
}
Update 2nd :
https://github.com/AronDavis/TwitchBot/blob/master/TwitchBotApp/Notification.xaml
Update:
https://www.youtube.com/watch?v=jdvD55ir1is
original :
this is the good example
Final Result
the Window page has no Close button. And also it cannot be dragged by commenting this line https://github.com/ejabu/AcrylicWindow/blob/343f4f5a6bc23109a97640f9ac35facb31e9ae43/AcrylicWindow/MainWindow.xaml.cs#L30
I found example project here
https://github.com/shenchauhan/MyPeople/tree/master/MyPeople/MyPeople
We may look at MyPeopleCanvas then.
I found also there is new update from Microsoft, that maybe we can replace Icon images with text in System Tray icon in the near future.
https://newswwc.com/technology/dotnet-technologies/personalized-content-at-a-glance-introducing-news-and-interests-on-the-windows-10-taskbar/
This is the closest i got to what i needed.
Although it's using ElectronJS and not WPF or UWP. But since it's doable with ElectronJS then it should also be doable on WPF.
https://github.com/sfatihk/electron-tray-window
Library is not created by me.

How to position a view right above the keyboard?

I'm writing a Forms app. How to position a view right at the bottom of the screen and when some entry is focused and the keyboard is visible, the view to be right above the keyboard? On android, it is possible to set Window.SetSoftInputMode(SoftInput.AdjustResize) and that will make the Content resize every time the keyboard is appearing/disappearing. However, I need the status bar to be transparent and SoftInput.AdjustResize doesn't work with WindowManagerFlags.TranslucentStatus. My question is, how do I position a view right above the keyboard without setting SoftInput.AdjustResize?
Take this example:
public Page1()
{
InitializeComponent();
var al = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
var button = new BoxView {Color = Color.Red, VerticalOptions = LayoutOptions.EndAndExpand};
var entry = new Entry {HorizontalOptions = LayoutOptions.Fill};
al.Children.Add(entry);
al.Children.Add(button);
Content = al;
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
}
If you run this code, when you'll press the input, nothing will change, the "button" will remain on the bottom of the screen not visible because of the overlaying keyboard.
If we add Window.SetSoftInputMode(SoftInput.AdjustResize) in MainActivity's onCreate it works fine, the box is moved above the keyboard on entry's focus.
Also, if we change Content = al; to Content = new ScrollView {Content = al};, it works fine.
However, if we add Window.AddFlags(WindowManagerFlags.TranslucentStatus); in MainActivity's onCreate, none of those methods work anymore.
Thanks in advance.
I'm writing a Forms app. How to position a view right at the bottom of
the screen and when some entry is focused and the keyboard is visible,
the view to be right above the keyboard?
If you are using Xamarin Forms, then wrapping your UI elements in a ScrollView should do the trick. Something like this if you are using XAML:
<ScrollView>
<ScrollView.Content>
// Your Original XAML content here
</ScrollView.Content>
<ScrollView
EDIT:
Looking at the example you just added, I THINK I know what is happening. So, the ScrollView Trick only works for elements that require keyboard input. I.e if you instead had an entry element at the bottom of the screen, and wrapped everything in a ScrollView like I suggested, then the keyboard should push the entry element up for you. However in your case you have a boxview at the bottom of the screen, which the keyboard simply runs over.
What you have for Content.SizedChanged is a good idea, however I don't think the size of the view actually changes when the keyboard pops up (at least, Content.SizeChanged isn't called when the keyboard pops up), so that part of your code is really only called on loading of the page from the MCVE you provided.
HOWEVER, I was able to move the 'button' up when the keyboard appears by doing this:
Replace
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
With
entry.Focused += (sender, e) =>
{
button.TranslationY -= 120;
};
You may have a heck of a time getting that magic translation number for all the different devices and orientations though. When I tested it on the iPhone 6 simulator I had to push way above 120 before I could see it above the keyboard.
Hope that helps!

Platform specific UI adjustments in Xamarin.Forms

I have a Xamarin.Forms screen defined is the core library as below:
Content = new WebView
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Source = "https://google.com",
};
As a result for iOS the content is overlapped with the system tray (top bar with system icons). You can see them in left top corner. The issue is the same tray is separated from webview for Android and I couldn't just add static top margin. I need to do it on "per platform" basis. Is there a way to accomplish that?
This is possible. You can use the Device.OnPlatform() method. Find out more in the API docs.
Usage could be:
Device.OnPlatform (iOS: () => webView.Padding = new Thickness (0, 20, 0, 0));
20 is the height of the statusbar.
There is also some documentation about platform tweaks here.

How to prevent multiple instance creation by SHBrowseForFolder()?

I am developing one application and i have added one button (CButton) which is calling SHBrowseForFolder() function. But the problem is that the button is still active and also it is letting me to click my parent window. Also i can click again and again that button and multiple browsing window are coming.
What i want to know that is there any way to use SHBrowseForFolder() in a DoModal() way, so that the control did not return to the parent window till user click that Ok/Cancel button of the folder browse window? I do not want to disable that button after clicking once or something like that.
I am using Visual Studio 2010.
Thanks in advance.
Sure it's possible:
void CUtility::BrowseFolder(CWnd* pParentWnd, const CString& sTitle, CEdit& Edit)
{
LPMALLOC pMalloc = NULL;
::SHGetMalloc(&pMalloc);
TCHAR pBuffer[MAX_PATH] = {0};
LPITEMIDLIST pidlRoot = NULL;
BROWSEINFO bi;
bi.hwndOwner = pParentWnd->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = pBuffer;
bi.lpszTitle = sTitle;
bi.ulFlags = BIF_USENEWUI;
bi.lpfn = NULL;
if((pidlRoot = ::SHBrowseForFolder(&bi)) == NULL)
return;
if(::SHGetPathFromIDList(pidlRoot, pBuffer))
Edit.SetWindowText(pBuffer);
if(pidlRoot)
pMalloc->Free(pidlRoot);
}

How to attach CFormView derived class to CMFCTabCrtl?

I have created MFC MDI project with base class CFormView, ribbon, caption bar etc.
In CMainFrame, OnCreate() calls EnableMDITabbedGroups() which automatically adds one tab
and attaches CMyProjectView view. Now I want to add second tab and attach second view to that tab. I created new dialog and added CFormView derived class to it.
Here is the code:
void CMainFrame::CreateViews()
{
const CObList &tabGroups = GetMDITabGroups();
CMFCTabCtrl *wndTab = (CMFCTabCtrl*)tabGroups.GetHead();
wndTab->m_bEnableWrapping = TRUE;
CRect dummyRect;
CNewFormView *pNewView = (CNewFormView*)RUNTIME_CLASS(CNewFormView)->CreateObject();
((CWnd*)pNewView)->Create(NULL, NULL, WS_CHILD, dummyRect, wndTab, IDD_NEWFORMVIEW);
wndTab->AddTab(pNewView, _T("NewTab"), -1, TRUE);
}
Now, I'm pretty sure I missed something trivial or went in wrong direction all together,
but I can't get new view to show up. Also, I can't catch AFX_WM_CHANGE_ACTIVE_TAB or AFX_WM_CHANGING_ACTIVE_TAB in CMainFrame. Message gets send from CMFCBaseTabCtrl::FireChangingActiveTab but nothing happens.
WS_VISIBLE is missing from the view's styles?
You may want to set the active view for the frame too.

Resources