How to change Window.Forms Application Icon - winforms

I am trying to change the Window Icon using the System.Forms library.
open System
open System.Drawing
open System.Windows.Forms
let window = new Form()
window.Text <- "Hallo!"
let icon = new System.Drawing.Icon("icon.png")
window.Icon <- icon
Application.Run window
My code doesn't return any errors and compiles like a charm. But! i get an unhandled exception stating that the argument picture must be a picture that can be used as an icon.
So what are the requirements for the picture? the present one i got is a png and is 512x512 in dimensions.
The official discription of the Icon property is found here:
https://msdn.microsoft.com/en-us/library/system.drawing.icon(v=vs.110).aspx
So i take it the problem is that the attempted match the requested size fails. But what is the requested size?

You are using png image as an icon of windows forms. Use .ico file as an icon. Convert icon from here, this site will convert png to ico with all sizes available.

Related

Is there any way in react to Blend text color with image?

Background images are floating on the page according to mouse movement. What i want is that whenever there is an image behind/above the text the color of that specific portion of text get's change similar to given image.
I had tried multiple libraries like Frame-motion, GSAP but I am unable find the solution. If there is kindly let me know.

change the color of the png image using expression blend

There might be duplicates of this question but I didnt find any exact solution to my problem.
I have an image. The source of image is a png image named add.png. The shape of add.png is like a plus(+) symbol. Its color is white at the moment.
I want to change this white color to green when mouse cursor goes over it. So which property of the image should I change to change its color.
I don't want to change the source of image.
Edit :
Why I don't want to change the image source :
Basically I have a rectangle and I keep the image over it.
On MouseOver and MouseLeave I change the Fill color of Rectangle using ChangePropertyAction. Now When I click on the image I want to change its source.
But when my program runs I get an error sayin that windows explorer has stopped working.
When I see the output window for errors I get System.NullReferenceException: Object reference not set to an instance of an object
It is easier. to change the image source.
Your options are limited here: Create own effect by derive from System.Windows.Media.Effects.Effect, call it ColorEffect and implement color change logic there, a similar alternative would be to create separate PixelShader Effect but this is more complex then the Effect above.
Use image processing from http://www.codeproject.com/Articles/237226/Image-Processing-is-done-using-WPF

Icon size help WINAPI only showing small c

Hi there just a quick question I hope someone can help me with I am loading a logo onto my dialog application into a static picture holder using the .rc file and adding this code.
ICON IDI_MYICON,IDC_STATIC_IMAGE,120,154,21,20
However my problem is this will only display a 64x64 image max and the banner I have loaded is 242x74 in size am I using the wrong method in using ICON? I did try bitmap but didnt work either.
Thanks
The 21,20 in your statement is the width and height of the icon control in dialog units. Dialog units vary depending on things like screen DPI and the font selected. There are typically 2-4 pixels per dialog unit. You've basically given the icon something on the order of 64x64 to display in.
To get the icon control sized pixel-perfectly, you can to resize it dynamically, e.g., during WM_INITDIALOG.
Also, I'm not sure which method the dialog box code uses to load the icon--some (like LoadIcon) restrict the size to a "standard" size which others (like LoadImage) do not.

Win32 CreateWindowEx() window icon not showing properly

I create my window using CreateWindowEx, but I only get an icon in the task bar; both the window's title bar and the icon that shows when I Alt+Tab show this type of dummy icon: . I set both the hIcon and the hIconSm fields in the WNDCLASSEX to the value returned from ::LoadIcon(hInstance, IDI_APPLICATION) (not NULL).
The .ico file itself was made out of a .png which I genereated through http://converticon.com to 16x16, 32x32 and 96x96 (what are the recommended sizes btw?). Could it be that I'm using the wrong sizes or color depth? If so, why does it work in the task bar (different size)? Thanks!
The icon must be defined as a resource somewhere. In your resource header there should be a line like this:
#define IDI_MYICON 1000
Then in your call to LoadIcon() it should be something like:
wc.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_MYICON));
If you're using Visual Studio it's pretty easy to add resources. Just right click Resources in the solution explorer.

WPF : Use different icon images as an ImageBrush?

An Icon can contain more than one image. I want to use an icon for an ImageBrush and I want to set which image inside the icon should be use. But somehow it seems I can't do that. The brush always picks the largest image from the icon.
Is there a way to choose the image manually?

Resources