Visual basic "skin" or "theme"

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

36 Replies - 7668 Views - Last Post: 27 September 2013 - 09:10 AM Rate Topic: ***** 1 Votes

#1 Storesnurr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 13

Visual basic "skin" or "theme"

Posted 21 September 2013 - 12:49 PM

I want to make a "skin" or "theme" for my project.
The skin is gonna be a file that contains a icon and a image.
So if I open the file with my program will the programs icon and background change to the icon and a image in the file.
Can someone please help me?
Is This A Good Question/Topic? 0
  • +

Replies To: Visual basic "skin" or "theme"

#2 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 21 September 2013 - 02:12 PM

Perhaps you mean a folder that contains an icon and an image? A single file doesn't (usually) contain two images, unless it's a zip file.

A WinForm has an Icon and BackgroundImage property. You can set these properties to whatever suitable images are found on your system or, for portability, images that are distributed with your application as resources.
Was This Post Helpful? 0
  • +
  • -

#3 Storesnurr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 13

Re: Visual basic "skin" or "theme"

Posted 22 September 2013 - 05:17 AM

I think a zip file will work.
So the idea was that all the skin (zip) files would be stored inside a folder in the program files folder.
So when you go to the settings window in my program a ComboBox will display a list of all the skins, and when you click one it will change to that skin
I'm pretty new in visual basic so could you please help me with the code :)

This post has been edited by andrewsw: 22 September 2013 - 06:02 AM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 22 September 2013 - 06:08 AM

As you are new to VB then simple image files would be slightly easier than zip files.

You need to study how to set images as icons and backgrounds, and storing images as Resources (MSDN).

When you've made some progress then you can come back if you are stuck (with some code). You could look through the tutorials section, there is a Tutorials link at the top of this page.

There is also a link in my signature to a Programming Fundamentals tutorial.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14175
  • View blog
  • Posts: 56,787
  • Joined: 12-June 08

Re: Visual basic "skin" or "theme"

Posted 22 September 2013 - 08:37 AM

Then again - there's this: Intro to "skinning" an application .
Was This Post Helpful? 0
  • +
  • -

#6 Storesnurr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 13

Re: Visual basic "skin" or "theme"

Posted 22 September 2013 - 12:11 PM

View Postandrewsw, on 22 September 2013 - 06:08 AM, said:

As you are new to VB then simple image files would be slightly easier than zip files.

You need to study how to set images as icons and backgrounds, and storing images as Resources (MSDN).

When you've made some progress then you can come back if you are stuck (with some code). You could look through the tutorials section, there is a Tutorials link at the top of this page.

There is also a link in my signature to a Programming Fundamentals tutorial.
I found this code:
Private Sub Shutdown_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If File.Exists("C:\Program Files (x86)\Shutdown by Storesnurr\Skin\Background.bmp") Then
            Dim bytes = My.Computer.FileSystem.ReadAllBytes("C:\Program Files (x86)\Shutdown by Storesnurr\Skin\Background.bmp")
            Me.BackgroundImage = Image.FromStream(New IO.MemoryStream(bytes))
        Else
            Me.BackgroundImage = My.Resources.Shutdown22
        End If
    End Sub

So you can go to the folder an replace the image and the program will load it.
Only problem now is that I cant load icons.
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 22 September 2013 - 12:38 PM

If you save your icon/image as a Resource then it's:

Me.Icon = My.Resources.AppIcon    'or whatever you've named the resource

This is what you need to do anyway, rather than referring to a specific location on the C: drive.

This post has been edited by andrewsw: 22 September 2013 - 12:44 PM

Was This Post Helpful? 0
  • +
  • -

#8 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 22 September 2013 - 12:50 PM

You can add the resource/image from the Project menu, Project Properties; click into the Resources tab, Add Resource, Add Existing File.. Give this resource a name that you can refer to in your code.

I think it needs to be a bitmap (or an image that can be converted to a bitmap), although I suspect it could also be an .ico file. (It can even be a Stream.)

Form.Icon :MSDN

It should be 16x16, 32x32 or 48x48 pixels.

Icon Class :MSDN

This post has been edited by andrewsw: 22 September 2013 - 01:00 PM

Was This Post Helpful? 0
  • +
  • -

#9 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 07:23 AM

seems like great lengths to achieve something that should be very simple

if you have a skins folder that contains all the relevant images for your application

why not just change the images on the fly .


Folder structure
- Skins
-- Green Theme
---- bg.png
---- logo.png
---- etc

Add a form of something to select a skin, do a search of the Skin folder and display the names of the top level directories

User clicks on the name / skin

nice wee function that goes and updates all of the images in your app

This post has been edited by deery5000: 23 September 2013 - 07:25 AM

Was This Post Helpful? 0
  • +
  • -

#10 Storesnurr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 13

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 07:40 AM

View Postandrewsw, on 22 September 2013 - 12:50 PM, said:

You can add the resource/image from the Project menu, Project Properties; click into the Resources tab, Add Resource, Add Existing File.. Give this resource a name that you can refer to in your code.

I think it needs to be a bitmap (or an image that can be converted to a bitmap), although I suspect it could also be an .ico file. (It can even be a Stream.)

Form.Icon :MSDN

It should be 16x16, 32x32 or 48x48 pixels.

Icon Class :MSDN
But is it possible to have the icon in a specific folder on the C: drive.
I tried this code:
        If File.Exists("C:\Program Files (x86)\Shutdown by Storesnurr\Skin\Icon.ico") Then
            Dim bytes = My.Computer.FileSystem.ReadAllBytes("C:\Program Files (x86)\Shutdown by Storesnurr\Skin\Icon.ico")
            Me.Icon = Image.FromStream(New IO.MemoryStream(bytes))
        End If

but it wont work.

This post has been edited by andrewsw: 23 September 2013 - 07:44 AM

Was This Post Helpful? 0
  • +
  • -

#11 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 07:42 AM

What does "it won't work" mean? Do you receive error messages? If so, post them.

I did say that I suspected that .ico files could be used. Try it with a 16x16 bitmap.
Was This Post Helpful? 0
  • +
  • -

#12 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 07:47 AM

You can leave your post! I've edited your previous one.

The error message:

Quote

Value of type 'System.Drawing.Image' cannot be converted to 'System.Drawing.Icon'.

Try with a bitmap .bmp file rather than .ico.
Was This Post Helpful? 0
  • +
  • -

#13 Storesnurr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 13

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 07:54 AM

View Postdeery5000, on 23 September 2013 - 07:23 AM, said:

seems like great lengths to achieve something that should be very simple

if you have a skins folder that contains all the relevant images for your application

why not just change the images on the fly .


Folder structure
- Skins
-- Green Theme
---- bg.png
---- logo.png
---- etc

Add a form of something to select a skin, do a search of the Skin folder and display the names of the top level directories

User clicks on the name / skin

nice wee function that goes and updates all of the images in your app
I have tried that, and it worked but I had to remove my about box.
It also didn't look so good.
Was This Post Helpful? 0
  • +
  • -

#14 Storesnurr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 13

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 08:00 AM

View Postandrewsw, on 23 September 2013 - 07:47 AM, said:

You can leave your post! I've edited your previous one.

The error message:

Quote

Value of type 'System.Drawing.Image' cannot be converted to 'System.Drawing.Icon'.

Try with a bitmap .bmp file rather than .ico.
I don't think that is the problem.
If it was the file type that was the problem would the error message come when I started debugging.
The error message came before I started debugging.
Was This Post Helpful? 0
  • +
  • -

#15 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: Visual basic "skin" or "theme"

Posted 23 September 2013 - 08:06 AM

Yes, that code you found was for a background-image, not an icon.

Try this:

Me.Icon = New Icon(New IO.MemoryStream(bytes))

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3