vb6parse 1.0.0

vb6parse is a library for parsing and analyzing VB6 code, from projects, to controls, to modules, and forms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="VB6Parse Library Reference - loadrespicture - Resources">
    <title>loadrespicture - Resources - VB6Parse Library Reference</title>
    <link rel="stylesheet" href="../../../assets/css/style.css">
    <link rel="stylesheet" href="../../../assets/css/docs-style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
    <script src="../../../assets/js/theme-switcher.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/vbnet.min.js"></script>
    <script>hljs.highlightAll();</script>
</head>
<body>
    <header class="docs-header">
        <div class="container">
            <h1><a href="../../../index.html">VB6Parse</a> / <a href="../../../library/index.html">Library</a> / <a href="../../../library/functions/resources/index.html">Resources</a> / loadrespicture</h1>
            <p class="tagline">VB6 Library Reference</p>
        </div>
    </header>

    <nav class="docs-nav">
        <div class="container">
            <a href="../../../index.html">Home</a>
            <a href="../../../library/index.html">Library Reference</a>
            <a href="../../../documentation.html">Documentation</a>
            <a href="https://docs.rs/vb6parse" target="_blank">API Docs</a>
            <a href="https://github.com/scriptandcompile/vb6parse" target="_blank">GitHub</a>
            <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
                <span class="theme-icon">🌙</span>
            </button>
        </div>
    </nav>

    <main class="container">
        
        <article class="library-item">
            <h1 id="loadrespicture-function">LoadResPicture Function</h1>
<p>Returns a picture object (<code>StdPicture</code>) containing an image from a resource (.res) file.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-vbnet">LoadResPicture(index, format)</code></pre>
<h2 id="parameters">Parameters</h2>
<ul>
<li><code>index</code> (Required): Integer or String identifying the picture resource</li>
<li>Can be a numeric ID or string name</li>
<li>Must match the ID/name used when the resource was compiled</li>
<li><code>format</code> (Required): Integer specifying the format of the picture</li>
<li><code>vbResBitmap</code> (0): Bitmap (.bmp)</li>
<li><code>vbResIcon</code> (1): Icon (.ico)</li>
<li><code>vbResCursor</code> (2): Cursor (.cur)</li>
</ul>
<h2 id="return-value">Return Value</h2>
<p>Returns a <code>StdPicture</code> object:
- Picture object containing the loaded image from resources
- Object can be assigned to Picture properties of controls
- Object implements <code>IPicture</code> interface
- Returns Nothing if resource not found (some VB versions)
- May raise error 32813 if resource not found</p>
<h2 id="remarks">Remarks</h2>
<p>The <code>LoadResPicture</code> function loads images from embedded resources:
- Loads images from compiled resource (.res) files
- Resource file must be linked to project at compile time
- Supports BMP, ICO, and CUR formats only
- Does NOT support JPG, GIF, or PNG
- Returns <code>StdPicture</code> object implementing <code>IPicture</code>
- Alternative to <code>LoadPicture</code> for embedded images
- No external files needed at runtime
- Faster than loading from disk
- More secure (can't be modified by users)
- Resources embedded in compiled EXE/DLL
- Only one resource file per project
- Resource file added via Project &gt; Add File
- Resource files created with Resource Editor or RC.EXE
- Index can be numeric ID or string name
- Format constants: vbResBitmap, vbResIcon, vbResCursor
- Error 32813: "Resource not found" if ID/format don't match
- Error 48: "Error loading from file" if resource file corrupt
- Pictures are not cached (loaded each time)
- Set object = Nothing to release memory
- Common in <code>Form_Load</code> for initial graphics
- Used with Image, <code>PictureBox</code>, and Form.Picture
- Preferred for distribution (no external image files)</p>
<h2 id="typical-uses">Typical Uses</h2>
<ol>
<li><strong>Load Bitmap to <code>PictureBox</code></strong></li>
</ol>
<pre><code class="language-vbnet">   Picture1.Picture = LoadResPicture(101, vbResBitmap)
   ```
2. **Load Icon to Image Control**
   ```vb
   Image1.Picture = LoadResPicture(102, vbResIcon)
   ```
3. **Load Form Background**
   ```vb
   Me.Picture = LoadResPicture(&quot;BACKGROUND&quot;, vbResBitmap)
   ```
4. **Load Cursor**
   ```vb
   Me.MousePointer = vbCustom
   Me.MouseIcon = LoadResPicture(103, vbResCursor)
   ```
5. **Load Named Resource**
   ```vb
   imgLogo.Picture = LoadResPicture(&quot;LOGO&quot;, vbResBitmap)
   ```
6. **Conditional Image Loading**
   ```vb
   If mode = &quot;dark&quot; Then
       Picture1.Picture = LoadResPicture(201, vbResBitmap)
   Else
       Picture1.Picture = LoadResPicture(101, vbResBitmap)
   End If
   ```
7. **Button Icons**
   ```vb
   cmdSave.Picture = LoadResPicture(104, vbResIcon)
   ```
8. **Multiple Images in Loop**
   ```vb
   For i = 1 To 5
       imgArray(i).Picture = LoadResPicture(100 + i, vbResBitmap)
   Next i
   ```
## Basic Examples
### Example 1: Basic Picture Loading</code></pre>
<p>vb
' Load bitmap from resources
Picture1.Picture = LoadResPicture(101, vbResBitmap)
' Load icon
Image1.Picture = LoadResPicture(102, vbResIcon)
' Load using string name
Picture2.Picture = LoadResPicture("SPLASH", vbResBitmap)</p>
<pre><code>### Example 2: Form Initialization</code></pre>
<p>vb
Private Sub Form_Load()
    ' Load form background
    Me.Picture = LoadResPicture(101, vbResBitmap)
    ' Load toolbar icons
    cmdNew.Picture = LoadResPicture(201, vbResIcon)
    cmdOpen.Picture = LoadResPicture(202, vbResIcon)
    cmdSave.Picture = LoadResPicture(203, vbResIcon)
End Sub</p>
<pre><code>### Example 3: Error Handling</code></pre>
<p>vb
On Error Resume Next
Picture1.Picture = LoadResPicture(999, vbResBitmap)
If Err.Number = 32813 Then
    MsgBox "Resource not found!", vbCritical
    Err.Clear
ElseIf Err.Number &lt;&gt; 0 Then
    MsgBox "Error loading resource: " &amp; Err.Description, vbCritical
    Err.Clear
End If</p>
<pre><code>### Example 4: Dynamic Loading</code></pre>
<p>vb
Dim imageID As Integer
imageID = 101 + selectedIndex
Picture1.Picture = LoadResPicture(imageID, vbResBitmap)</p>
<pre><code>## Common Patterns
### Pattern 1: `SafeLoadResPicture`</code></pre>
<p>vb
Function SafeLoadResPicture(ByVal resID As Variant, _
                            ByVal resFormat As Integer, _
                            ByVal ctrl As Object) As Boolean
    On Error Resume Next
    Set ctrl.Picture = LoadResPicture(resID, resFormat)
    SafeLoadResPicture = (Err.Number = 0)
    Err.Clear
End Function</p>
<pre><code>### Pattern 2: `PreloadResourcePictures`</code></pre>
<p>vb
Dim preloadedPics() As StdPicture
Sub PreloadResourcePictures()
    Dim i As Long
    ReDim preloadedPics(1 To 5)
    For i = 1 To 5
        Set preloadedPics(i) = LoadResPicture(100 + i, vbResBitmap)
    Next i
End Sub
Sub ShowPreloadedImage(ByVal index As Long)
    If index &gt;= 1 And index &lt;= UBound(preloadedPics) Then
        Set Picture1.Picture = preloadedPics(index)
    End If
End Sub</p>
<pre><code>### Pattern 3: `LoadResPictureWithDefault`</code></pre>
<p>vb
Function LoadResPictureWithDefault(ByVal resID As Variant, _
                                   ByVal resFormat As Integer, _
                                   ByVal defaultID As Variant) As StdPicture
    On Error Resume Next
    Set LoadResPictureWithDefault = LoadResPicture(resID, resFormat)
    If Err.Number &lt;&gt; 0 Then
        Err.Clear
        Set LoadResPictureWithDefault = LoadResPicture(defaultID, resFormat)
    End If
End Function</p>
<pre><code>### Pattern 4: `LoadResByName`</code></pre>
<p>vb
Function LoadResByName(ByVal resName As String, _
                       ByVal resFormat As Integer) As StdPicture
    On Error Resume Next
    Set LoadResByName = LoadResPicture(resName, resFormat)
    If Err.Number &lt;&gt; 0 Then
        Debug.Print "Failed to load resource: " &amp; resName
        Set LoadResByName = Nothing
        Err.Clear
    End If
End Function</p>
<pre><code>### Pattern 5: `ToggleResPicture`</code></pre>
<p>vb
Dim currentState As Boolean
Sub ToggleResPicture()
    If currentState Then
        Picture1.Picture = LoadResPicture(101, vbResBitmap)
    Else
        Picture1.Picture = LoadResPicture(102, vbResBitmap)
    End If
    currentState = Not currentState
End Sub</p>
<pre><code>### Pattern 6: `LoadThemeResources`</code></pre>
<p>vb
Enum ThemeType
    tmLight = 0
    tmDark = 1
End Enum
Sub LoadThemeResources(theme As ThemeType)
    Dim baseID As Integer
    baseID = IIf(theme = tmDark, 200, 100)
    Me.Picture = LoadResPicture(baseID + 1, vbResBitmap)
    Picture1.Picture = LoadResPicture(baseID + 2, vbResBitmap)
    Picture2.Picture = LoadResPicture(baseID + 3, vbResBitmap)
End Sub</p>
<pre><code>### Pattern 7: `ResExists`</code></pre>
<p>vb
Function ResExists(ByVal resID As Variant, _
                   ByVal resFormat As Integer) As Boolean
    On Error Resume Next
    Dim pic As StdPicture
    Set pic = LoadResPicture(resID, resFormat)
    ResExists = (Err.Number = 0)
    Set pic = Nothing
    Err.Clear
End Function</p>
<pre><code>### Pattern 8: `LoadAllResourceIcons`</code></pre>
<p>vb
Function LoadAllResourceIcons(startID As Integer, _
                              endID As Integer) As Collection
    Dim col As New Collection
    Dim i As Integer
    Dim pic As StdPicture
    On Error Resume Next
    For i = startID To endID
        Set pic = LoadResPicture(i, vbResIcon)
        If Err.Number = 0 Then
            col.Add pic
        End If
        Err.Clear
    Next i
    Set LoadAllResourceIcons = col
End Function</p>
<pre><code>### Pattern 9: `SetButtonIcon`</code></pre>
<p>vb
Sub SetButtonIcon(btn As CommandButton, _
                  ByVal iconID As Integer, _
                  ByVal enabled As Boolean)
    On Error Resume Next
    If enabled Then
        Set btn.Picture = LoadResPicture(iconID, vbResIcon)
    Else
        Set btn.Picture = LoadResPicture(iconID + 100, vbResIcon)
    End If
    btn.enabled = enabled
End Sub</p>
<pre><code>### Pattern 10: `LoadResourceArray`</code></pre>
<p>vb
Sub LoadResourceArray(ByRef picArray() As StdPicture, _
                      ByVal startID As Integer, _
                      ByVal count As Integer, _
                      ByVal resFormat As Integer)
    Dim i As Integer
    ReDim picArray(1 To count)
    On Error Resume Next
    For i = 1 To count
        Set picArray(i) = LoadResPicture(startID + i - 1, resFormat)
        If Err.Number &lt;&gt; 0 Then
            Debug.Print "Failed to load resource: " &amp; (startID + i - 1)
            Err.Clear
        End If
    Next i
End Sub</p>
<pre><code>## Advanced Examples
### Example 1: Resource Picture Manager</code></pre>
<p>vb
' Class: ResPictureManager
Private m_cache As Collection
Private Sub Class_Initialize()
    Set m_cache = New Collection
End Sub
Public Function LoadPicture(ByVal resID As Variant, _
                            ByVal resFormat As Integer) As StdPicture
    Dim key As String
    On Error Resume Next
    key = CStr(resID) &amp; "_" &amp; CStr(resFormat)
    Set LoadPicture = m_cache(key)
    If Err.Number &lt;&gt; 0 Then
        Err.Clear
        Set LoadPicture = LoadResPicture(resID, resFormat)
        If Err.Number = 0 Then
            m_cache.Add LoadPicture, key
        Else
            Err.Raise vbObjectError + 1000, "ResPictureManager", _
                      "Failed to load resource"
        End If
    End If
End Function
Public Sub AssignToControl(ByVal ctrl As Object, _
                           ByVal resID As Variant, _
                           ByVal resFormat As Integer)
    Set ctrl.Picture = LoadPicture(resID, resFormat)
End Sub
Public Sub ClearCache()
    Dim i As Long
    For i = m_cache.Count To 1 Step -1
        m_cache.Remove i
    Next i
End Sub
Public Property Get CacheSize() As Long
    CacheSize = m_cache.Count
End Property
Private Sub Class_Terminate()
    ClearCache
    Set m_cache = Nothing
End Sub</p>
<pre><code>### Example 2: Image Gallery from Resources</code></pre>
<p>vb
' Form with Picture1, Timer1, cmdNext, cmdPrev, lblInfo
Private Const BASE_IMAGE_ID = 1001
Private Const IMAGE_COUNT = 10
Private currentIndex As Long
Private Sub Form_Load()
    currentIndex = 0
    ShowCurrentImage
    Timer1.Interval = 5000 ' 5 seconds
    Timer1.Enabled = True
End Sub
Private Sub ShowCurrentImage()
    Dim imageID As Integer
    On Error Resume Next
    imageID = BASE_IMAGE_ID + currentIndex
    Set Picture1.Picture = LoadResPicture(imageID, vbResBitmap)
    If Err.Number &lt;&gt; 0 Then
        Picture1.Cls
        Picture1.Print "Image not found"
    Else
        lblInfo.Caption = "Image " &amp; (currentIndex + 1) &amp; " of " &amp; IMAGE_COUNT
    End If
    Err.Clear
End Sub
Private Sub Timer1_Timer()
    NextImage
End Sub
Private Sub cmdNext_Click()
    NextImage
End Sub
Private Sub cmdPrev_Click()
    PrevImage
End Sub
Private Sub NextImage()
    currentIndex = (currentIndex + 1) Mod IMAGE_COUNT
    ShowCurrentImage
End Sub
Private Sub PrevImage()
    currentIndex = (currentIndex - 1 + IMAGE_COUNT) Mod IMAGE_COUNT
    ShowCurrentImage
End Sub</p>
<pre><code>### Example 3: Toolbar with Resource Icons</code></pre>
<p>vb
' Form with toolbar buttons array: cmdTool(0 to 9)
Private Type ToolButton
    caption As String
    iconID As Integer
    enabled As Boolean
    tooltip As String
End Type
Private toolConfig() As ToolButton
Private Sub Form_Load()
    InitializeToolbar
    ApplyToolbarConfig
End Sub
Private Sub InitializeToolbar()
    ReDim toolConfig(0 To 9)
    With toolConfig(0)
        .caption = "New"
        .iconID = 201
        .enabled = True
        .tooltip = "Create new document"
    End With
    With toolConfig(1)
        .caption = "Open"
        .iconID = 202
        .enabled = True
        .tooltip = "Open existing document"
    End With
    With toolConfig(2)
        .caption = "Save"
        .iconID = 203
        .enabled = False
        .tooltip = "Save current document"
    End With
    ' ... more buttons
End Sub
Private Sub ApplyToolbarConfig()
    Dim i As Long
    On Error Resume Next
    For i = 0 To UBound(toolConfig)
        With cmdTool(i)
            .caption = toolConfig(i).caption
            .enabled = toolConfig(i).enabled
            .ToolTipText = toolConfig(i).tooltip
            Set .Picture = LoadResPicture(toolConfig(i).iconID, vbResIcon)
            If Err.Number &lt;&gt; 0 Then
                Debug.Print "Failed to load icon: " &amp; toolConfig(i).iconID
                Err.Clear
            End If
        End With
    Next i
End Sub
Public Sub EnableTool(ByVal index As Long)
    If index &gt;= 0 And index &lt;= UBound(toolConfig) Then
        toolConfig(index).enabled = True
        cmdTool(index).enabled = True
    End If
End Sub
Public Sub DisableTool(ByVal index As Long)
    If index &gt;= 0 And index &lt;= UBound(toolConfig) Then
        toolConfig(index).enabled = False
        cmdTool(index).enabled = False
    End If
End Sub</p>
<pre><code>### Example 4: Multi-State Indicator</code></pre>
<p>vb
' Form with imgStatus (Image control)
Public Enum StatusState
    stIdle = 0
    stProcessing = 1
    stSuccess = 2
    stWarning = 3
    stError = 4
End Enum
Private Const RES_STATUS_IDLE = 301
Private Const RES_STATUS_PROCESSING = 302
Private Const RES_STATUS_SUCCESS = 303
Private Const RES_STATUS_WARNING = 304
Private Const RES_STATUS_ERROR = 305
Private statusIcons() As StdPicture
Private currentStatus As StatusState
Private Sub Form_Load()
    LoadStatusIcons
    SetStatus stIdle
End Sub
Private Sub LoadStatusIcons()
    ReDim statusIcons(0 To 4)
    On Error Resume Next
    Set statusIcons(stIdle) = LoadResPicture(RES_STATUS_IDLE, vbResIcon)
    Set statusIcons(stProcessing) = LoadResPicture(RES_STATUS_PROCESSING, vbResIcon)
    Set statusIcons(stSuccess) = LoadResPicture(RES_STATUS_SUCCESS, vbResIcon)
    Set statusIcons(stWarning) = LoadResPicture(RES_STATUS_WARNING, vbResIcon)
    Set statusIcons(stError) = LoadResPicture(RES_STATUS_ERROR, vbResIcon)
    If Err.Number &lt;&gt; 0 Then
        MsgBox "Warning: Some status icons could not be loaded", vbExclamation
        Err.Clear
    End If
End Sub
Public Sub SetStatus(ByVal newStatus As StatusState)
    currentStatus = newStatus
    If newStatus &gt;= 0 And newStatus &lt;= UBound(statusIcons) Then
        If Not statusIcons(newStatus) Is Nothing Then
            Set imgStatus.Picture = statusIcons(newStatus)
        End If
    End If
End Sub
Public Function GetStatus() As StatusState
    GetStatus = currentStatus
End Function
Private Sub Form_Unload(Cancel As Integer)
    Dim i As Long
    For i = 0 To UBound(statusIcons)
        Set statusIcons(i) = Nothing
    Next i
End Sub</p>
<pre><code>## Error Handling</code></pre>
<p>vb
' Error 32813: Resource not found
On Error Resume Next
Set pic = LoadResPicture(999, vbResBitmap)
If Err.Number = 32813 Then
    MsgBox "Resource not found!"
End If
' Error 48: Error loading from file
Set pic = LoadResPicture(101, vbResBitmap)
If Err.Number = 48 Then
    MsgBox "Resource file is corrupt or missing!"
End If
' Safe loading pattern
Function TryLoadResPicture(ByVal resID As Variant, _
                           ByVal resFormat As Integer, _
                           ByRef pic As StdPicture) As Boolean
    On Error Resume Next
    Set pic = LoadResPicture(resID, resFormat)
    TryLoadResPicture = (Err.Number = 0)
    Err.Clear
End Function</p>
<pre><code>## Performance Considerations
- **Fast Loading**: Resources embedded in EXE (very fast access)
- **No File I/O**: No disk access required
- **Memory Usage**: Pictures consume memory until released
- **No Caching**: Each call loads fresh copy (implement caching if needed)
- **Preloading**: Load frequently used images once at startup
- **EXE Size**: Large images increase executable size
## Best Practices
1. **Always handle errors** - resource might not exist
2. **Use constants** for resource IDs for maintainability
3. **Preload frequently used images** for better performance
4. **Release memory** by setting picture objects to Nothing when done
5. **Use meaningful names** for string-based resource IDs
6. **Test all resources** during development
7. **Document resource IDs** in code or separate file
8. **Use Resource Editor** to manage resources efficiently
9. **Consider image size** - large bitmaps increase EXE size
10. **Cache in Collection** for images used multiple times
## Comparison with Related Functions
| Function | Purpose | Source | External Files |
|----------|---------|--------|----------------|
| **`LoadResPicture`** | Load from resources | Embedded .res | No |
| **`LoadPicture`** | Load from file | External file | Yes |
| **`LoadResData`** | Load binary data | Embedded .res | No |
| **`LoadResString`** | Load string | Embedded .res | No |
## `LoadResPicture` vs `LoadPicture`</code></pre>
<p>vb
' LoadResPicture - from embedded resources
Picture1.Picture = LoadResPicture(101, vbResBitmap)
' LoadPicture - from external file
Picture1.Picture = LoadPicture("C:\Images\logo.bmp")</p>
<pre><code>**When to use each:**
- **`LoadResPicture`**: Distribution (no external files), static images, faster loading
- **`LoadPicture`**: Dynamic images, user-selected files, easier updates
## Resource Format Constants</code></pre>
<p>vb
' Format constants
Const vbResBitmap = 0  ' Bitmap (.bmp)
Const vbResIcon = 1    ' Icon (.ico)
Const vbResCursor = 2  ' Cursor (.cur)
' Usage
Picture1.Picture = LoadResPicture(101, vbResBitmap)
Image1.Picture = LoadResPicture(102, vbResIcon)
Me.MouseIcon = LoadResPicture(103, vbResCursor)
```</p>
<h2 id="platform-notes">Platform Notes</h2>
<ul>
<li>Available in VB6 (not in early VB versions)</li>
<li>Requires resource file (.res) linked to project</li>
<li>Resource file created with Resource Editor or RC.EXE</li>
<li>Only one resource file per project</li>
<li>Resources embedded in compiled EXE/DLL</li>
<li>Returns <code>StdPicture</code> object (OLE automation object)</li>
<li>Supports BMP, ICO, CUR formats only</li>
<li>No native support for JPG, GIF, PNG</li>
<li>Format parameter: 0=Bitmap, 1=Icon, 2=Cursor</li>
<li>Icons can contain multiple sizes</li>
</ul>
<h2 id="limitations">Limitations</h2>
<ul>
<li><strong>Format Support</strong>: Only BMP, ICO, CUR (no JPG/GIF/PNG)</li>
<li><strong>One Resource File</strong>: Only one .res file per project</li>
<li><strong>Compile Time</strong>: Must recompile to update resources</li>
<li><strong>No Modification</strong>: Cannot modify resources at runtime</li>
<li><strong>No Caching</strong>: Each call reloads from resource</li>
<li><strong>EXE Size</strong>: Large images significantly increase EXE size</li>
<li><strong>No Compression</strong>: Images stored uncompressed</li>
<li><strong>Limited Editor</strong>: VB6 Resource Editor is basic</li>
<li><strong>No Metadata</strong>: Cannot read image dimensions before loading</li>
<li><strong>Memory Usage</strong>: Large images consume significant memory</li>
</ul>
<h2 id="related-functions">Related Functions</h2>
<ul>
<li><code>LoadPicture</code>: Load picture from external file</li>
<li><code>LoadResData</code>: Load custom binary data from resources</li>
<li><code>LoadResString</code>: Load string from resources</li>
<li><code>SavePicture</code>: Save picture object to file</li>
<li><code>Set</code>: Assign object references</li>
</ul>
        </article>
        
        <div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color);">
            <p>
                <a href="index.html">← Back to Resources</a> |
                <a href="../index.html">View all functions</a>
            </p>
        </div>

    </main>

    <footer>
        <div class="container">
            <p>&copy; 2024-2026 VB6Parse Contributors. Licensed under the MIT License.</p>
        </div>
    </footer>
</body>
</html>