Specifically, what I am try to is overlap my element on top of everything, including the desktop, similar to the taskbar in Windows. I have a Windows Form Control that looks kind of like a tab. its like 50px wide by like 150px in length. What I would like to do is have that control appear in front of all windows, including the desktop itself. I say "dock-like" because I belive docking pushes windows over (so if my tab was docked, it would push any full screen application window over 50px), which is not what I'm trying to do. I want my tab to overlay on top of everything. The closest example I can think of is Winamp. Winamp can dock to the top of the screen and it is always on top of any application.
how can do this in C#?
System.Windows.Forms.Form has a property, TopMost, which will cause the form to stay on top of other windows.
The "snapping" behavior of Winamp can be implemented by using the Move event of the form--when the form is moved close enough to the edge of the screen, programatically set the position so that it's on the edge.
Related
I'm working on an app in c# windows forms, I have a form called Form1 with a button, and after click this button the idea is to take a screenshoot of everything behind it except the Form1 itself (without minimizing Form1).
Any idea or suggestion?
Thank you!
If you want a solution without hiding, moving, minimizing etc., you need the following approach:
EnumWindows() to iterate all windows. This will give you the windows top to bottom.
Don't forget to exclude your own window
Exclude windows that are invisible. Check out GetWindowLongPtr with GWL_STYLE and compare against WS_VISIBLE
GetWindowRect() to get their size
PrintWindow() to get a bitmap of the window, no matter whether it's in the background
Create a bitmap with the size of the VirtualScreen
Paint the windows in reverse order (bottom to top) using DrawImage()
I found that this is quite fast (514 ms on a 2560x1440 screen with 20 visible windows to draw).
Limitations:
since it sends a WM_PRINT message to the application, you can not capture applications that are "not responding"
For me, Firefox does not render well. It's missing page contents.
For me, control panel content appears black, although it's there when getting a screenshot of the whole screen.
you can use hard code. Actually light shot and other tools working such as. When you click to screenshot button you may close the form window after the event and reopen it. it is the basic way of solution...
Please check this way: How can i capture the screen without the Form?
I'm planning the development of a fairly simple app and have little experience with UWP, some with Winforms. I'd like to make it so that the user can dock the app (similar to the taskbar, but the size of a browser tab) to the edge of the screen and allow it to slide in/out on click or hover. Searches have turned up nothing (maybe I'm not using the right terms) and I've yet to see this functionality on a Windows 10 app.
I'm thinking that I could just force the window to be offscreen or have a 0 width. But I'm not certain how to make a tab appear when that happens. Would I make a second window that is the tab?
All constructive thoughts and ideas are welcome.
I'm trying to create a windows form app that "owns" the top area of a screen. Think of it as just a rectangular form width = screen size and height = 20px or so. The app would always be on top and would be borderless (i.e. FormBorderStyle=none). The questionable part, for example, if a user maximizes a window like chrome or some other application, it should treat the bottom of this windows form app as the top of the screen. This way since the form app is always on top, it doesn't cover up any of the maximized application's window.
Any clues on how to do this.. can it be done with windows forms? The only questionable part is how to "own" a portion of the screen.
Let me know if clarification is needed. Thanks in advanced.
What you need is to set the Screen.WorkingArea which is readonly you should use PInvoke to achieve this you can find your answer in this thread
To get the working area of the display you can use Screen.WorkingArea property
I'm working on a class that descends from the WPF Window class that implements the Application Toolbar functionality available in the Window 7 + shell (that is, it calls the Win32 SHAppBarWindow to dock to an edge of the desktop and undock). The idea is that you can drag the window around the screen and when it is within some distance of a desktop edge, it docks itself.
Because of the need to call the Win32 SHAppbarWindow function, and because working through WPF events is just not helpful, I've written a window procedure that works at the Win32 level & is hooked in using the HwndSource.AddHook method. This procedure gets called first and processes anything it needs to process, and passes the rest on to WPF.
I've been working on the dragging logic and I'd like to give the user a visual indication that the window could dock itself to the edge it's closest to, without actually docking it. To that end, I'd like to display a transparent rectangle with a dashed border the size that the window would be after docking in the location it would be. If the user releases the left mouse button at that point, then the window would actually be docked at that edge. Once the mouse is moved away from that edge, the rectangle would go away.
I know how to compute the rectangle's size & location. But how do I display the rectangle? I'm pretty sure I'd have to do it with GDI32 calls, as the target area is outside the window's nonclient & client areas. But how would I draw the rectangle, without messing up the other windows that might be in that area?
I see that many applications do not have a title bar, but still have the window controls in the upper right corner. These are also styled differently than the normal windows form controls. Is it possible to achieve this effect in WPF?
Here are some examples:
Zune Desktop software:
http://i548.photobucket.com/albums/ii356/elpedrogrande/btns2.gif
Photoshop:
http://i548.photobucket.com/albums/ii356/elpedrogrande/btns3.gif
GoTo Assist:
http://i548.photobucket.com/albums/ii356/elpedrogrande/btns1.gif
They do this by setting the window style bits so it is created without a title bar. And then draw their own, making it look like a custom one. Which is the main reason that all these programs have caption glyphs that are not identical.
You'd accomplish the same in WPF by setting the WindowStyle to None. And a whole bunch of code to get back the behavior that Windows implements automatically with the title bar. Google "WM_NCHITTEST" to find out more.