How to add icons in VB program
I wrote a small program using VB and wanted to add an icon
Can you elaborate on where to add the icon? I will write a program for you now. I wonder if it will be useful to this friend.
First add a new form in VB. The specific steps are: Project-Add Form-Open.
Second, add a command button on the form: name it cmddj (cmd click), and the caption attribute is "Open".
Fine-tuning content: "Third, select "Microsoft Common Dialog Control 6.0" in Project - Parts, and add the control to the newly created form in the toolbox. Note that the control is not visible at runtime and the size Not adjustable."
Fourth, draw a Picture control on the form. Moderately sized name attribute is Picture1.
Then add a click event to the cmddj control, the code is as follows
Private Sub Command1_Click()
Dim s As String
CommonDialog1.InitDir = "e:"
CommonDialog1.ShowOpen
s = CommonDialog1.FileName
Picture1.Picture = LoadPicture(s)
End Sub
When the program is running, click the "Open" button and a dialog box will appear. Then find the icon you want and click "Open" to open it.
I don’t know if what I’m talking about is what this friend wants. If it weren't for me, there would be another way.
If you want to modify the icon of the form, just modify the icon attribute of the main form. Here I recommend using VB's icon library as the icon source.
That’s it for now. If it’s not right, please contact me again.
VB6 0 generated program ICO icon problem
Use IconWorkshop or other software to process icons, modify icons, add small resolution and low quality ones. If you are not sure, select them all, and then save them. You can use them in VB. In the resource manager, it is high The quality is good, but the VB form icon is of low quality. You need to use the code below to set the icon.
IconWorkshop specific steps:
Add multiple image formats after opening the icon
Just like this, if you don’t care about the file size, you can also select them all
result:
Of course vb2005 will be simpler, but the syntax of vb2005 and vb6 is very different. The original code can hardly be used
Private Const ICON_BIG = 1
Private Const ICON_SMALL = 0
Private Const WM_SETICON = &H80
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Public Sub SetWindowIcon(hWnd As Long)
Dim hIcon As Long
hIcon = ExtractIcon(App.hInstance, App.EXEName & ".exe", 0)
SendMessage hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon
SendMessage hWnd, WM_SETICON, ICON_BIG, ByVal hIcon
End Sub
The above is the detailed content of How to add icons in VB program. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Article discusses editing Windows Registry, precautions, backup methods, and potential issues from incorrect edits. Main issue: risks of system instability and data loss from improper changes.

Article discusses managing Windows services for system health, including starting, stopping, restarting services, and best practices for stability.

The Steam Cloud error can be caused by many reasons. To play a game smoothly, you need to take some measures to remove this error before you launch the game. php.cn Software introduces some best ways as well as more useful information in this post.

You may see the “A connection to the Windows Metadata and Internet Services (WMIS) could not be established.” error on Event Viewer. This post from php.cn introduces how to remove the Windows Metadata and Internet Services problem.

Article discusses changing default apps for file types on Windows, including reverting and bulk changes. Main issue: no built-in bulk change option.

KB5035942 update issues - crashing system commonly happens to users. Inflicted people hope to find a way out of the kind of trouble, such as crashing system, installation, or sound issues. Targeting these situations, this post published by php.cn wil

The article explains how to use the Group Policy Editor (gpedit.msc) in Windows for managing system settings, highlighting common configurations and troubleshooting methods. It notes that gpedit.msc is unavailable in Windows Home editions, suggesting

Chris Titus Tech has a tool called Windows Utility that can help you easily create a debloated Windows 11/10 ISO to install a clean system. php.cn offers a full guide on how to do this thing using the Chris Titus tool.
