Force WinForm Application on top Windows 10 Tablet Mode - winforms

Is there any way to force a simple winforms application to run on top the tablet mode main screen ?
It can be Vb script or anything, the idea is to show a count down application on top the main screen to announce the upcoming "force shutdown" of that tablet.
screnshot

Whoever face the same problem, there is a "hack" I was reading about.
When on tablet mode, your application will be start as "minimized" in the taskbar, therefore you will not be able to see it, just a "Home screen".
What worked for me was adding to my Form_Load event the SendKey Function, with alt + tab.
That, mixing with #EpicKip answer just above, will always send the app (even when on start screen of "Tablet Mode" and the app on "Minimized").
private void form1_Load(object sender, EventArgs e)
{
//SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
Thread.Sleep(1000);
SendKeys.SendWait("%{TAB}");
}

Related

android.view.WindowLeaked: Activity has leaked window android.widget.ZoomButtonsController$Container that was originally added here

Working with maps i have an activity which is launched when no connection is available and uses offline maps (MapQuest). The activity runs fine, map is shown, and all overlays, markers and so on. When the user clicks on one of the markers info window another activity is launched and at this moment i get a bunch of red error messages in the log, though the app does not crash. These messages (the init is in the title) seem to talk about the ZoomButtons and touch events. As for ZoomButtons or touch events (multitouch) in the code, there are only 2 lines :
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
and not any dialog…
if i write:
map.setBuiltInZoomControls(false);
map.setMultiTouchControls(false);
the red error messages disappear but of course the user cannot zoom in or out in any way…
As the error (with the "true" parameter) occurs only when launching another activity i thought that i have to add something in on pause() ie:
onPause(){
map.setBuiltInZoomControls(false);
map.setMultiTouchControls(false);
super.OnPause();
}
---- but doing so does not change anything…
Any hint??? - Thanks in advance!
Add this to your activity:
#Override
public void finish() {
ViewGroup view = (ViewGroup) getWindow().getDecorView();
view.removeAllViews();
super.finish();
}
I was having the exact same problem... thanks to you pointing out that it is caused by (likely) when the zoom controls are still visible. I tested it, and that was correct. When I pressed the back button with the zoom controls showing, it would show that leak error, if I waited until the controls faded away (they do after you stop scrolling), then there was no leak error.
A little research in WebSettings provided a method that doesn't show the zoom controls, which means it doesn't leak at anytime you want to press the back button. It does still zoom with the pinch effect though. The only disadvantage to using this method is that your controls won't show. But to me, that's worth it, since most users know about pinch zoom for all apps.
Here is what I used:
// make sure your pinch zoom is enabled
webView.getSettings().setBuiltInZoomControls(true);
// don't show the zoom controls
webView.getSettings().setDisplayZoomControls(false);
The problem with this leak window does not appear in the following version of Android 3.0 , so,you can try to do :
// enabled zoom support
getSettings().setSupportZoom(true);
getSettings().setBuiltInZoomControls(true);
// but,We should hide this button, otherwise in the version
// of Android 3 and above, there is a window leak.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// call requies API Level 11 ( Android 3.0 + )
getSettings().setDisplayZoomControls(false);
}

Rendering issue in WPF window while dragging

I have WPF window in which my Direct3D engine render. WPF Window I start from my engine, which I develop on C++/CLI.
I have 2 displays and when I move window between them, part of the window became white and not update until I am not stop dragging it (like on screen shot).
Does somebody know how to fix this issue?
It will be hard to post code here as it is a lot of code, but I will try:
I use managed C++ and unmanaged in one project:
So, I add .Net dll`s to have access to the WPF window:
Window^ wnd = gcnew Window();
wnd->Width = 1280;
wnd->Height = 720;
wnd->Show();
WindowInteropHelper^ helper = gcnew WindowInteropHelper(wnd);
HWND WPFHwnd = (HWND)helper->Handle.ToPointer();
HINSTANCE hinstance = (HINSTANCE)Marshal::GetHINSTANCE(this->GetType()->Module).ToPointer();
engine->SetHisnstanceHWND(WPFHwnd, hinstance);
engine->InitializeSystem(wnd->ActualWidth, wnd->ActualHeight);
engine - this is unmanaged class which incapsulates all work with rendering.
Further it is a stardard d3d rendering loop. Nothing special.
It render OK, but when I resizing or move window, it draw a part of it like this (with white). When I stop resizing or moving - all OK again.
My question is: is it possible to get rid of this effect or not?
UPDATE:
I hooked the wndProc if the WPF window and try to use UpdateLayout() when size changing, but this has no effect. Seems window is not react on any intervention.
Well, it sounds like your engine is receiving WM_ERASEBKGND and it clears the window. After you release the window, it sends WM_PAINT and everything is clear again. That's what I believe might be happening.
In order to test this theory, you can handle that message and return true. Put that to your engine message handling routine:
case WM_ERASEBKGND:
{
PAINTSTRUCT pss;
BeginPaint(hWnd,&pss);
EndPaint(hWnd,&pss);
return true;
}
You can use WinSpy++ to check out what messages are delivered to underneath window. If you want to see why the background is whited out, you can do it through ProcessMonitor and see what API calls are being issued. You're probably interested in API calls that include the color white.

How can I use a meter-style progress bar?

In Vista/7, the Windows Explorer shell window makes use of a special kind of static progress bar to display hard drive space.
With default styles, this bar is blue colored and non-animated. It also turns red colored when it gets close to being full (low disk space).
Using messaging, I can tell the Windows Forms ProgressBar control to update its state to Paused and Error (yellow and red colored, respectively), which works fine, but these are still specific to progress.
In the Windows User Experience Guidelines, it specifically points out this "meter" variant of the Progress Bar:
This pattern isn't a progress bar, but
it is implemented using the progress
bar control. Meters have a distinct
look to differentiate them from true
progress bars.
They say it "is implemented using the progress bar control", so... how? What message could I send to the control to have it behave this way?
I've seen that you can send messages for setting the bar color, but the documentation says these calls are ignored when visual styles are enabled. Nothing else in the Windows API documentation for raw ProgressBar controls seemed to suggest a way to do this. Am I just stuck making a custom drawn bar? I'd really like to utilize the OS whenever possible so that the application will appear consistent throughout different OS versions. I realize that pre-Vista versions probably won't support this, though.
I'm looking for a Windows Forms solution, but I wonder if it is even exposed at all via Win32 API.
It is possible, but not through ProgressBar. Nor does Win7 use a PB to draw those meters, there is no window handle associated with the bar. It must be using custom drawing. That's possible in WinForms as well with the VisualStyleRenderer class. One thing that doesn't help however is that the required visual style parts and states are not declared, not even in .NET 4.0.
This sample form reproduces the meter bar:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.ProgressBar.Bar.Normal);
protected override void OnPaint(PaintEventArgs e) {
renderer.SetParameters("PROGRESS", 11, 2);
renderer.DrawBackground(e.Graphics, new Rectangle(10, 10, 200, 15));
renderer.SetParameters("PROGRESS", 5, 4);
renderer.DrawBackground(e.Graphics, new Rectangle(10, 10, 100, 15));
}
}
}
I got the part and state numbers from the vsstyle.h SDK header file.

Adding a minimum display time for Silverlight splash screen

When hosting a silverlight application on a webpage it is possible to use the splashscreensource parameter to specify a simple Silverlight 1.0 (xaml+javascript) control to be displayed while the real xap file is downloaded, and which can receive notification of the downloads progress through onSourceDownloadProgressChanged. If the xap file is in cache, the splash screen is not shown (and if the download only takes 1 second, the splash screen will only be shown for 1 second).
I know this is not best practice in general, but I am looking for a way to specify a minimum display time for the splash screen - even if the xap cached or the download is fast, the splash screen would remain up for at least, let's say, 5 seconds (for example to show a required legal disclaimer, corporate identity mark or other bug).
I do want to do it in the splash screen exclusively (rather then in the main xap) as I want it to be clean and uninterupted (for example a sound bug) and shown to the user as soon as they open the page, rather then after the download (which could take anywhere from 1 to 20+ seconds).
I'd prefer not to accomplish this with preloading - replacing the splash screen with a full Silverlight xap application (with it's own loading screen), which then programmably loads and displays the full xap after a minimum wait time.
Its a little known fact that the splash screen remains in place beyond the time that XAP takes to load. It doesn't get replaced until the application RootVisual loads. Hence if you don't assign the RootVisual in the application Startup event the splash screen displays forever.
Hence you can delay the display of the splash for a few seconds using code like this:-
private void Application_Startup(object sender, StartupEventArgs e)
{
var timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(10);
EventHandler eh = null;
eh = (s, args) =>
{
timer.Stop();
this.RootVisual = new Test();
timer.Tick -= eh;
};
timer.Tick += eh;
timer.Start();
}
This can be simplified with the Reactive framework:-
private void Application_Startup(object sender, StartupEventArgs e)
{
Observable.Timer(TimeSpan.FromSeconds(10), Scheduler.Dispatcher)
.Subscribe((l) =>
{
this.RootVisual = new Test();
});
}
However the Reactive framework adds at least 66KB to the size of your Xap so only use it you are already using the Reactive stuff for other things.
Note that if you were only interested in extending the display time of the splash screen during development then it is very simple to add a Fiddler rule which delays the response off the Xap file.
This is an example of a rule that would have this effect. See Pedro Forte's post for details on how to apply the rule - it is really very easy!
if (oSession.uriContains("Midwinter.ReasonableBasis.Client.xap")){
oSession["ui-color"]="orange";
oSession["ui-bold"]="true";
//Delay received data by X ms per KB downloaded.
oSession["response-trickle-delay"] = "10";
}

WPF application window appears on top of SplashScreen

I followed the simple steps outlined at How to: Add a Splash Screen to a WPF Application to add a splash screen to my WPF application. When I start the application, the splash image is shown, then the main window pops up, and the splash image fades away.
My problem is that when the main window pops up, it appears on top of the splash image. Then when the splash image begins to fade out, the splash image pops up to the top again. The end result is that the splash image disappears for a split second as the main window appears.
How can I force the main window to appear under the splash image, so that the splash image does not disappear?
In .NET 4.0 an overload has been added to the Show method that allows to set the window style WS_EX_TOPMOST on the splash screen window. Show the splash screen in code like this:
SplashScreen splash = new SplashScreen("SplashScreen.png");
splash.Show(autoClose: true, topMost: true);
I call that from the method
protected override void OnStartup(StartupEventArgs e)
in App.xaml.cs.
"SplashScreen.png" is of course the identifier for your splash image embedded in the application's resources.
This isn't default behaviour you must have some code thats manually focusing the main window?
It may be easier just to turn off the fade manually with a bit of code like this:
_splash = new SplashScreen("LoadingScreen.png");
_splash.Show(false);
_splash.Close(TimeSpan.Zero);
Not sure if this will help, but if you set the owner of the Splash screen to the current form, then this should maybe do the trick?
_splash.Owner = this;
Otherwise you can look here:
Splash Screen Example
This might help too.

Resources