Remove the height limit of an app targeting Windows 8.1, but running on Windows 10? - windows-8

My question sounds simple: is it possible to remove the height limit of an app, if it is targeting Windows 8.1, but is also distributed to Windows 10 devices? Or is it my only choice just to upgrade project to target Windows 10, and distribute a separate package for it?
A related question:
How to specify initial window size for Windows 8.1 app running on Windows 10
..and an answer suggests "You could use reflection to call part of windows 10 sdk at runtime within your windows 8.1 app". Well, I have turned the whole Internet inside out, and I didn't find any normal explanation of this mystical method.

The method you've mentioned is use reflection to call ApplicationView.SetPreferredMinSize method at run time within Windows 8.1 app like following:
var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
var setPreferredMinSizeMethod = appView.GetType().GetRuntimeMethod("SetPreferredMinSize", new Type[] { typeof(Size) });
if (setPreferredMinSizeMethod != null)
{
setPreferredMinSizeMethod.Invoke(appView, new object[] { new Size(300, 300) });
}
Using this approach, you can reset the preferred min size and remove the default 768 height limit.
But please note that on Windows 10, Windows 8.1 app's ApplicaitonView is mainly controlled by system. If not necessary, please do not use reflection to do this.

Related

Is it possible to add a progress bar to the taskbar icon of a Windows Forms App? [duplicate]

Windows 7 has an AWESOME new feature that applications can report the progress of the current activity through the status bar. For example, when copying file(s) using Windows Explorer, a progress bar is layered on top of the application icon in the task bar and the progress is shown as it updates.
What is the API for exposing the progress bar? Is there MSDN documentation on it?
For below .NET 4, or WinForms in any .NET version
Using the Windows API Code Pack from Microsoft (as Keeron mentioned), it's really simple. You just need to use the TaskbarManager. E.g.
To start the progress:
TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal);
To update the progress:
TaskbarManager.Instance.SetProgressValue(currentValue, maxProgressValue);
And when when you're done, to end the progress:
TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);
There is more you can do, but that should get you started and might be all you need.
For .NET 4 and above with WPF
You can use System.Windows.Shell.TaskbarItemInfo. E.g. in the Xaml for your main window, you'll need to add:
<Window.TaskbarItemInfo>
<TaskbarItemInfo x:Name="taskBarItemInfo" />
</Window.TaskbarItemInfo>
Then to update the progress, you would do something like:
taskBarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
for (int i = 0; i < 100; i++)
{
taskBarItemInfo.ProgressValue = i / 100.0;
Thread.Sleep(50); // whatever the 'work' really is
}
taskBarItemInfo.ProgressState = TaskbarItemProgressState.None;
Don't forget that if you're doing the 'work' on a background thread (which is probably a good idea for long running tasks), you will need to switch back to the UI thread to update the taskbar.
There's a good article in MSDN magazine about the new taskbar APIs. And yes, the feature is awesome :-)
Essentially, it's all about implementing IFileOperation. There's a good article about using it in managed code here.
If you plan to use other Windows 7 Taskbar features, another approach would be to use the library from Microsoft: Windows API Code Pack for .NET Framework which is no longer available at the old link, but can be found on nuget.
I've written an article about implementing the Windows 7 Taskbar progress API in C# (see: Windows 7 Taskbar Progress Bar with C# and .NET). The control is open source (BSD) and has example projects for C# and VB.NET.
This way you don't have to convert the C++ code from scratch.
Actually I use Telerik's RadWindow which you cannot just use <telerik:RadWindow.TaskbarItemInfo>. So I use this workaround for net6.0-windows WPF:
In code behind file I made a property:
public Lazy<TaskbarItemInfo> TaskbarItemInfo { get; set; } = new Lazy<TaskbarItemInfo>(() =>
{
return System.Windows.Application.Current.MainWindow.TaskbarItemInfo = new TaskbarItemInfo();
});
In method part of BackgroundWorker
private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
I set the value of the progress:
TaskbarItemInfo.Value.ProgressState = TaskbarItemProgressState.Normal;
TaskbarItemInfo.Value.ProgressValue = (double)progressUserState.ProgressInPercent / 100;
In
private void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
I reset the state:
TaskbarItemInfo.Value.ProgressValue = 0;
TaskbarItemInfo.Value.ProgressState = TaskbarItemProgressState.None;

Use Qt 5 Wayland QPA plugin to set window transparency with wl_surface

I have three Qt 5 applications that work fine independently on the BeagleBone X-15 using the Qt 5 Wayland plugin on the TI SDK image.
When I launch them, they fill the whole screen so that the first app launched is covered by the second, and the second app is covered by the third.
How can I modify the transparency of the second and third app launched, so that I can see some of the view from the first app launched?
I tried modifying the window opacity with Qt’s setWindowOpacity, but the Wayland plugin says: “Window Opacity not supported by this Plugin.”
Qt 5 on Wayland page says:
Qt 5 is structured with the Lighthouse (or Qt Platform) Abstraction, which is the windowing system and device agnostic architecture. That means Qt can load in run-time different backend plugins for different window systems as desired. For instance, an application developed on Qt could be run using "-platform xcb" and "-platform wayland" for XCB or Wayland respectively (or set the QT_QPA_PLATFORM environment variable) and should have a similar behavior on both systems, without the need to recompile.
Qt abstraction exposes to applications developers two native resources of Wayland: wl_display and wl_surface. With those types, one could access Wayland internals to deal with special cases through the interface:
void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
Getting the display global handler is quite straightforward, as shown in the following example:
QPlatformNativeInterface *native =
QGuiApplication::platformNativeInterface();
struct wl_display *wl_dpy = (struct wl_display *)
native->nativeResourceForWindow("display", NULL);
and for wl_surface:
QPlatformNativeInterface *native =
QGuiApplication::platformNativeInterface();
struct wl_surface *surface = static_cast<struct wl_surface *>(
native->nativeResourceForWindow("surface", this->windowHandle()));
If I get the handle to this wl_surface, how can I change the transparency directly?

Get Windows version in WinRT, Windows8(10) application

The question is straightforward.
I am using VB.Net to develop Windows8.1(+10) application.
And, I want to detect if the OS version is 8.1 or 10. Not even want to know other versions like XP, 7 and 8.
BUT, Environment.OsVersion is deprecated,
cannot access into Registry in Windows8 APP(it's a policy even it's possible),
cannot generate custom manifest(blocked) file to retrieve version info,
cannot use 'Kernel32.dll'(policy problem) to extract.
How can I get the Windows version in Windows8.1 or Windows10 Store application?
Thanks.
Appended:
I want to retrieve Windows version (whether it is 8.1 or 10)
which is important for manipulating Live Tile.
not altering critical behavior or something mentioned in comment.
the Windows metro app provides slightly different method to pin tiles in Start Menu, which is very annoying to handle without knowing Windows version. Anyway, it is not the main topic.
VB.Net or C# code would be very appreciated.
It is not a 'give me the working code' thing.
This issue is not just on me,
it is also ongoing topic on other sites:
http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
http://www.vbforums.com/showthread.php?776481-Get-OS-version-Windows-8-1-does-not-detect
only thing is that either the solution is based on C++ or not applicable to Windows 8.1(metro app).
Thanks.
What you should be doing is checking whether the new methods are available. If they are available, use them, regardless of the operating system version. Example:
if (Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.UI.ViewManagement.ApplicationView", "TryEnterFullScreenMode"))
{
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
}
I didn't find any other way to do this, so here's my approach. (it's in C#, but you can easily translate it to Visual Basic)
The following property IsWindows10 detects if a Windows 8.1 or Windows Phone 8.1 app is running on a Windows 10 (including Windows 10 Mobile) device.
#region IsWindows10
static bool? _isWindows10;
public static bool IsWindows10 => (_isWindows10 ?? (_isWindows10 = getIsWindows10Sync())).Value;
static bool getIsWindows10Sync()
{
bool hasWindows81Property = Windows.ApplicationModel.Package.Current.GetType().GetRuntimeProperties().Any(r => r.Name == "DisplayName");
bool hasWindowsPhone81Property = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().GetType().GetRuntimeProperties().Any(r => r.Name == "RawPixelsPerViewPixel");
bool isWindows10 = hasWindows81Property && hasWindowsPhone81Property;
return isWindows10;
}
#endregion
How does it work?
In Windows 8.1 the Package class has a DisplayName property, which Windows Phone 8.1 doesn't have.
In Windows Phone 8.1 the DisplayInformation class has a RawPixelsPerViewPixel property, which Windows 8.1 doesn't have.
Windows 10 (including Mobile) has both properties. That's how we can detect which OS the app is running on.

Windows Phone ThemeManager

is it possible to for example - write a background service, which randomly changes the windows phone theme, I mean is it possible to access the windows phone theme under settings via code? and change it?
if so can you please give me an example of the API's I can use or additional libraries I can dl
thank you
Unfortunately you can't. It is not possible to change the Windows Phone theme by code. The only one who can is the user. This is part of the Windows Phone concept.
The only thing you can do is defining themes that are used in your own apps.
Sorry for the bad news...
You are allowed to change the theme for your application. There is a Nuget package available that makes this even easier. You could accomplish changing it in a background task by setting a property that you check when the app opens.
// background agent code
// get random value
IsolatedStorageSettings.ApplicationSettings["Theme"] = randomValue; // this is just a string or something simple
IsolatedStorageSettings.ApplicationSettings.Save();
When your app opens, you would check this value
var theme = "Standard";
if(IsolatedStorageSettings.ApplicationSettings.ContainsValue("Theme"))
{
theme = IsolatedStorageSettings.ApplicationSettings["Theme"];
// Set the theme
}
You can modify the source of the Theme Manager by downloading the source from github. Here is some more info on the Theme Manager. If you would like to change values yourself, you can accomplish this by setting the resource values when the papp starts
((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = myAccentBrush;
((SolidColorBrush)Resources["PhoneBackgroundBrush"]).Color = myBackgroundBrush;
((SolidColorBrush)Resources["PhoneChromeBrush"]).Color = myChromeBrush;
((SolidColorBrush)Resources["PhoneForegroundBrush"]).Color = myForegroundBrush;

Why does Trace.WriteLine("Test") not appear when targeting .net 4.0 but does when 3.5

I have just noticed that when i call the following code from a console app
for (int i = 0; i < 10; i++)
{
Trace.WriteLine("Logging");
Debug.WriteLine("Logging Debug");
}
if I am targeting .net 4.0 no messages appear in the debugview app although I am capturing all outputs.
If I change to target 3.5 it appears fine.
What's changed and how can I fix it?
This is actually by design.
From Microsoft Connect :
The CLR has a new debugging
architecture where the CLR is native
debugging the application even when
managed only attached, and therefore
MS-SysInternals DebugView will not
work.
Are you doing this on the same machine?
It could be that the debug viewer (assumed DbgView from Sysinternals) is not connected. Check the title of the debug viewer for the name of the machine you're connected to.
This fixed the problem for me:
Trace.Autoflush = true;