Load UI Graphics From the Resource File

Load UI Graphics From the Resource File

Many VB programmers haven’t harnessed the power of VB6’s resource editor. They still use traditional LoadPicture or other primitive calls to load bitmaps and icons. Before VB5, loading pictures into controls was somewhat harder, because of the inherent troubles associated with specifying the path and filename of the resource. With the resource editor, it’s easy to store icons, strings, and bitmaps in a single RES file. I had to load the same picture for several CommandButton controls in a current project. I set the Style property of the CommandButton to 1 (Graphical) and the Tag property to “calendar” so my app would know to load calendar.bmp. I then added and saved this BMP in a resource file and set the ID to “calendar.” First paste this code into the general section of a form:

 'loads icons/bmps from resource files.Sub FillPictures(psdFrm As Form)	' desired form is passed as an parameter.	Dim lcl_Ctrl As Control	For Each lcl_Ctrl In psdFrm.Controls		' controls collection is used here.		If LCase(lcl_Ctrl.Tag) = "calendar" Then		' checking the tag property.			Set lcl_Ctrl.Picture = _				LoadResPicture(lcl_ctrl.tag, vbResBitmap)		End If		' extra code could have been added for 		' loading other picture files by setting 		' the tag property accordingly.	NextEnd Sub

Then call this function from the Form_Load event:

 Private Sub Form_Load()	Call FillPictures(Me)End Sub
Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as