Validating icon of titlebar in form

Class library usage, coding and language questions.
Posts: 2
Joined: Wed Sep 24, 2008 11:18 am

Validating icon of titlebar in form

Post by poojaagni » Wed Sep 24, 2008 11:29 am


I am able to get form icon using form.Icon property... to compare this retrived icon cannot find any api.

FindImage and CompareImage methods returns false for title bar icon as point value is not set.

Could you please suggest me the solution for this?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12169
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Post by Support Team » Wed Sep 24, 2008 12:17 pm

First of all you need to save the icon as a bitmap (see System.Drawing.Icon.ToBitmap method). Then you can use the CompareImage and FindImage methods of the form with the bitmap. You can calculate the offset for the CompareImage method by using the FindImage once.

The only thing with icons is that you need to consider transparent areas. When saving icons as a bitmap, these transparent colors will be replaced with a default color, so the transparency gets lost. So, if your form icon hast transparent areas, be sure to crop those areas with an image editor first.

Ranorex Support Team