Program Size Problem made in C# - c#

I have made a program within C# which i have now published from it but a problem occuyrs when i try to install it on different machines to mine. On my computer the program window size is fine but on other computers its sometimes too small and sometimes too big so the user can not properly look at the main screen of the program. I don't know what to do to change this problem, either within the computer settings or possibly in C# in the code of my project. Please Help,
Thanks,
Chris.

Use Dock and Anchor

It sounds like different users have different screen resolutions. Thats just part of developing software for a variety of users, with differing screen options. You should test your app is usable with different settings and possibly adjust font sizes, layout and dimensions accordingly.

If I'm guessing correctly the problem here isn't the screen resolution but that the actual program window changes size, either hiding parts of the program or showing too much? In that case you should take a look in your WPF editor (if you're using WPF, that is) and check the different Layout/Size options.

You need to use the Anchor properties and Dock properties of your controls (inside the form) to allow your program to be resized. If you can successfully resize it on your computer it should work on others too.
Part from that you may want to set the form to fixed size so that users can't resize it.

You can use the Screen class to get the bounds of the available screens, and from there you should be able to tell if your initial window size is too small and adjust it accordingly. You should probably take care to do this once on the initial launch of the application, just in case the user explicitly and intentionally moves/resizes the window so it doesn't completely cover the screen -- you wouldn't want to accidentally obliterate their changes the next time you run (assuming you even save window positions).

Related

Show C# WinForm on different screens

On my workstation I have developed a WinForm application. With panels, buttons and dropdowns.
After that I applied the application to my laptop.
On my laptop the presentation of the application was not correct. The elements overlap and the buttons are warped.
Can you tell me how to handle this?
I apologize for my english. This text was written with Google translator.
It is a bit difficult to tell from the distance, but I guess the window uses a different size on the laptop and the controls' docking and anchoring are not configured to do what you want. I suggest this and this tutorial on how to configure the properties; this is preferrably done in the designer instead of code for a fixed layout.
I've seen this behavior running Windows with a "display size" setting greater than 100%. Try resetting this value in your display settings:
Make sure to develop your forms on a computer with the system DPI setting set to 100%. Visual Studio will automatically convert your form coordinates depending on this system setting (it's a bug according to me). A quick way to fix a form is to do the following:
Make sure the system DPI setting is set to 100%.
Move a button in the form one pixel to the left. Then move it back again.
Save. Compile. Run.
1.] Either use Anchor or Dock
2.] Or try to fix the minimum and maximum size of your form and disable maximize button

Windows Forms advanced visual effects

I have an design idea about the appearence of a small program , which is basically a windows form with a combo and one button.What i would like to do is the following.When i click on the .exe of the program to start it , i would like to have an non-standart start up of the window.To be more specific i will give you an example - i click on the .exe , upon which some dots appear in a random matter all over the screen , after those points appear they start moving in a spiral way so finally they merge into the standart square windows form shape.So my question is - is there a free API or anything similar with the help of which its easily doable or there would be a lot of work needed from myself to create those API's ?
Thanks in advance
This will be extremely difficult to do.
It will also be very annoying for the end-users.
In short I see two options:
Render your form to a bitmap and render peices of the bitmap to a full-screen layered window. You'll have to call UpdateLayeredWindow repeatedly to get the animation working but that should be a good lead. I could see getting 10-20 fps with this method.
Take a screenshot of the desktop, create a full screen borderless topmost window, render the screenshot, then render your animation on top. This will prevent any other windows from recieving input while the animation is playing.
Either way your users will hate you.
As SLaks has already said, that will be pretty annoying for the end-users.
If you ask whether it is doable, I would say yes, everything is doable in programming, it all depends on the effort you're ready to put into.
As a very simple algorithm, here are some steps I would go through for your achievement:
Create a System.Windows.Forms.Form;
Set Form.ShowInTaskBar= false;
Set the Form.TransparencyKey property;
Set the Form.ControlBox= false;
Set Form.TopMost= true;
Drop a PictureBox control on your Form;
On the Form.Load event, take a screenshot of the current desktop and set it as the image of your PictureBox.
Then, build an animated GIF, and superpose it to your form.
You will most likely appreciate, I guess, the following link which discusses about C# Winforms Animation.
Disclaimer: This is an arbitrary algorithm off the top of my head. Besides, I illustrated the steps I would go through in order to achieve such objective, though I have never ever performed WindowsForms animation.
Althouth this might be cool to program, users are conservatives and "always anxious" about program startups, so, as already mentioned, this might become pretty annoying for the end-users.
I hope this helps you through anyway!

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?

How to set the windows screen resolution using c# windows application

I have done a project in c# winforms. I want to set the resolution of the screen to 1680 x 1050,
when the application is run in any pc. How to do it ?
As the others already mentioned you shouldn't change the resolution automatically, cause the user set it to a specific resolution he likes (or his hardware works best on).
So instead of changing the resolution you should change your application. Use TableLayoutPanel, FlowLayoutPanel and / or SplitContainer. Set the Anchor and Dock properties of your Controls and think about setting the MinimumSize and MaximumSize of each control within your application.
This way your application can automatically scale between different resolutions and the user can take the one he likes.
Last but not least, your application should not only consider to take care about the resolution the user selected, it should also take care about the selected dpi settings. Which one you should care of are described in the Windows UX Guide (site 592).
I would advice you to not do these kind of things. The screen resolution is set by the user and this is something you shouldn't change automatically. It is just as bad as changing the color scheme, sound scheme or any other user based preferences without the user knowing anything about it, let alone wants to let your program to do. At least show a dialog and let the user choose what to do.
Having said that, here's an example on how to do this.
Well, he is not saying his application will be changing other systems' resolutions. You shouldn't change the screen resolution on other people's computers; however, it may be necessary for a user to change his own resolution through a separate utility (for different reasons). That is my case right now, so I had to write a simple utility in C# to accomplish that by using InteropServices. Call ChangeDisplaySettings. Here's the declaration:
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(
ref DEVMODE devMode, int flags);

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