I need to create a application which is similar to those we will get when we buy a laptop. It will be visible only when the mouse pointer reaches the top of the window. So how can I able to do this using C# 4.0 ?
http://www.notebookcheck.net/uploads/pics/win2_12.jpg
this link u can see the application. I need to create such type
Any idea pls share. Thanks
I suppose there are several different ways to achieve this effect:
You can place part of the window of your application above the visible screen, so only a part of it is visible (let's say you can see only it's bottom). Then you need to handle events when mouse enters (MouseEnter) and leaves (MouseLeave) the form to move the form up and down.
You can use a background thread to call GetCursorPos method at a set interval (i.e. each 500ms) second to check where currently the mouse is. See this link for more information about it and a sample code: http://www.pinvoke.net/default.aspx/user32.getcursorpos.
(If you need only to check the mouse position, you can use a timer to simplify you application.)
When you hit what's possible with C#, you can always start invoking native code - such as the windows API. Since you don't ask a specific question, I'll leave you with:
Position your app where you want it to appear and hide it.
Capture mouse position with windows api (see this SO answer)
When mouse is at screen corner / top, etc; make your app visible.
Now make sure all this works with dual screen setup, and you are done.
Related
How, on Windows API, is it possible to draw outside the bounds of a window (not just outside the client area)?
I need to be able to draw a drop shadow, a color glow or any other custom design outside the bounds of a window, so I can implement a complete custom window theme design with outer glows or drop shadows. My question is about how to be able to achieve that on the Windows API.
On my searches, I found that some developers use to combine a "ghost" window behind the actual window, so it is possible to draw a shadow or anything on it, while for the user it seems that there is only one single window. Is it a good way of doing what I need?
Well, to accomplish that, I would like to know what functions on the Windows API I need to use to make that "ghost" window to not appear as a separate window when I click on Alt+Tab or Windows+Tab, and basically to make that "ghost" window really a ghost.
I will be doing that on WPF using C#, but the question is really more related to the Windows API, independently of the framework.
Thanks in advance!
Create a headless window (without the _ [] X), make it transparent, and inside create a fixed frame (a frame is a rectangle that can contain other things). So 1 window 1 frame and around that frame you can add more frames tha contain semi transparent stuff to create shadow effect.
The main headless window has to be big enough to draw all that inside. If you only create 1 window (all other things be frames or other widgets) there will be no problem with Alt Tab.
Inside the fixed frame you can create again the (_ [] X) buttons to give the illusion. The API exist for this and can then be bound to these buttons.
PS: There might me more than one solution
Well, the project has moved along rather nicely and we have a pretty darn good product, but a wrench has been thrown into the gear works.
We have a C# 2012 application that interacts with another application (written in VB 6 of all things) and we can do a good bit with it so far, but we have a problem.
We need to select a button on a toolbar at the top of this particular application's window, but the button is not available through an API search. We have the main window's handle and can see all of its children, but I think the Toolbar is a User type control that we can't access through the API Calls. This application is very poorly designed and we had to do a LOT of work just to discover TWO User ID text boxes on the logon screen.
Anyway, my question is this: How would I set up a call to the main window and click a certain X, Y coordinate of that window's viewable area? I am using SendMessage to send mouse clicks to press a button control already, but if I can't get access to that button control, the idea was to send mouse clicks to a specific coordinate of the window.
Any ideas folks? Thanks!
It looks like the solution will be to get the Window's rectangle and add the offset in order to use the mouse event API call.
Thank you to #Idle_Mind for the suggestion. It is at least working on our test environment. It will be next week before we can test the solution out in our client's environment.
I am currently working on a desktop C# WPF application where the goal is to make it look and feel like a "real" Windows Store App.
I want to add an appbar that should be shown when the user swipes up from the bottom. To do this in a normal app you just position your finger outside the screen area, and swipe up.
But if I do that in a fullscreen WPF program I don't receive any TouchDown or TouchMove events - probably because the finger is already down when entering the actual screen area.
I have tried with the Manipulation framework also, but same result here. Even when I hook directly into the message queue using WndProc or other hooks I get no events at all.
The funny thing is that I can see the "touch cursor" move around the screen, so at least something in the underlying framework is notified.
Does anyone have an idea how to do this?
p.s. It is not an option for me just to use a windows store app instead, because of hardware connectivity issues ;-)
You will need to keep track of the cursor location coordinates, and see when the cursor (swipe) starts at the edge of the screen and moves in. When that triggers (with whatever trigger you want, distance covered most likely) you can fire up your Appbar.
There was a similar question asked on MSDN:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d85dcde7-839a-44d3-9f2a-8b47b947576c/swipe-gesture-and-page-change?forum=wpf
Is there a way to know the universal coordinates of the point?
I mean the following:
we have the button which could be pressed by clicking (500;500) when application maximized;
if it possible to know which point to click to press the button when the window of application is 600x600;
And so on. Is there any function to calculate such a point?
Thanks in advance!
I don't think there is a general function, since any developer could change the appearance based on screen size.
However, different approaches may work:
Somehow get a handle to the button/element of interest, then just call its clicked command, or use that handle to get the coordinate position on the screen.
For instance, with Web pages, you can get the specific HTMLElement by name (or id) and then work backward from there.
If it is a Windows Form application, you can actually get a handle onto the window of that application, and then get the desired element/component by walking through them all.
Create a list of the button locations under different maximization/restorings/movings and calculate the function from that. (Perhaps make a computer program to help with this).
As a last-resort, like for applications which randomly move their buttons around to confuse bots (I can't think of any real life examples), you might need to do image analysis on a screenshot.
The spy++ tool in/for Visual Studio has a finder tool that can help get the window/element names of windows applications.
Is there a way to create a window (similar to a screen-saver) that will be displayed once your running application is not 'interacting' (or being idle) with the user, meaning to say, no mouse movements happening on the application.
Some of my friends suggested to use a Timer for this one. Any suggestion for a good head start? Thanks.
If your looking to create your own screensaver just create another form. Remove the border from the form. Make it the top most and start maximized. Then you just paint the control to do whatever you want.
Then wire up the form to check if the mouse moves or a key is pressed. You'll need to create a timer that will determine if the screensaver should be shown.
This might help: http://www.codeproject.com/KB/miscctrl/csharpscreensaver.aspx.
There's a similar question on StackOverflow here: How to invoke the screen saver in Windows in C#?.