Possible to intercept "unminimize" event on windows? - windows

Is it programmatically possible to intercept the maximize/restore event on Windows such that when you click on a minimized button on the taskbar, it asks you for a password?
Update: To clarify, I'm asking if it is possible systemwide. For example, I may pick a browser/im/editor window that I want to secure if I need to walk away from the machine for a few minutes.

It is possible to capture a "SizeChange" event. I don't see anything specific to Minimizing/Restoring.
With .NET (C#), you'd do something like this:
private void Form1_Load(object sender, EventArgs e)
{
// Tie in a new event handler.
this.SizeChanged += new EventHandler(Form1_SizeChanged);
}
void Form1_SizeChanged(object sender, EventArgs e)
{
if(WindowState == FormWindowState.Minimized)
MessageBox.Show("Window is now: " + WindowState.ToString());
}
If you can be more specific as to which language you are using, perhaps me or someone else can better answer.

Well, you could write a program that deep hooks the target program.
Seriously, however, if I can walk up to your computer and encounter that you got away lucky the first time. Next time I'll be back with a powerful tool to read disk files, scrape memory, or worse.
Winkey+L, dude!

Related

Ways of detecting Windows Phone idle

I want to perform some calculations while the phone is in locked screen mode, regardless if the app is on the foreground or the background.
I know that in order to do this, I need to use OnObscured event from App class. However, it is only launched when the app is in the foreground, but not in the background.
So, I would like to know if exist any way to detect the phone state while the App runs the background.
I have thought something that would be crazy, but is to access an API property which is not allowed to use while the phone is in locked screen, and then catch the exception and, with that, get if the phone is active or sleeping.
I am open to hear new ideas.
I figured out a simple thing - maybe it will help you:
I assume that you already disabled Idle Detection to run your calculations in background.
So why not to create the variable in which you hold the state of the App? Since you have to launch first your App, so it goes to foreground and when Obscured is called and IsLocked = true, set the variable. Then you can check it whenever you want:
public MainPage()
{
InitializeComponent();
App.RootFrame.Obscured+=RootFrame_Obscured;
App.RootFrame.Unobscured+=RootFrame_Unobscured;
}
private bool AppIsLocked = false;
private void RootFrame_Unobscured(object sender, EventArgs e)
{
if (AppIsLocked) AppIsLocked = false;
}
private void RootFrame_Obscured(object sender, ObscuredEventArgs e)
{
if (e.IsLocked) AppIsLocked = true;
}
Is this what you searching for Running a Windows Phone Application under the lock screen?
This article describes - how to avoid tombstoning. But you can't do a lot of work under lock screen.

How to get the position of touch in a simple windows phone 8 app?

I am making an app for windows phone 8.
On one of the pages of the app, I want to get the co-ordinates of the touch.
I tried searching on net but I got results related to games.
I want to know is it possible to get the position of touch on canvas/or any other component in a simple app.
If yes, plz guide me through it.
Hook up to Tap event of the Control, and use GetPosition of event args.
<Canvas Tap="HandleTap/>
private void HandleTap(object sender, GestureEventArgs e)
{
Point point = e.GetPosition(null);
}

Showing message without any buttons in Windows Phone

I would like to create an info message box in Windows Phone.
It should look like a single text message, that's shown on screen for X seconds, and I doesn't have any confirmation buttons
as MessageBox.Show() does. It would be used to show user some messages about the app progress, like "file download started",
or "preferences saved".
I've tried to create something like that, using Popup element, but it seems a bit different of what I want to
make.
With the popup I can create something like that
canvas.MouseLeftButtonUp += new MouseButtonEventHandler(popupCloseEvent);
For example, which closes this popup when user taps it.
or something similar. (Maybe can implement a timer there to close it after a few secs)
Are there better ways to create such thing?
You could use the either the Message Dialog or Overlay controls in the Coding4Fun toolkit.
Found here: http://coding4fun.codeplex.com/
They are really simple and easy to use controls.
Try this
In Xaml:
<Popup Tap="Popup_Tap"></Popup>
In code behind:
private void Popup_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
(sender as Popup).IsOpen = false;
}
I hope it helps.

ListBoxItem background color

I want upon selection to change the background color of the item, however i can't seem to find a way to do it.
I'm trying to use the code below but can't find the completion for it, and i need to set the colror to a custom one such as "#8e8e8e":
private void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (list.SelectedItem != null)
{
ListBoxItem a = sender as ListBoxItem;
//a.Background=
PhoneApplicationService.Current.State["test"] = list.SelectedItem;
NavigationService.Navigate(new Uri("/Detail", UriKind.Relative));
}
list.SelectedIndex = -1;
}
So i need to chnage the selected item background color to #8E8E8E from C# for simplicity because changing the states seems a bit complicated especially that all i need to do is change background color of the selected item.
Thanks in advance,
Although not recommend like Matt already pointed out you should be able to achieve this by using ControlTemplates and Visual States. Check out this article on windowsphonegeek to see how: Part 1 Part 2
Please let us know if you encounter any problems
You should look at the visual states for selected items if you wish to do this.
However, standard behaviour for Metro apps and recommended design best practices advise not to use colour to indicate selection in anythign other than the ListPicker.
Without seeing your app, how you're using the ListBox or the purpose of indicating selection it's hard to advise further though.

ImageMap behavior for tiles

Is it possible to determine the area on which a user clicked on a tile? Just like an image map in HTML. I would like to specify two buttons at an image tile and carry out different actions for each of them.
No. It is not possible to do this.
With respect of lauching your app, the tile works just like a shortcut on your PC desktop.
If you really need the behaviour you describe you'll have to create 2 applications - 1 for each launch action.
You can use something like this for every UI element.
private void ListBox_MouseEnter(object sender, MouseEventArgs e)
{
string pos= e.GetPosition(CanvasForLoop).X.ToString();
}

Resources