powered by simpleCommunicator - 2.0.53     © 2025 Programmizd 02
Форумы / Microsoft Access [игнор отключен] [закрыт для гостей] / Загрузка изображения из директории. Не работает в 64-битном Офисе.
18 сообщений из 18, страница 1 из 1
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612475
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Приветствую всех! Нужна ваша помощь! На Киберфоруме нашел код загрузки изображений из директории http://www.cyberforum.ru/ms-access/thread1871730.html. Работает хорошо на 32-битном Офисе. На 64 работать не хочет, выдает сообщение. Что надо изменить, что бы работало и в 32 и в 64?
Сам код следующий:
Код: vbnet
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.
Private Sub PictuereUPD()
' Загрузка изображения в обьект Picture : Me!Im_Picture
'--------------------------------------------------------------------
Dim pd As clsPictureData
Dim strPath As String
 
On Error GoTo PictuereUPD_Err
    
    Set pd = New clsPictureData
    
    If Not IsNull(Me!txtFileName) Then
        ' Получаем полный путь
        strPath = CurrentProject.Path & "" & Me!txtFileName
        ' вписываем Полный путь в поле (чисто для наглядности)
        Me!txtFilePath = strPath
        ' Загрузка
        If pd.Load(strPath, Me!Im_Picture) Then
           If Not Me!Im_Picture.Visible Then Me!Im_Picture.Visible = True
        Else
           If Me!Im_Picture.Visible Then Me!Im_Picture.Visible = False
        End If
    Else 'Не указано или новая запись
        Me!txtFilePath = Null
        Me!Im_Picture.Visible = False
    End If
 
PictuereUPD_Bye:
    Set pd = Nothing
    Exit Sub
 
PictuereUPD_Err:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
    "in procedure PictuereUPD", vbCritical, "Error!"
    Resume PictuereUPD_Bye
End Sub
 
Private Sub cmdUPD_Click()
'Кнопка "Обновить!" (изображение)
    PictuereUPD
End Sub
 
Private Sub Form_Current()
'Переход на тек запись
    PictuereUPD
End Sub
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612486
_СергейВП
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
wladimirrr,
Приведите весь текст, включая модуль класса clsPictureData.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612495
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
_СергейВПwladimirrr,
Приведите весь текст, включая модуль класса clsPictureData.
Вот модуль clsPictureData, а что еще нужно?

Код: vbnet
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.
' Ìîäóëü Êëàññà:  clsPictureData
'--------------------------------------------------------------------
' Module    : clsPictureData
' Author    : Áåíåäèêò
' Purpose   : çàãðóæàåò ôàéë â Image ëèáî ÷åðåç .Picture, ëèáî ÷åðåç .PictureData
'             â ïîñëåäíåì ñëó÷àå èñïîëüçóåòñÿ ìåòàôàéë
'--------------------------------------------------------------------
' Òðåáóåòñÿ áèáë. ññûëêà íà OLE Automation
'--------------------------------------------------------------------
' Ïî ìàòåðèàëàì: http://www.sql.ru/forum/actualthread.aspx?tid=304849

Option Compare Database
Option Explicit

'----------- Îïèñàíèÿ ñòðóêòóð, ôóíêöèé, êîíñòàíò Win32 API ---------

Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type

Private Type BITMAP '24 bytes
   bmType As Long
   bmWidth As Long
   bmHeight As Long
   bmWidthBytes As Long
   bmPlanes As Integer
   bmBitsPixel As Integer
   bmBits As Long
End Type

Private Declare Function SelectObject Lib "gdi32" ( _
   ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function GetObjectA Lib "gdi32" ( _
   ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

Private Declare Function GetObjectType Lib "gdi32" ( _
   ByVal hgdiobj As Long) As Long
Private Const OBJ_BITMAP = 7

Private Declare Function GetDC Lib "user32" ( _
   ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( _
   ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" ( _
   ByVal hDC As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" ( _
   ByVal hDC As Long) As Long

Private Declare Function GetDeviceCaps Lib "gdi32" ( _
   ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Const HORZSIZE = 4           '  Horizontal size in millimeters
Private Const VERTSIZE = 6           '  Vertical size in millimeters
Private Const HORZRES = 8            '  Horizontal width in pixels
Private Const VERTRES = 10           '  Vertical width in pixels

Private Declare Function CreateEnhMetaFile Lib "gdi32" _
   Alias "CreateEnhMetaFileA" ( _
   ByVal hdcRef As Long, ByVal lpFileName As String, lpRect As RECT, _
   ByVal lpDescription As String) As Long
Private Declare Function CloseEnhMetaFile Lib "gdi32" ( _
   ByVal hDC As Long) As Long
Private Declare Function DeleteEnhMetaFile Lib "gdi32" ( _
   ByVal hEMF As Long) As Long
Private Declare Function GetEnhMetaFileBits Lib "gdi32" ( _
   ByVal hEMF As Long, ByVal cbBuffer As Long, lpbBuffer As Any) As Long

Private Declare Function SetMapMode Lib "gdi32" ( _
   ByVal hDC As Long, ByVal nMapMode As Long) As Long
Private Const MM_ANISOTROPIC = 8 ' Map mode anisotropic

Private Declare Function SetWindowExtExAny Lib "gdi32" _
   Alias "SetWindowExtEx" ( _
   ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, _
   lpSize As Any) As Long
Private Declare Function SetViewportExtExAny Lib "gdi32" _
   Alias "SetViewportExtEx" ( _
   ByVal hDC As Long, ByVal nX As Long, _
   ByVal nY As Long, lpSize As Any) As Long

Private Declare Function SetStretchBltMode Lib "gdi32" ( _
   ByVal hDC As Long, ByVal nStretchMode As Long) As Long
Private Const STRETCH_DELETESCANS = 3
Private Const STRETCH_HALFTONE = 4

Private Declare Function BitBlt Lib "gdi32" ( _
   ByVal hdcDest As Long, ByVal x As Long, ByVal y As Long, _
   ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, _
   ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
   Destination As Any, Source As Any, ByVal Length As Long)

Private Const CF_ENHMETAFILE = 14
'-------------------------------------------------------------------------------

Private m_hEMF As Long


Public Function Load(ByVal FileName As String, Image As Image) As Boolean
Dim pic As StdPicture
Dim rc As RECT
Dim hdcRef As Long
Dim hdcMeta As Long
Dim hdcMem As Long
Dim bm As BITMAP
Dim cbSize As Long
Dim cbCopied As Long
Dim hbmpOld As Long
Dim iWidthMM As Long
Dim iHeightMM As Long
Dim iWidthPels As Long
Dim iHeightPels As Long
Dim nDotPos As Integer

ReleaseResources

'Âûäåëåíèå ðàñøèðåíèÿ èìåíè ôàéëà, ïðèíÿòèå ðåøåíèÿ, èäòè ïî äëèííîìó ïóòè
'èëè ïî êîðîòêîìó.
    FileName = Trim$(FileName)
    nDotPos = InStrRev(FileName, ".")
    If nDotPos > InStrRev(FileName, "\") Then
        Select Case UCase$(Mid$(FileName, nDotPos + 1))
        Case "WMF", "EMF", "ICO", "BMP", "DIB":
           'Åñëè õîòèì ïîëüçîâàòüñÿ STRETCH_HALFTONE (ñì. íèæå),
           'òî BMP è DIB èç ñïèñêà óáðàòü.
           'Ñ÷èòàåì, ÷òî îêíî ôèëüòðà äëÿ ïðîñòûõ ôîðìàòîâ íå ïîÿâëÿåòñÿ,
           'ãðóçèì èçîáðàæåíèå ÷åðåç ñâîéñòâî Picture.
           On Error Resume Next
           Image.Picture = FileName
           Load = Err = 0
           On Error GoTo 0
           Exit Function
        End Select
    End If

'Äî êîíöà ôóíêöèè - çàãðóçêà èçîáðàæåíèÿ ÷åðåç ñâîéñòâî PictureData.
    On Error Resume Next
    Set pic = LoadPicture(FileName)
    On Error GoTo 0
    If pic Is Nothing Then
        'Åù¸ ïîïûòêà - äëÿ ôîðìàòîâ òèïà PNG, PCX, TGA, íå ïîíèìàåìûõ LoadPicture
        On Error Resume Next
        Image.Picture = FileName
        Load = Err = 0
        On Error GoTo 0
        Exit Function
    End If

'Îæèäàåòñÿ pic.Type=vbPicTypeBitmap=1,GetObjectType(pic.Handle)=OBJ_BITMAP=7
    If GetObjectType(pic.Handle) <> OBJ_BITMAP Then Exit Function

'&#207;&#238;&#235;&#243;&#247;&#224;&#229;&#236; &#231;&#224;&#227;&#238;&#235;&#238;&#226;&#238;&#234; &#225;&#232;&#242;&#236;&#224;&#239;&#224;, &#247;&#242;&#238;&#225;&#251; &#232;&#231;&#226;&#235;&#229;&#247;&#252; &#232;&#231; &#237;&#229;&#227;&#238; &#240;&#224;&#231;&#236;&#229;&#240;&#251; &#232;&#231;&#238;&#225;&#240;&#224;&#230;&#229;&#237;&#232;&#255;
'&#226; &#239;&#232;&#234;&#241;&#229;&#235;&#255;&#245;
    cbSize = LenB(bm)
    cbCopied = GetObjectA(pic.Handle, cbSize, bm)
    If cbCopied <> cbSize Then Exit Function

'&#209;&#247;&#232;&#242;&#224;&#229;&#236;, &#247;&#242;&#238; Image.Parent.hWnd - &#228;&#229;&#241;&#234;&#240;&#232;&#239;&#242;&#238;&#240; &#238;&#234;&#237;&#224; &#244;&#238;&#240;&#236;&#251;
    hdcRef = GetDC(Image.Parent.hWnd)
    
    iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE)
    iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE)
    iWidthPels = GetDeviceCaps(hdcRef, HORZRES)
    iHeightPels = GetDeviceCaps(hdcRef, VERTRES)
    
    rc.Right = bm.bmWidth * iWidthMM * 100 / iWidthPels
    rc.Bottom = bm.bmHeight * iHeightMM * 100 / iHeightPels

'&#209;&#238;&#231;&#228;&#224;&#184;&#236; "&#243;&#241;&#238;&#226;&#229;&#240;&#248;&#229;&#237;&#241;&#242;&#226;&#238;&#226;&#224;&#237;&#237;&#251;&#233;" &#236;&#229;&#242;&#224;&#244;&#224;&#233;&#235; &#226; &#239;&#224;&#236;&#255;&#242;&#232;
    hdcMeta = CreateEnhMetaFile(hdcRef, vbNullString, rc, vbNullString)

    If hdcMeta = 0 Then
        ReleaseDC Image.Parent.hWnd, hdcRef
        Exit Function
    End If
    
    SetMapMode hdcMeta, MM_ANISOTROPIC
    SetWindowExtExAny hdcMeta, bm.bmWidth, bm.bmHeight, ByVal 0&
    SetViewportExtExAny hdcMeta, bm.bmWidth, bm.bmHeight, ByVal 0&
'Access &#241; &#246;&#229;&#235;&#252;&#254; &#241;&#238;&#226;&#236;&#229;&#241;&#242;&#232;&#236;&#238;&#241;&#242;&#232; &#241; Win9x &#232;&#241;&#239;&#238;&#235;&#252;&#231;&#243;&#229;&#242; &#240;&#229;&#230;&#232;&#236; STRETCH_DELETESCANS,
'&#238;&#237; &#225;&#251;&#241;&#242;&#240;&#229;&#229;, &#237;&#238; &#236;&#229;&#237;&#229;&#229; &#234;&#224;&#247;&#229;&#241;&#242;&#226;&#229;&#237;&#237;&#251;&#233;, &#247;&#229;&#236; STRETCH_HALFTONE. &#207;&#238;&#241;&#235;&#229;&#228;&#237;&#232;&#233; &#228;&#238;&#241;&#242;&#243;&#239;&#229;&#237;
'&#226; NT/200x/XP.
    SetStretchBltMode hdcMeta, STRETCH_HALFTONE 'STRETCH_DELETESCANS
    
    hdcMem = CreateCompatibleDC(hdcRef)
    hbmpOld = SelectObject(hdcMem, pic.Handle)
    
    BitBlt hdcMeta, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY
    
    SelectObject hdcMem, hbmpOld
    DeleteDC hdcMem
    ReleaseDC Image.Parent.hWnd, hdcRef
    Set pic = Nothing '&#238;&#241;&#226;&#238;&#225;&#238;&#230;&#228;&#224;&#229;&#236; &#239;&#224;&#236;&#255;&#242;&#252;
    
    m_hEMF = CloseEnhMetaFile(hdcMeta)
    If m_hEMF = 0 Then Exit Function
    
    cbSize = GetEnhMetaFileBits(m_hEMF, 0, ByVal 0&)
    ReDim bPicData(0 To cbSize + 7) As Byte
    cbCopied = GetEnhMetaFileBits(m_hEMF, cbSize, bPicData(8))
    
    bPicData(0) = CF_ENHMETAFILE
    CopyMemory bPicData(4), m_hEMF, 4 '&#245;&#238;&#242;&#255; &#236;&#238;&#230;&#237;&#238; &#232; &#239;&#238;&#225;&#224;&#233;&#242;&#237;&#238; &#231;&#224;&#239;&#238;&#235;&#237;&#232;&#242;&#252;
    Image.PictureData = bPicData
    Erase bPicData '&#238;&#241;&#226;&#238;&#225;&#238;&#230;&#228;&#224;&#229;&#236; &#239;&#224;&#236;&#255;&#242;&#252;
    
    Load = True
End Function
Private Sub ReleaseResources()
    If m_hEMF Then
        DeleteEnhMetaFile m_hEMF
        m_hEMF = 0
    End If
End Sub

Private Sub Class_Terminate()
    ReleaseResources
End Sub
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612497
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
wladimirrr,

еще раз модуль

Код: vbnet
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.
' Модуль Класса:  clsPictureData
'--------------------------------------------------------------------
' Module    : clsPictureData
' Author    : Бенедикт
' Purpose   : загружает файл в Image либо через .Picture, либо через .PictureData
'             в последнем случае используется метафайл
'--------------------------------------------------------------------
' Требуется библ. ссылка на OLE Automation
'--------------------------------------------------------------------
' По материалам: http://www.sql.ru/forum/actualthread.aspx?tid=304849

Option Compare Database
Option Explicit

'----------- Описания структур, функций, констант Win32 API ---------

Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type

Private Type BITMAP '24 bytes
   bmType As Long
   bmWidth As Long
   bmHeight As Long
   bmWidthBytes As Long
   bmPlanes As Integer
   bmBitsPixel As Integer
   bmBits As Long
End Type

Private Declare Function SelectObject Lib "gdi32" ( _
   ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function GetObjectA Lib "gdi32" ( _
   ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

Private Declare Function GetObjectType Lib "gdi32" ( _
   ByVal hgdiobj As Long) As Long
Private Const OBJ_BITMAP = 7

Private Declare Function GetDC Lib "user32" ( _
   ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( _
   ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" ( _
   ByVal hDC As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" ( _
   ByVal hDC As Long) As Long

Private Declare Function GetDeviceCaps Lib "gdi32" ( _
   ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Const HORZSIZE = 4           '  Horizontal size in millimeters
Private Const VERTSIZE = 6           '  Vertical size in millimeters
Private Const HORZRES = 8            '  Horizontal width in pixels
Private Const VERTRES = 10           '  Vertical width in pixels

Private Declare Function CreateEnhMetaFile Lib "gdi32" _
   Alias "CreateEnhMetaFileA" ( _
   ByVal hdcRef As Long, ByVal lpFileName As String, lpRect As RECT, _
   ByVal lpDescription As String) As Long
Private Declare Function CloseEnhMetaFile Lib "gdi32" ( _
   ByVal hDC As Long) As Long
Private Declare Function DeleteEnhMetaFile Lib "gdi32" ( _
   ByVal hEMF As Long) As Long
Private Declare Function GetEnhMetaFileBits Lib "gdi32" ( _
   ByVal hEMF As Long, ByVal cbBuffer As Long, lpbBuffer As Any) As Long

Private Declare Function SetMapMode Lib "gdi32" ( _
   ByVal hDC As Long, ByVal nMapMode As Long) As Long
Private Const MM_ANISOTROPIC = 8 ' Map mode anisotropic

Private Declare Function SetWindowExtExAny Lib "gdi32" _
   Alias "SetWindowExtEx" ( _
   ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, _
   lpSize As Any) As Long
Private Declare Function SetViewportExtExAny Lib "gdi32" _
   Alias "SetViewportExtEx" ( _
   ByVal hDC As Long, ByVal nX As Long, _
   ByVal nY As Long, lpSize As Any) As Long

Private Declare Function SetStretchBltMode Lib "gdi32" ( _
   ByVal hDC As Long, ByVal nStretchMode As Long) As Long
Private Const STRETCH_DELETESCANS = 3
Private Const STRETCH_HALFTONE = 4

Private Declare Function BitBlt Lib "gdi32" ( _
   ByVal hdcDest As Long, ByVal x As Long, ByVal y As Long, _
   ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, _
   ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
   Destination As Any, Source As Any, ByVal Length As Long)

Private Const CF_ENHMETAFILE = 14
'-------------------------------------------------------------------------------

Private m_hEMF As Long


Public Function Load(ByVal FileName As String, Image As Image) As Boolean
Dim pic As StdPicture
Dim rc As RECT
Dim hdcRef As Long
Dim hdcMeta As Long
Dim hdcMem As Long
Dim bm As BITMAP
Dim cbSize As Long
Dim cbCopied As Long
Dim hbmpOld As Long
Dim iWidthMM As Long
Dim iHeightMM As Long
Dim iWidthPels As Long
Dim iHeightPels As Long
Dim nDotPos As Integer

ReleaseResources

'Выделение расширения имени файла, принятие решения, идти по длинному пути
'или по короткому.
    FileName = Trim$(FileName)
    nDotPos = InStrRev(FileName, ".")
    If nDotPos > InStrRev(FileName, "\") Then
        Select Case UCase$(Mid$(FileName, nDotPos + 1))
        Case "WMF", "EMF", "ICO", "BMP", "DIB":
           'Если хотим пользоваться STRETCH_HALFTONE (см. ниже),
           'то BMP и DIB из списка убрать.
           'Считаем, что окно фильтра для простых форматов не появляется,
           'грузим изображение через свойство Picture.
           On Error Resume Next
           Image.Picture = FileName
           Load = Err = 0
           On Error GoTo 0
           Exit Function
        End Select
    End If

'До конца функции - загрузка изображения через свойство PictureData.
    On Error Resume Next
    Set pic = LoadPicture(FileName)
    On Error GoTo 0
    If pic Is Nothing Then
        'Ещё попытка - для форматов типа PNG, PCX, TGA, не понимаемых LoadPicture
        On Error Resume Next
        Image.Picture = FileName
        Load = Err = 0
        On Error GoTo 0
        Exit Function
    End If

'Ожидается pic.Type=vbPicTypeBitmap=1,GetObjectType(pic.Handle)=OBJ_BITMAP=7
    If GetObjectType(pic.Handle) <> OBJ_BITMAP Then Exit Function

'Получаем заголовок битмапа, чтобы извлечь из него размеры изображения
'в пикселях
    cbSize = LenB(bm)
    cbCopied = GetObjectA(pic.Handle, cbSize, bm)
    If cbCopied <> cbSize Then Exit Function

'Считаем, что Image.Parent.hWnd - дескриптор окна формы
    hdcRef = GetDC(Image.Parent.hWnd)
    
    iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE)
    iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE)
    iWidthPels = GetDeviceCaps(hdcRef, HORZRES)
    iHeightPels = GetDeviceCaps(hdcRef, VERTRES)
    
    rc.Right = bm.bmWidth * iWidthMM * 100 / iWidthPels
    rc.Bottom = bm.bmHeight * iHeightMM * 100 / iHeightPels

'Создаём "усовершенствованный" метафайл в памяти
    hdcMeta = CreateEnhMetaFile(hdcRef, vbNullString, rc, vbNullString)

    If hdcMeta = 0 Then
        ReleaseDC Image.Parent.hWnd, hdcRef
        Exit Function
    End If
    
    SetMapMode hdcMeta, MM_ANISOTROPIC
    SetWindowExtExAny hdcMeta, bm.bmWidth, bm.bmHeight, ByVal 0&
    SetViewportExtExAny hdcMeta, bm.bmWidth, bm.bmHeight, ByVal 0&
'Access с целью совместимости с Win9x использует режим STRETCH_DELETESCANS,
'он быстрее, но менее качественный, чем STRETCH_HALFTONE. Последний доступен
'в NT/200x/XP.
    SetStretchBltMode hdcMeta, STRETCH_HALFTONE 'STRETCH_DELETESCANS
    
    hdcMem = CreateCompatibleDC(hdcRef)
    hbmpOld = SelectObject(hdcMem, pic.Handle)
    
    BitBlt hdcMeta, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY
    
    SelectObject hdcMem, hbmpOld
    DeleteDC hdcMem
    ReleaseDC Image.Parent.hWnd, hdcRef
    Set pic = Nothing 'освобождаем память
    
    m_hEMF = CloseEnhMetaFile(hdcMeta)
    If m_hEMF = 0 Then Exit Function
    
    cbSize = GetEnhMetaFileBits(m_hEMF, 0, ByVal 0&)
    ReDim bPicData(0 To cbSize + 7) As Byte
    cbCopied = GetEnhMetaFileBits(m_hEMF, cbSize, bPicData(8))
    
    bPicData(0) = CF_ENHMETAFILE
    CopyMemory bPicData(4), m_hEMF, 4 'хотя можно и побайтно заполнить
    Image.PictureData = bPicData
    Erase bPicData 'освобождаем память
    
    Load = True
End Function
Private Sub ReleaseResources()
    If m_hEMF Then
        DeleteEnhMetaFile m_hEMF
        m_hEMF = 0
    End If
End Sub

Private Sub Class_Terminate()
    ReleaseResources
End Sub
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612506
_СергейВП
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
wladimirrr,

У вас обьявлены переменные и апи функции для работы только в 32х битных версиях оффиса.
Вам надо анализировать в какой версии идет запуск вашего приложения и в зависимости от этого обьявлять пернменные и апи функции.
Я, например, анализировал версию VBA.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612510
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
_СергейВПwladimirrr,

У вас обьявлены переменные и апи функции для работы только в 32х битных версиях оффиса.
Вам надо анализировать в какой версии идет запуск вашего приложения и в зависимости от этого обьявлять пернменные и апи функции.
Я, например, анализировал версию VBA.

Я предполагал это, но сделать эти изменения у меня нет нужных знаний и умений. Насколько это объемная работа?
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612517
_СергейВП
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
wladimirrr,
Воспользуйтесь поиском по форуму, ответ найдете быстро.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612529
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
_СергейВПwladimirrr,
Воспользуйтесь поиском по форуму, ответ найдете быстро.

Поискал, только больше запутался). Автор этого кода уже давно, с 2015г. не появляется на форуме. Может кто-то сможет изменить этот код за определенное вознаграждение?
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612542
MrShin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Под катом модуль GDI plus для работы с изображениями, который я переделывал под 64 бита. Не проверял, но большинство объявлений функций должно быть, нужно также везде в функциях, использующих API проверить, что используется LongLong там, где нужно.
В инете есть почти полный список 64-х разрядных объявлений API функций, я его использую при переделывании, могу сюда выложить.

Option Compare Database
Option Explicit


'-------------------------------------------------
' Picture functions using GDIPlus-API (GDIP) |
'-------------------------------------------------

'-------------------------------------------------
' (c) mossSOFT / Sascha Trowitzsch rev. 04/2009 |
'-------------------------------------------------

'- Reference to library "OLE Automation" (stdole) needed!
'- Code work under Office 2007 and Office 2010 x86 and Office 2010 x64 (see *Remark below)

' rev. 07/2010 (Support for Office 2010 x64)
' rev. 10/2011 better Timer Support
' rev. 08/2013 InitGDIP() updated

Public Const GUID_IPicture = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}" 'IPicture

'User-defined types: ----------------------------------------------------------------------

Public Enum PicFileType
pictypeBMP = 1
pictypeGIF = 2
pictypePNG = 3
pictypeJPG = 4
End Enum

Public Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type

Public Type TSize
x As Double
y As Double
End Type


#If Win64 Then
Private Type PICTDESC
cbSizeOfStruct As Long
PicType As Long
hImage As LongPtr
xExt As Long
yExt As Long
End Type

Private Type GDIPStartupInput
GdiplusVersion As Long
DebugEventCallback As LongPtr
SuppressBackgroundThread As LongPtr
SuppressExternalCodecs As LongPtr
End Type

Private Type EncoderParameter
UUID As GUID
NumberOfValues As LongPtr
type As LongPtr
Value As LongPtr
End Type

#Else

Private Type PICTDESC
cbSizeOfStruct As Long
PicType As Long
hImage As Long
xExt As Long
yExt As Long
End Type

Private Type GDIPStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type

Private Type EncoderParameter
UUID As GUID
NumberOfValues As Long
type As Long
Value As Long
End Type
#End If

Private Type EncoderParameters
count As Long
Parameter As EncoderParameter
End Type

#If Win64 Then

'API-Declarations: ----------------------------------------------------------------------------

' G.A.: olepro32 in oleaut32 geandert. Olepro32 ist in x64 nicht verfugbar.
Private Declare PtrSafe Function OleCreatePictureIndirect Lib "oleaut32.dll" (lpPictDesc As PICTDESC, riid As GUID, ByVal fPictureOwnsHandle As LongPtr, IPic As Object) As Long

'Retrieve GUID-Type from string :
Private Declare PtrSafe Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pclsid As GUID) As Long

'Memory functions:
Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal uFlags As LongPtr, ByVal dwBytes As LongPtr) As Long
Private Declare PtrSafe Function GlobalSize Lib "kernel32.dll" (ByVal hMem As LongPtr) As Long
Private Declare PtrSafe Function GlobalLock Lib "kernel32.dll" (ByVal hMem As LongPtr) As Long
Private Declare PtrSafe Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As LongPtr) As Long
Private Declare PtrSafe Function GlobalFree Lib "kernel32" (ByVal hMem As LongPtr) As Long
Private Declare PtrSafe Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As LongPtr)
Private Declare PtrSafe Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As LongPtr, ByRef Source As Byte, ByVal Length As LongPtr)

'Modules API:
Private Declare PtrSafe Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As LongPtr) As Long
Private Declare PtrSafe Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare PtrSafe Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long

'Timer API:
Private Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As LongPtr, ByVal lpTimerFunc As LongPtr) As Long
Private Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long

'OLE-Stream functions :
Private Declare PtrSafe Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As LongPtr, ByVal fDeleteOnRelease As LongPtr, ByRef ppstm As Any) As Long
Private Declare PtrSafe Function GetHGlobalFromStream Lib "ole32.dll" (ByVal pstm As Any, ByRef phglobal As LongPtr) As Long


'GDIPlus Flat-API declarations:

'Initialization GDIP:
Private Declare PtrSafe Function GdiplusStartup Lib "gdiplus" (token As LongPtr, inputbuf As GDIPStartupInput, Optional ByVal outputbuf As Long = 0) As Long
'Tear down GDIP:
Private Declare PtrSafe Function GdiplusShutdown Lib "gdiplus" (ByVal token As LongPtr) As Long
'Load GDIP-Image from file :
Private Declare PtrSafe Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal FileName As LongPtr, BITMAP As LongPtr) As Long
'Create GDIP- graphical area from Windows-DeviceContext:
Private Declare PtrSafe Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As LongPtr, GpGraphics As LongPtr) As Long
'Delete GDIP graphical area :
Private Declare PtrSafe Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As LongPtr) As Long
'Copy GDIP-Image to graphical area:
Private Declare PtrSafe Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As LongPtr, ByVal Image As LongPtr, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As Long
'Clear allocated bitmap memory from GDIP :
Private Declare PtrSafe Function GdipDisposeImage Lib "gdiplus" (ByVal Image As LongPtr) As Long
'Retrieve windows bitmap handle from GDIP-Image:
Private Declare PtrSafe Function GdipCreateHBITMAPFromBitmap Lib "gdiplus" (ByVal BITMAP As LongPtr, hbmReturn As LongPtr, ByVal background As LongPtr) As Long
'Retrieve Windows-Icon-Handle from GDIP-Image:
Public Declare PtrSafe Function GdipCreateHICONFromBitmap Lib "gdiplus" (ByVal BITMAP As LongPtr, hbmReturn As LongPtr) As Long
'Scaling GDIP-Image size:
Private Declare PtrSafe Function GdipGetImageThumbnail Lib "gdiplus" (ByVal Image As LongPtr, ByVal thumbWidth As LongPtr, ByVal thumbHeight As LongPtr, thumbImage As LongPtr, Optional ByVal callback As LongPtr = 0, Optional ByVal callbackData As LongPtr = 0) As Long
'Retrieve GDIP-Image from Windows-Bitmap-Handle:
Private Declare PtrSafe Function GdipCreateBitmapFromHBITMAP Lib "gdiplus" (ByVal hbm As LongPtr, ByVal hpal As LongPtr, BITMAP As LongPtr) As Long
'Retrieve GDIP-Image from Windows-Icon-Handle:
Private Declare PtrSafe Function GdipCreateBitmapFromHICON Lib "gdiplus" (ByVal hicon As LongPtr, BITMAP As LongPtr) As Long
'Retrieve width of a GDIP-Image (Pixel):
Private Declare PtrSafe Function GdipGetImageWidth Lib "gdiplus" (ByVal Image As LongPtr, Width As LongPtr) As Long
'Retrieve height of a GDIP-Image (Pixel):
Private Declare PtrSafe Function GdipGetImageHeight Lib "gdiplus" (ByVal Image As LongPtr, Height As LongPtr) As Long
'Save GDIP-Image to file in seletable format:
Private Declare PtrSafe Function GdipSaveImageToFile Lib "gdiplus" (ByVal Image As LongPtr, ByVal FileName As LongPtr, clsidEncoder As GUID, encoderParams As Any) As Long
'Save GDIP-Image in OLE-Stream with seletable format:
Private Declare PtrSafe Function GdipSaveImageToStream Lib "gdiplus" (ByVal Image As LongPtr, ByVal stream As IUnknown, clsidEncoder As GUID, encoderParams As Any) As Long
'Retrieve GDIP-Image from OLE-Stream-Object:
Private Declare PtrSafe Function GdipLoadImageFromStream Lib "gdiplus" (ByVal stream As IUnknown, Image As LongPtr) As Long
'Create a gdip image from scratch
Private Declare PtrSafe Function GdipCreateBitmapFromScan0 Lib "gdiplus" (ByVal Width As Long, ByVal Height As Long, ByVal stride As Long, ByVal PixelFormat As Long, scan0 As Any, BITMAP As Long) As Long
'Get the DC of an gdip image
Private Declare PtrSafe Function GdipGetImageGraphicsContext Lib "gdiplus" (ByVal Image As LongPtr, graphics As LongPtr) As Long
'Blit the contents of an gdip image to another image DC using positioning
Private Declare PtrSafe Function GdipDrawImageRectRectI Lib "gdiplus" (ByVal graphics As LongPtr, ByVal Image As LongPtr, ByVal dstx As Long, ByVal dsty As Long, ByVal dstwidth As Long, ByVal dstheight As Long, ByVal srcx As Long, ByVal srcy As Long, ByVal srcwidth As Long, ByVal srcheight As Long, ByVal srcUnit As Long, Optional ByVal imageAttributes As Long = 0, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long


'-----------------------------------------------------------------------------------------
'Global module variable:
Private lGDIP As LongPtr
'-----------------------------------------------------------------------------------------

Public TempVarGDIPlus As LongPtr
#Else

'API-Declarations: ----------------------------------------------------------------------------

'Convert a windows bitmap to OLE-Picture :
Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (lpPictDesc As PICTDESC, riid As GUID, ByVal fPictureOwnsHandle As Long, IPic As Object) As Long
'Retrieve GUID-Type from string :
Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pclsid As GUID) As Long

'Memory functions:
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalSize Lib "kernel32.dll" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32.dll" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByRef Source As Byte, ByVal Length As Long)

'Modules API:
Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long

'Timer API:
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long


'OLE-Stream functions :
Private Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As Long, ByVal fDeleteOnRelease As Long, ByRef ppstm As Any) As Long
Private Declare Function GetHGlobalFromStream Lib "ole32.dll" (ByVal pstm As Any, ByRef phglobal As Long) As Long

'GDIPlus Flat-API declarations:

'Initialization GDIP:
Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GDIPStartupInput, Optional ByVal outputbuf As Long = 0) As Long
'Tear down GDIP:
Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As Long
'Load GDIP-Image from file :
Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal FileName As Long, BITMAP As Long) As Long
'Create GDIP- graphical area from Windows-DeviceContext:
Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As Long, GpGraphics As Long) As Long
'Delete GDIP graphical area :
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
'Copy GDIP-Image to graphical area:
Private Declare Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As Long, ByVal Image As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As Long
'Clear allocated bitmap memory from GDIP :
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal Image As Long) As Long
'Retrieve windows bitmap handle from GDIP-Image:
Private Declare Function GdipCreateHBITMAPFromBitmap Lib "gdiplus" (ByVal BITMAP As Long, hbmReturn As Long, ByVal background As Long) As Long
'Retrieve Windows-Icon-Handle from GDIP-Image:
Public Declare Function GdipCreateHICONFromBitmap Lib "gdiplus" (ByVal BITMAP As Long, hbmReturn As Long) As Long
'Scaling GDIP-Image size:
Private Declare Function GdipGetImageThumbnail Lib "gdiplus" (ByVal Image As Long, ByVal thumbWidth As Long, ByVal thumbHeight As Long, thumbImage As Long, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long
'Retrieve GDIP-Image from Windows-Bitmap-Handle:
Private Declare Function GdipCreateBitmapFromHBITMAP Lib "gdiplus" (ByVal hbm As Long, ByVal hpal As Long, BITMAP As Long) As Long
'Retrieve GDIP-Image from Windows-Icon-Handle:
Private Declare Function GdipCreateBitmapFromHICON Lib "gdiplus" (ByVal hicon As Long, BITMAP As Long) As Long
'Retrieve width of a GDIP-Image (Pixel):
Private Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal Image As Long, Width As Long) As Long
'Retrieve height of a GDIP-Image (Pixel):
Private Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal Image As Long, Height As Long) As Long
'Save GDIP-Image to file in seletable format:
Private Declare Function GdipSaveImageToFile Lib "gdiplus" (ByVal Image As Long, ByVal FileName As Long, clsidEncoder As GUID, encoderParams As Any) As Long
'Save GDIP-Image in OLE-Stream with seletable format:
Private Declare Function GdipSaveImageToStream Lib "gdiplus" (ByVal Image As Long, ByVal stream As IUnknown, clsidEncoder As GUID, encoderParams As Any) As Long
'Retrieve GDIP-Image from OLE-Stream-Object:
Private Declare Function GdipLoadImageFromStream Lib "gdiplus" (ByVal stream As IUnknown, Image As Long) As Long
'Create a gdip image from scratch
Private Declare Function GdipCreateBitmapFromScan0 Lib "gdiplus" (ByVal Width As Long, ByVal Height As Long, ByVal stride As Long, ByVal PixelFormat As Long, scan0 As Any, BITMAP As Long) As Long
'Get the DC of an gdip image
Private Declare Function GdipGetImageGraphicsContext Lib "gdiplus" (ByVal Image As Long, graphics As Long) As Long
'Blit the contents of an gdip image to another image DC using positioning
Private Declare Function GdipDrawImageRectRectI Lib "gdiplus" (ByVal graphics As Long, ByVal Image As Long, ByVal dstx As Long, ByVal dsty As Long, ByVal dstwidth As Long, ByVal dstheight As Long, ByVal srcx As Long, ByVal srcy As Long, ByVal srcwidth As Long, ByVal srcheight As Long, ByVal srcUnit As Long, Optional ByVal imageAttributes As Long = 0, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long

'-----------------------------------------------------------------------------------------
'Global module variable:
Private lGDIP As Long

#End If

Private tVarTimer() As Long
Private lCounter As Long
Private bSharedLoad As Boolean


'Initialize GDI+
Function InitGDIP() As Boolean
Dim TGDP As GDIPStartupInput
Dim hMod As Long


'Debug.Print Now(), "InitGDIP"

If lGDIP = 0 Then
#If Win64 Then
If TempVarGDIPlus = 0 Then 'If lGDIP is broken due to unhandled errors restore it from the Tempvars collection
TGDP.GdiplusVersion = 1
hMod = GetModuleHandle("gdiplus.dll") 'ogl.dll not yet loaded?
If hMod = 0 Then
hMod = LoadLibrary("gdiplus.dll")
bSharedLoad = False
Else
bSharedLoad = True
End If
GdiplusStartup lGDIP, TGDP 'Get a personal instance of gdiplus
TempVarGDIPlus = lGDIP

Else
lGDIP = TempVarGDIPlus
End If

#Else
If IsNull(TempVars("GDIPlusHandle")) Then
'Debug.Print Now(), "InitGDIP, start INIT"
TGDP.GdiplusVersion = 1
hMod = GetModuleHandle("gdiplus.dll")
If hMod = 0 Then
hMod = LoadLibrary("gdiplus.dll")
bSharedLoad = False
Else
bSharedLoad = True
End If
GdiplusStartup lGDIP, TGDP
TempVars("GDIPlusHandle") = lGDIP
Else
lGDIP = TempVars("GDIPlusHandle")
End If

#End If

End If

InitGDIP = (lGDIP <> 0)
'Debug.Print Now(), "InitGDIP End", lGDIP

AutoShutDown

End Function


'Clear GDI+
Sub ShutDownGDIP()
'Debug.Print Now(), "ShutDownGDIP"

If lGDIP <> 0 Then

Dim lngDummy As Long
Dim lngDummyTimer As Long
For lngDummy = 0 To lCounter - 1
lngDummyTimer = tVarTimer(lngDummy)

If lngDummyTimer <> 0 Then
If KillTimer(0&, CLng(lngDummyTimer)) Then
'Debug.Print Now(), "ShutDownGDIP, Timer " & CLng(lngDummyTimer) & " KILLED"
tVarTimer(lngDummy) = 0
End If

End If
Next

GdiplusShutdown lGDIP
lGDIP = 0

#If Win64 Then
TempVarGDIPlus = 0
#Else
TempVars("GDIPlusHandle") = Null
#End If

If Not bSharedLoad Then FreeLibrary GetModuleHandle("gdiplus.dll")

End If

End Sub

'Scheduled ShutDown of GDI+ handle to avoid memory leaks
Private Sub AutoShutDown()
'Set to 5 seconds for next shutdown
'That's IMO appropriate for looped routines - but configure for your own purposes

If lGDIP <> 0 Then
ReDim Preserve tVarTimer(lCounter)
tVarTimer(lCounter) = SetTimer(0&, 0&, 5000, AddressOf TimerProc)
'Debug.Print Now(), "AutoShutDown SET", tVarTimer(lCounter), lCounter
End If
'Debug.Print Now(), "AutoShutDown", tVarTimer(lCounter), lCounter
lCounter = lCounter + 1

End Sub

'Callback for AutoShutDown
Private Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
'Debug.Print Now(), "TimerProc Start"

ShutDownGDIP

'Debug.Print Now(), "TimerProc End"
End Sub

'Load image file with GDIP
'It's equivalent to the method LoadPicture() in OLE-Automation library (stdole2.tlb)
'Allowed format: bmp, gif, jp(e)g, tif, png, wmf, emf, ico
Function LoadPictureGDIP(sFileName As String) As StdPicture
#If Win64 Then
Dim hBmp As LongPtr
Dim hPic As LongPtr
#Else
Dim hBmp As Long
Dim hPic As Long
#End If

If Not InitGDIP Then Exit Function

If GdipCreateBitmapFromFile(StrPtr(sFileName), hPic) = 0 Then

GdipCreateHBITMAPFromBitmap hPic, hBmp, 0&

If hBmp <> 0 Then
Set LoadPictureGDIP = BitmapToPicture(hBmp)
GdipDisposeImage hPic
End If
End If

End Function


'Create an OLE-Picture from Byte-Array PicBin()
Public Function ArrayToPicture(ByRef PicBin() As Byte) As Picture

Dim IStm As IUnknown
#If Win64 Then
Dim lBitmap As LongPtr
Dim hBmp As LongPtr
#Else
Dim lBitmap As Long
Dim hBmp As Long
#End If

Dim ret As Long

'Debug.Print Now(), "ArrayToPicture"

If Not InitGDIP Then
'Debug.Print "Exit"
Exit Function
End If

ret = CreateStreamOnHGlobal(VarPtr(PicBin(0)), 0, IStm) 'Create stream from memory stack

If ret = 0 Then 'OK, start GDIP :
'Convert stream to GDIP-Image :
ret = GdipLoadImageFromStream(IStm, lBitmap)
If ret = 0 Then
'Get Windows-Bitmap from GDIP-Image:
GdipCreateHBITMAPFromBitmap lBitmap, hBmp, 0&
If hBmp <> 0 Then
'Convert bitmap to picture object :
Set ArrayToPicture = BitmapToPicture(hBmp)
End If
End If
'Clear memory ...
GdipDisposeImage lBitmap
End If

End Function

#If Win64 Then
'Help function to get a OLE-Picture from Windows-Bitmap-Handle
'If bIsIcon = TRUE, an Icon-Handle is commited
Function BitmapToPicture(ByVal hBmp As LongPtr, Optional bIsIcon As Boolean = False) As StdPicture

Dim TPicConv As PICTDESC, UID As GUID

With TPicConv
If bIsIcon Then
.cbSizeOfStruct = 16
.PicType = 3 'PicType Icon
Else
.cbSizeOfStruct = Len(TPicConv)
.PicType = 1 'PicType Bitmap
End If
.hImage = hBmp
End With

CLSIDFromString StrPtr(GUID_IPicture), UID
OleCreatePictureIndirect TPicConv, UID, True, BitmapToPicture

End Function
#Else
Function BitmapToPicture(ByVal hBmp As Long, Optional bIsIcon As Boolean = False) As StdPicture

Dim TPicConv As PICTDESC, UID As GUID

With TPicConv
If bIsIcon Then
.cbSizeOfStruct = 16
.PicType = 3 'PicType Icon
Else
.cbSizeOfStruct = Len(TPicConv)
.PicType = 1 'PicType Bitmap
End If
.hImage = hBmp
End With

CLSIDFromString StrPtr(GUID_IPicture), UID
OleCreatePictureIndirect TPicConv, UID, True, BitmapToPicture

End Function
#End If
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612544
MrShin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Забыл тэг кода поставить, сорри.

Код: vbnet
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.
Option Compare Database
Option Explicit


'-------------------------------------------------
'    Picture functions using GDIPlus-API (GDIP)   |
'-------------------------------------------------

'-------------------------------------------------
'   (c) mossSOFT / Sascha Trowitzsch rev. 04/2009 |
'-------------------------------------------------

'- Reference to library "OLE Automation" (stdole) needed!
'- Code work under Office 2007 and Office 2010 x86 and Office 2010 x64 (see *Remark below)

'  rev. 07/2010 (Support for Office 2010 x64)
'  rev. 10/2011 better Timer Support
'  rev. 08/2013 InitGDIP() updated

Public Const GUID_IPicture = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"    'IPicture

'User-defined types: ----------------------------------------------------------------------

Public Enum PicFileType
    pictypeBMP = 1
    pictypeGIF = 2
    pictypePNG = 3
    pictypeJPG = 4
End Enum

Public Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(7) As Byte
End Type

Public Type TSize
    x As Double
    y As Double
End Type


#If Win64 Then
    Private Type PICTDESC
        cbSizeOfStruct As Long
        PicType As Long
        hImage As LongPtr
        xExt As Long
        yExt As Long
    End Type
    
    Private Type GDIPStartupInput
        GdiplusVersion As Long
        DebugEventCallback As LongPtr
        SuppressBackgroundThread As LongPtr
        SuppressExternalCodecs As LongPtr
    End Type
    
    Private Type EncoderParameter
        UUID As GUID
        NumberOfValues As LongPtr
        type As LongPtr
        Value As LongPtr
    End Type
    
#Else

    Private Type PICTDESC
        cbSizeOfStruct As Long
        PicType As Long
        hImage As Long
        xExt As Long
        yExt As Long
    End Type
    
    Private Type GDIPStartupInput
        GdiplusVersion As Long
        DebugEventCallback As Long
        SuppressBackgroundThread As Long
        SuppressExternalCodecs As Long
    End Type
    
    Private Type EncoderParameter
        UUID As GUID
        NumberOfValues As Long
        type As Long
        Value As Long
    End Type
#End If

Private Type EncoderParameters
    count As Long
    Parameter As EncoderParameter
End Type

#If Win64 Then

    'API-Declarations: ----------------------------------------------------------------------------
    
    ' G.A.: olepro32 in oleaut32 geandert. Olepro32 ist in x64 nicht verfugbar.
    Private Declare PtrSafe Function OleCreatePictureIndirect Lib "oleaut32.dll" (lpPictDesc As PICTDESC, riid As GUID, ByVal fPictureOwnsHandle As LongPtr, IPic As Object) As Long
    
    'Retrieve GUID-Type from string :
    Private Declare PtrSafe Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pclsid As GUID) As Long
    
    'Memory functions:
    Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal uFlags As LongPtr, ByVal dwBytes As LongPtr) As Long
    Private Declare PtrSafe Function GlobalSize Lib "kernel32.dll" (ByVal hMem As LongPtr) As Long
    Private Declare PtrSafe Function GlobalLock Lib "kernel32.dll" (ByVal hMem As LongPtr) As Long
    Private Declare PtrSafe Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As LongPtr) As Long
    Private Declare PtrSafe Function GlobalFree Lib "kernel32" (ByVal hMem As LongPtr) As Long
    Private Declare PtrSafe Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As LongPtr)
    Private Declare PtrSafe Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As LongPtr, ByRef Source As Byte, ByVal Length As LongPtr)

    'Modules API:
    Private Declare PtrSafe Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As LongPtr) As Long
    Private Declare PtrSafe Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
    Private Declare PtrSafe Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
    
    'Timer API:
    Private Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As LongPtr, ByVal lpTimerFunc As LongPtr) As Long
    Private Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long

    'OLE-Stream functions :
    Private Declare PtrSafe Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As LongPtr, ByVal fDeleteOnRelease As LongPtr, ByRef ppstm As Any) As Long
    Private Declare PtrSafe Function GetHGlobalFromStream Lib "ole32.dll" (ByVal pstm As Any, ByRef phglobal As LongPtr) As Long
    
    
    'GDIPlus Flat-API declarations:
    
    'Initialization GDIP:
    Private Declare PtrSafe Function GdiplusStartup Lib "gdiplus" (token As LongPtr, inputbuf As GDIPStartupInput, Optional ByVal outputbuf As Long = 0) As Long
    'Tear down GDIP:
    Private Declare PtrSafe Function GdiplusShutdown Lib "gdiplus" (ByVal token As LongPtr) As Long
    'Load GDIP-Image from file :
    Private Declare PtrSafe Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal FileName As LongPtr, BITMAP As LongPtr) As Long
    'Create GDIP- graphical area from Windows-DeviceContext:
    Private Declare PtrSafe Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As LongPtr, GpGraphics As LongPtr) As Long
    'Delete GDIP graphical area :
    Private Declare PtrSafe Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As LongPtr) As Long
    'Copy GDIP-Image to graphical area:
    Private Declare PtrSafe Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As LongPtr, ByVal Image As LongPtr, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As Long
    'Clear allocated bitmap memory from GDIP :
    Private Declare PtrSafe Function GdipDisposeImage Lib "gdiplus" (ByVal Image As LongPtr) As Long
    'Retrieve windows bitmap handle from GDIP-Image:
    Private Declare PtrSafe Function GdipCreateHBITMAPFromBitmap Lib "gdiplus" (ByVal BITMAP As LongPtr, hbmReturn As LongPtr, ByVal background As LongPtr) As Long
    'Retrieve Windows-Icon-Handle from GDIP-Image:
    Public Declare PtrSafe Function GdipCreateHICONFromBitmap Lib "gdiplus" (ByVal BITMAP As LongPtr, hbmReturn As LongPtr) As Long
    'Scaling GDIP-Image size:
    Private Declare PtrSafe Function GdipGetImageThumbnail Lib "gdiplus" (ByVal Image As LongPtr, ByVal thumbWidth As LongPtr, ByVal thumbHeight As LongPtr, thumbImage As LongPtr, Optional ByVal callback As LongPtr = 0, Optional ByVal callbackData As LongPtr = 0) As Long
    'Retrieve GDIP-Image from Windows-Bitmap-Handle:
    Private Declare PtrSafe Function GdipCreateBitmapFromHBITMAP Lib "gdiplus" (ByVal hbm As LongPtr, ByVal hpal As LongPtr, BITMAP As LongPtr) As Long
    'Retrieve GDIP-Image from Windows-Icon-Handle:
    Private Declare PtrSafe Function GdipCreateBitmapFromHICON Lib "gdiplus" (ByVal hicon As LongPtr, BITMAP As LongPtr) As Long
    'Retrieve width of a GDIP-Image (Pixel):
    Private Declare PtrSafe Function GdipGetImageWidth Lib "gdiplus" (ByVal Image As LongPtr, Width As LongPtr) As Long
    'Retrieve height of a GDIP-Image (Pixel):
    Private Declare PtrSafe Function GdipGetImageHeight Lib "gdiplus" (ByVal Image As LongPtr, Height As LongPtr) As Long
    'Save GDIP-Image to file in seletable format:
    Private Declare PtrSafe Function GdipSaveImageToFile Lib "gdiplus" (ByVal Image As LongPtr, ByVal FileName As LongPtr, clsidEncoder As GUID, encoderParams As Any) As Long
    'Save GDIP-Image in OLE-Stream with seletable format:
    Private Declare PtrSafe Function GdipSaveImageToStream Lib "gdiplus" (ByVal Image As LongPtr, ByVal stream As IUnknown, clsidEncoder As GUID, encoderParams As Any) As Long
    'Retrieve GDIP-Image from OLE-Stream-Object:
    Private Declare PtrSafe Function GdipLoadImageFromStream Lib "gdiplus" (ByVal stream As IUnknown, Image As LongPtr) As Long
    'Create a gdip image from scratch
    Private Declare PtrSafe Function GdipCreateBitmapFromScan0 Lib "gdiplus" (ByVal Width As Long, ByVal Height As Long, ByVal stride As Long, ByVal PixelFormat As Long, scan0 As Any, BITMAP As Long) As Long
    'Get the DC of an gdip image
    Private Declare PtrSafe Function GdipGetImageGraphicsContext Lib "gdiplus" (ByVal Image As LongPtr, graphics As LongPtr) As Long
    'Blit the contents of an gdip image to another image DC using positioning
    Private Declare PtrSafe Function GdipDrawImageRectRectI Lib "gdiplus" (ByVal graphics As LongPtr, ByVal Image As LongPtr, ByVal dstx As Long, ByVal dsty As Long, ByVal dstwidth As Long, ByVal dstheight As Long, ByVal srcx As Long, ByVal srcy As Long, ByVal srcwidth As Long, ByVal srcheight As Long, ByVal srcUnit As Long, Optional ByVal imageAttributes As Long = 0, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long

    
    '-----------------------------------------------------------------------------------------
    'Global module variable:
    Private lGDIP As LongPtr
    '-----------------------------------------------------------------------------------------
    
    Public TempVarGDIPlus As LongPtr
#Else

    'API-Declarations: ----------------------------------------------------------------------------
    
    'Convert a windows bitmap to OLE-Picture :
    Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (lpPictDesc As PICTDESC, riid As GUID, ByVal fPictureOwnsHandle As Long, IPic As Object) As Long
    'Retrieve GUID-Type from string :
    Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpsz As Any, pclsid As GUID) As Long
    
    'Memory functions:
    Private Declare Function GlobalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal dwBytes As Long) As Long
    Private Declare Function GlobalSize Lib "kernel32.dll" (ByVal hMem As Long) As Long
    Private Declare Function GlobalLock Lib "kernel32.dll" (ByVal hMem As Long) As Long
    Private Declare Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As Long) As Long
    Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
    Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByRef Source As Byte, ByVal Length As Long)
    
    'Modules API:
    Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
    Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
    Private Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
    
    'Timer API:
    Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    
    
    'OLE-Stream functions :
    Private Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As Long, ByVal fDeleteOnRelease As Long, ByRef ppstm As Any) As Long
    Private Declare Function GetHGlobalFromStream Lib "ole32.dll" (ByVal pstm As Any, ByRef phglobal As Long) As Long
    
    'GDIPlus Flat-API declarations:
    
    'Initialization GDIP:
    Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GDIPStartupInput, Optional ByVal outputbuf As Long = 0) As Long
    'Tear down GDIP:
    Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As Long
    'Load GDIP-Image from file :
    Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal FileName As Long, BITMAP As Long) As Long
    'Create GDIP- graphical area from Windows-DeviceContext:
    Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As Long, GpGraphics As Long) As Long
    'Delete GDIP graphical area :
    Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
    'Copy GDIP-Image to graphical area:
    Private Declare Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As Long, ByVal Image As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As Long
    'Clear allocated bitmap memory from GDIP :
    Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal Image As Long) As Long
    'Retrieve windows bitmap handle from GDIP-Image:
    Private Declare Function GdipCreateHBITMAPFromBitmap Lib "gdiplus" (ByVal BITMAP As Long, hbmReturn As Long, ByVal background As Long) As Long
    'Retrieve Windows-Icon-Handle from GDIP-Image:
    Public Declare Function GdipCreateHICONFromBitmap Lib "gdiplus" (ByVal BITMAP As Long, hbmReturn As Long) As Long
    'Scaling GDIP-Image size:
    Private Declare Function GdipGetImageThumbnail Lib "gdiplus" (ByVal Image As Long, ByVal thumbWidth As Long, ByVal thumbHeight As Long, thumbImage As Long, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long
    'Retrieve GDIP-Image from Windows-Bitmap-Handle:
    Private Declare Function GdipCreateBitmapFromHBITMAP Lib "gdiplus" (ByVal hbm As Long, ByVal hpal As Long, BITMAP As Long) As Long
    'Retrieve GDIP-Image from Windows-Icon-Handle:
    Private Declare Function GdipCreateBitmapFromHICON Lib "gdiplus" (ByVal hicon As Long, BITMAP As Long) As Long
    'Retrieve width of a GDIP-Image (Pixel):
    Private Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal Image As Long, Width As Long) As Long
    'Retrieve height of a GDIP-Image (Pixel):
    Private Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal Image As Long, Height As Long) As Long
    'Save GDIP-Image to file in seletable format:
    Private Declare Function GdipSaveImageToFile Lib "gdiplus" (ByVal Image As Long, ByVal FileName As Long, clsidEncoder As GUID, encoderParams As Any) As Long
    'Save GDIP-Image in OLE-Stream with seletable format:
    Private Declare Function GdipSaveImageToStream Lib "gdiplus" (ByVal Image As Long, ByVal stream As IUnknown, clsidEncoder As GUID, encoderParams As Any) As Long
    'Retrieve GDIP-Image from OLE-Stream-Object:
    Private Declare Function GdipLoadImageFromStream Lib "gdiplus" (ByVal stream As IUnknown, Image As Long) As Long
    'Create a gdip image from scratch
    Private Declare Function GdipCreateBitmapFromScan0 Lib "gdiplus" (ByVal Width As Long, ByVal Height As Long, ByVal stride As Long, ByVal PixelFormat As Long, scan0 As Any, BITMAP As Long) As Long
    'Get the DC of an gdip image
    Private Declare Function GdipGetImageGraphicsContext Lib "gdiplus" (ByVal Image As Long, graphics As Long) As Long
    'Blit the contents of an gdip image to another image DC using positioning
    Private Declare Function GdipDrawImageRectRectI Lib "gdiplus" (ByVal graphics As Long, ByVal Image As Long, ByVal dstx As Long, ByVal dsty As Long, ByVal dstwidth As Long, ByVal dstheight As Long, ByVal srcx As Long, ByVal srcy As Long, ByVal srcwidth As Long, ByVal srcheight As Long, ByVal srcUnit As Long, Optional ByVal imageAttributes As Long = 0, Optional ByVal callback As Long = 0, Optional ByVal callbackData As Long = 0) As Long

    '-----------------------------------------------------------------------------------------
    'Global module variable:
    Private lGDIP As Long

#End If

Private tVarTimer() As Long
Private lCounter    As Long
Private bSharedLoad As Boolean


'Initialize GDI+
Function InitGDIP() As Boolean
    Dim TGDP As GDIPStartupInput
    Dim hMod As Long
    

    'Debug.Print Now(), "InitGDIP"

    If lGDIP = 0 Then
        #If Win64 Then
            If TempVarGDIPlus = 0 Then 'If lGDIP is broken due to unhandled errors restore it from the Tempvars collection
                TGDP.GdiplusVersion = 1
                hMod = GetModuleHandle("gdiplus.dll")    'ogl.dll not yet loaded?
                If hMod = 0 Then
                    hMod = LoadLibrary("gdiplus.dll")
                    bSharedLoad = False
                Else
                    bSharedLoad = True
                End If
                GdiplusStartup lGDIP, TGDP 'Get a personal instance of gdiplus
                TempVarGDIPlus = lGDIP
                
            Else
                lGDIP = TempVarGDIPlus
            End If
            
        #Else
            If IsNull(TempVars("GDIPlusHandle")) Then
                'Debug.Print Now(), "InitGDIP, start INIT"
                TGDP.GdiplusVersion = 1
                hMod = GetModuleHandle("gdiplus.dll")
                If hMod = 0 Then
                    hMod = LoadLibrary("gdiplus.dll")
                    bSharedLoad = False
                Else
                    bSharedLoad = True
                End If
                GdiplusStartup lGDIP, TGDP
                TempVars("GDIPlusHandle") = lGDIP
            Else
                lGDIP = TempVars("GDIPlusHandle")
            End If
            
        #End If
        
    End If
    
    InitGDIP = (lGDIP <> 0)
    'Debug.Print Now(), "InitGDIP End", lGDIP
    
    AutoShutDown
    
End Function


'Clear GDI+
Sub ShutDownGDIP()
    'Debug.Print Now(), "ShutDownGDIP"

    If lGDIP <> 0 Then
    
        Dim lngDummy As Long
        Dim lngDummyTimer As Long
        For lngDummy = 0 To lCounter - 1
            lngDummyTimer = tVarTimer(lngDummy)
                        
            If lngDummyTimer <> 0 Then
                If KillTimer(0&, CLng(lngDummyTimer)) Then
                    'Debug.Print Now(), "ShutDownGDIP, Timer " & CLng(lngDummyTimer) & " KILLED"
                    tVarTimer(lngDummy) = 0
                End If
            
            End If
        Next
            
        GdiplusShutdown lGDIP
        lGDIP = 0
        
        #If Win64 Then
            TempVarGDIPlus = 0
        #Else
            TempVars("GDIPlusHandle") = Null
        #End If
        
        If Not bSharedLoad Then FreeLibrary GetModuleHandle("gdiplus.dll")
        
    End If
       
End Sub

'Scheduled ShutDown of GDI+ handle to avoid memory leaks
Private Sub AutoShutDown()
    'Set to 5 seconds for next shutdown
    'That's IMO appropriate for looped routines  - but configure for your own purposes
 
    If lGDIP <> 0 Then
        ReDim Preserve tVarTimer(lCounter)
        tVarTimer(lCounter) = SetTimer(0&, 0&, 5000, AddressOf TimerProc)
        'Debug.Print Now(), "AutoShutDown SET", tVarTimer(lCounter), lCounter
    End If
    'Debug.Print Now(), "AutoShutDown", tVarTimer(lCounter), lCounter
    lCounter = lCounter + 1
    
End Sub

'Callback for AutoShutDown
Private Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
    'Debug.Print Now(), "TimerProc Start"
    
    ShutDownGDIP

    'Debug.Print Now(), "TimerProc End"
End Sub

'Load image file with GDIP
'It's equivalent to the method LoadPicture() in OLE-Automation library (stdole2.tlb)
'Allowed format: bmp, gif, jp(e)g, tif, png, wmf, emf, ico
Function LoadPictureGDIP(sFileName As String) As StdPicture
    #If Win64 Then
        Dim hBmp As LongPtr
        Dim hPic As LongPtr
    #Else
        Dim hBmp As Long
        Dim hPic As Long
    #End If
    
    If Not InitGDIP Then Exit Function
    
        If GdipCreateBitmapFromFile(StrPtr(sFileName), hPic) = 0 Then
   
        GdipCreateHBITMAPFromBitmap hPic, hBmp, 0&
    
        If hBmp <> 0 Then
            Set LoadPictureGDIP = BitmapToPicture(hBmp)
            GdipDisposeImage hPic
        End If
    End If

End Function


'Create an OLE-Picture from Byte-Array PicBin()
Public Function ArrayToPicture(ByRef PicBin() As Byte) As Picture

    Dim IStm As IUnknown
    #If Win64 Then
        Dim lBitmap As LongPtr
        Dim hBmp As LongPtr
    #Else
        Dim lBitmap As Long
        Dim hBmp As Long
    #End If

    Dim ret As Long

    'Debug.Print Now(), "ArrayToPicture"
    
    If Not InitGDIP Then
        'Debug.Print "Exit"
        Exit Function
    End If

    ret = CreateStreamOnHGlobal(VarPtr(PicBin(0)), 0, IStm)  'Create stream from memory stack

    If ret = 0 Then    'OK, start GDIP :
        'Convert stream to GDIP-Image :
        ret = GdipLoadImageFromStream(IStm, lBitmap)
        If ret = 0 Then
            'Get Windows-Bitmap from GDIP-Image:
            GdipCreateHBITMAPFromBitmap lBitmap, hBmp, 0&
            If hBmp <> 0 Then
                'Convert bitmap to picture object :
                Set ArrayToPicture = BitmapToPicture(hBmp)
            End If
        End If
        'Clear memory ...
        GdipDisposeImage lBitmap
    End If

End Function

#If Win64 Then
    'Help function to get a OLE-Picture from Windows-Bitmap-Handle
    'If bIsIcon = TRUE, an Icon-Handle is commited
    Function BitmapToPicture(ByVal hBmp As LongPtr, Optional bIsIcon As Boolean = False) As StdPicture
        
        Dim TPicConv As PICTDESC, UID As GUID
    
        With TPicConv
            If bIsIcon Then
                .cbSizeOfStruct = 16
                .PicType = 3    'PicType Icon
            Else
                .cbSizeOfStruct = Len(TPicConv)
                .PicType = 1    'PicType Bitmap
            End If
            .hImage = hBmp
        End With
    
        CLSIDFromString StrPtr(GUID_IPicture), UID
        OleCreatePictureIndirect TPicConv, UID, True, BitmapToPicture
    
    End Function
#Else
    Function BitmapToPicture(ByVal hBmp As Long, Optional bIsIcon As Boolean = False) As StdPicture
        
        Dim TPicConv As PICTDESC, UID As GUID
    
        With TPicConv
            If bIsIcon Then
                .cbSizeOfStruct = 16
                .PicType = 3    'PicType Icon
            Else
                .cbSizeOfStruct = Len(TPicConv)
                .PicType = 1    'PicType Bitmap
            End If
            .hImage = hBmp
        End With
    
        CLSIDFromString StrPtr(GUID_IPicture), UID
        OleCreatePictureIndirect TPicConv, UID, True, BitmapToPicture
    
    End Function
#End If

...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612546
MrShin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Проверил, сам модуль уже был 64-х разрядно совместимый, я переделывал остальное приложение, там было достаточно много вызово API.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612578
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
MrShin,

Как Ваши модули интегрировать с уже используемыми в бд? Прикрепил пример базы, можете в ней проверить?
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612599
MrShin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
wladimirrr,
Из GDIplus можно взять объявления нужных вам функций, они там в 2-х вариантах, условная компиляция в зависимости от переменной Win64.
Постараюсь найти время и помочь с анализом остального кода на предмет совместимости, вы хотя бы добавьте объявления для 64-х битной среды как в моем примере.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612658
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
MrShin, спасибо большое, буду тестировать.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612699
4z4r
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Как-то тут туманно отвечают, делая секреты на пустом месте. Отвечу ссылкой и примером, надеюсь, поможет.

Код: vbnet
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.
#If VBA7 Then
' 64-разрядная система, имеется слово PtrSafe
Declare PtrSafe Function GetKeyboardLayoutName Lib "user32" _
        Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long
Declare PtrSafe Function LoadKeyboardLayout Lib "user32" _
        Alias "LoadKeyboardLayoutA" (ByVal HKL As String, _
                ByVal flags As Long) As Long
Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Declare PtrSafe Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
Declare PtrSafe Function GlobalAlloc Lib "kernel32" _
            (ByVal wFlags&, ByVal dwBytes As Long) As Long
Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Declare PtrSafe Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long
Declare PtrSafe Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
            ByVal lpString2 As Any) As Long
Declare PtrSafe Function lstrcpy2 Lib "kernel32" Alias "lstrcpy" _
        (ByVal lpString1 As Any, ByRef lpString2 As Byte) As Long
Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long
Declare PtrSafe Function SetClipboardData Lib "user32" (ByVal wFormat As Long, _
            ByVal hMem As Long) As Long
#Else
' 32-разрядная система, эти же функции БЕЗ PtrSafe 
Private Declare Function GetKeyboardLayoutName Lib "user32" _
        Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long
Private Declare Function LoadKeyboardLayout Lib "user32" _
        Alias "LoadKeyboardLayoutA" (ByVal HKL As String, _
                ByVal flags As Long) As Long
Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Declare Function CloseClipboard Lib "user32" () As Long
Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
Declare Function GlobalAlloc Lib "kernel32" _
            (ByVal wFlags&, ByVal dwBytes As Long) As Long
Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
            ByVal lpString2 As Any) As Long
Declare Function lstrcpy2 Lib "kernel32" Alias "lstrcpy" _
        (ByVal lpString1 As Any, ByRef lpString2 As Byte) As Long
Declare Function EmptyClipboard Lib "user32" () As Long
Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, _
            ByVal hMem As Long) As Long
#End If
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39612730
MrShin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
4z4r,
Не так все просто. Просто добавить PtrSafe недостаточно, нужно еще типы данных привести к 64-м разрядам. В вашем примере 64-х разрядный кусок не содержит ни одного LongPtr, который должен быть использован для указателей вместо Long в 32-х разрядной среде. Преобразование занимает время, уходит 1-3 минуты на каждый вызов, т.к. нужно найти или создать правильное 64-х разрядное объявление. Если нет готового, приходится лезть в описание API и разбираться, где укзатели, а где данные. Также просто создать правильную секцию объявлений опять-таки недостаточно, нужно внимательно проанализировать весь код, который использует эти функции и создать секции с 64-х разрядными объявлениями переменных, которые должны использоваться для работы с LongPtr. У меня ушел час на преобразование этого класса с двумя десятками вызовов. Может быть wladimirrr выложит результаты преобразования.

Я использую вот этот файл для конвертации большинства функций, но ингда и этого мало оказывается, приходится преобразовывать самому.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39615199
wladimirrr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
MrShin, большое спасибо за проведенную работу и отладку модуля. Для всех выкладываю пример базы с выводом изображений из директории для 32-х 64-х битных версий Аксесс.
...
Рейтинг: 0 / 0
Загрузка изображения из директории. Не работает в 64-битном Офисе.
    #39615442
Фотография Joss
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Вот старая статья в тему Access. Переход с 32-х разрядной системы на 64-х разрядную. (Примерное реководство)

А под спойлером пример универсального описания API для 64-х и 32-х разрядных версий Офиса и для VBA7 и VBA6. Всё сделано на основе статьи и справочного файла Win32API_PtrSafe
Код: vbnet
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.
#If VBA7 Then
'  Code is running in the new VBA7 editor
     #If Win64 Then
     '  Code is running in 64-bit version of Microsoft Office
' data buffer for the ChooseColor function
Private Type ChooseColor
        lStructSize As Long
        hwndOwner As LongPtr
        hInstance As LongPtr
        rgbResult As Long
        lpCustColors As LongPtr
        Flags As Long
        lCustData As LongPtr
        lpfnHook As LongPtr
        lpTemplateName As String
End Type
'data buffer for the GetOpenFileName and GetSaveFileName functions
Private Type OpenFilename
        lStructSize As Long
        hwndOwner As LongPtr
        hInstance As LongPtr
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        iFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        Flags As LongPtr
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As LongPtr
        lpfnHook As LongPtr
        lpTemplateName As String
'#if (_WIN32_WINNT >= 0x0500)
        pvReserved As LongPtr
        dwReserved As Long
        FlagsEx As Long
'#endif // (_WIN32_WINNT >= 0x0500)
End Type

'API function called by ChooseColor method

Private Declare PtrSafe Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long

'API function called by ShowOpen method
Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OpenFilename) As Long

'API function called by ShowSave method
Private Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OpenFilename) As Long

'API function to retrieve extended error information
Private Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long

'API memory functions
Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalFree Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
Private Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As LongPtr) As Long

Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Any, hpvSource As Any, ByVal cbCopy As LongPtr)
     #Else
     '  Code is running in 32-bit version of Microsoft Office
' data buffer for the ChooseColor function
Private Type ChooseColor
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        rgbResult As Long
        lpCustColors As Long
        Flags As Long
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
End Type
'data buffer for the GetOpenFileName and GetSaveFileName functions
Private Type OpenFilename
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        iFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        Flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
End Type


'API function called by ChooseColor method

Private Declare PtrSafe Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long

'API function called by ShowOpen method
Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OpenFilename) As Long

'API function called by ShowSave method
Private Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OpenFilename) As Long

'API function to retrieve extended error information
Private Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long

'API memory functions
Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare PtrSafe Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long

Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
     #End If
#Else
'' Code is running in VBA version 6 or earlier
' data buffer for the ChooseColor function
Private Type ChooseColor
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        rgbResult As Long
        lpCustColors As Long
        Flags As Long
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
End Type
'data buffer for the GetOpenFileName and GetSaveFileName functions
Private Type OpenFilename
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        iFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        Flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
End Type


'API function called by ChooseColor method

Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long

'API function called by ShowOpen method
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OpenFilename) As Long

'API function called by ShowSave method
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OpenFilename) As Long

'API function to retrieve extended error information
Private Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long

'API memory functions
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
         hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
#End If
 

...
Рейтинг: 0 / 0
18 сообщений из 18, страница 1 из 1
Форумы / Microsoft Access [игнор отключен] [закрыт для гостей] / Загрузка изображения из директории. Не работает в 64-битном Офисе.
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]