WaterMark using c# - c#

I am working on a Kiosk application. There is a Maintenance mode in my application. When my application enters into Maintenance mode, i want to show the user a watermark "Maintenance Mode Commenced".
I want this watermark to be shown through out my desktop. No matter what form is in focus. Is this possible ? Any ideas....
Note : This is Windows application using c#

If your OS is Vista or Win7, can't you make a create a window that toplevel + translucent + maximized? Then the entire screen can say "MAINTENANCE MODE" in large friendly letters.
Here's some C# code that might help. I think what you want to do is called "alpha blending". (Haven't done it myself.)
Here's some more.
This may be best, I'm not positive.

attach to the paint event of each form (maybe create a base form for all other forms to inherit)
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx
you can draw your image using the graphics object provided in the handler.
Take a look at the first answer with code here:
http://bytes.com/topic/net/answers/118600-how-eliminate-tiling-windows-forms-background-images

Related

Take a screenshot behind window in C# WinForm

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?

How does Chrome and other apps override the default windows forms borders?

There are some programs such as Google Chrome and this:
They have a windows forms border that is different than the default. How do these programs do this and still allow the user to drag the window around? Is it possible in C#?
There are plenty of component suites (DevExpress, Infragistics, Telerik, etc.) doing this but you can do it on your own as well. But prepare to get dirty - really dirty!
Basically you have to catch the windows messages (yes, native!) and handle them properly. To make the form draggable is the easiest thing in this chapter (you just have to tell windows that the mouse is over the titlebar area even if it is not >> see here on CodeProject).
Let me get back to the painting: Don't do it!
There are so many things to handle ...
is your form maximized, minimized, normal state
which of the buttons (min/max/close) are enabled?
is it a tool window or a sizeable one?
is there a help button?
is the form sizeable? if so, you have to draw that border as well ...
... and so many more.
In addition, painting in the non-client-area is not as easy as painting usercontrols with a Graphics object. And even if that does not scare you by now, you might probably find yourself breaking the layouting logic of your forms' controls because the forms' size is the same as its ClientSize.
So, please consider to use DevExpress or any other toolkit. Speaking of DevExpress - I knew there was a free set of their fantastic controls and I'm pretty sure that the XtraForm (which does all the titlebar painting) is included as well.
Save big parts of your life and skip that chapter.
(However, if you're brave enough, check this article to do it anyway).

WPF form displaying as winform

Sorry this is probably a really silly question but I am developing a WPF form on a Windows 7 machine with VS2010 yet when running the application the form still looks like a standard WinForms window.
I am assuming that it requires an extra component installed on the system to be displayed as shown in the designer?
PS: To be more specific what I am referring to is basically the outline and border.
No, what you are experiencing is totally normal. Unless you have altered the default style of your controls, your application will be drawn using windows default look and feel.
That border is just for design purposes. But you could add your own Border to recreate it during runtime.

c# how can i make sure that my application will look the same on other systems?

how do i make sure that the application iam developing will look the same on other windows-systems?
iam developing now on a windows7, with .net 3.5 framework .. (VS 2008)
as an example, i have a toolbar, that i changed its rendermode to system, it looks ok on my windows7, but when i run the application on windows xp, it is different, even the onmouseover backcolor is different. ..
is there a way to make the application looks like on every windows system (talking abt xp, vista and windows 7 only), lets say like exporting the settings of all the controls with the application !? or any trick to make sure it will be always the same ?
thankss in advance
Unless you render the window yourself you're going to always have slight differences between OS'es, they all have different ways of rendering your primitive controls like text boxes, panels, etc.
Also under windows the background color of a window/control is actually (by default) tied into the theme set in windows.
So allowing people to use their own themes is a plus. You really shouldn't force a style on people unless you're theming your own application.
You would have to you get a grab on all of the colours, fonts, transperancy, etc. and use them to override every controls' Paint event/method so that they may use your values.
The only way I see fit would be by writing yourself custom controls while handling these controls appearance throught the Paint() method so that the control may use what you give it. The pain!...
As SLaks commented, you shouldn't care about such details and let the defaut user preferences take over on the native OS, because some surprises may be encountered over time as if Windows doesn't find the font, for instance, it will replace it with its default, which could lead to horrible results. That is just one example. Need others?

Closing Windows Forms on a Touchscreen

Our clients have fat fingers, and so do we. We take touchscreen netbooks apart to insert them into our custom hardware, and I write a software interface that shows up on the touchscreen. The problem is that it has about a 3/4" bezel over the screen, which means hitting that little red "X" becomes a challenge, especially considering reduced capacitive ability on the edges and corners.
Is there a way to make this standard close button larger? Of course in the application I can always make really nice 80x80 buttons that are perfectly usable, but there seems to be no way to override the default frame of the form. We have tried enabling Large Fonts and all the built-in accessibility features, but nothing seems to make it large enough to hit successfully.
Simply adding a toolbar button is also not much of an option. We prefer to utilize the standard look and feel of a normal Windows application.
Alternatively, should we be looking at making some sort of "kiosk mode" where we simply go fullscreen and do nothing involving the taskbar or title bar? How difficult is this to accomplish, if so?
Well, since you're setting up the hardware, I presume you're able to configure preinstalled software, including Windows. Can't you just go into Display Settings and make the title bar larger, so that the close button grows accordingly?
See MS Article about distributing windows themes: http://support.microsoft.com/kb/310514
Getting a large close button is fairly easy to do. It is hidden well since Vista, in Win7 it is Control Panel + Personalization + Window Color, Advanced appearance settings, Item = Caption buttons, change the Size. You probably won't like this much though, you'll get a rather large caption bar, lots of waste screen real estate.
Tackling this from the other end: your request is unusual. Most anybody that sets up a touch screen app wants to know how to prevent the user from closing the window. Windows Forms makes it too easy to design a bunch of forms and switch between them. That isn't much of a user interface on a regular desktop, especially not here. You can design your forms as user controls as well and switch them in and out of the main window as the user navigates through the UI. Not unlike, say, Microsoft Outlook. You can even turn your existing form into a control. Set its TopLevel property to False, FormBorderStyle to None, Visible to true.

Categories