Подскажите как правильно пользоваться на VB Сишной CallBack функцией. Если можно то применительно к струткуре EDITSTREAM typedef struct _editstream { DWORD dwCookie; DWORD dwError; EDITSTREAMCALLBACK pfnCallback; } EDITSTREAM; Я пробовал делать AddressOf, но у меня не получалось - выбивало VB. Может я что не так делал? === Объявления я помещу в конце(для того чтобы вы не утруждались :)). Sub StreamFileIn(lpszFileName As String) hFile = OpenFile(lpszFileName, ofs, OF_READ) est.dwCookie = hFile est.dwError = 0 est.pfnCallback = FnPtrToLong(AddressOf ofCallBack) SendMessage hRich, EM_STREAMIN, SF_TEXT, est 'Здесь выбивает VB. End Sub Function FnPtrToLong(ByVal lngFnPtr As Long) As Long FnPtrToLong = lngFnPtr End Function Function ofCallBack(dwCookie As Long, pbBuff As Long, cb As Long, pcb As OVERLAPPED) As Long ReadFile hFile, dwCookie, pbBuff, cb, pcb ' ofCallBack=ReadFile (hFile, dwCookie, pbBuff, cb, pcb) тоже не даёт положительного эффекта. End Function 'Код конечно не полный - нет кода загрузки библиотеки, которую выбивает(RICHED32.DLL). Но, если здесь всё сделано верно, то я вышлю и код загрузки библиотеки и создания контрола. === Конец кода / Начало объявлений Public Type EDITSTREAM dwCookie As Long dwError As Long pfnCallback As Long End Type Public est As EDITSTREAM Public Const OFS_MAXPATHNAME = 128 Public Type OFSTRUCT cBytes As Byte fFixedDisk As Byte nErrCode As Integer Reserved1 As Integer Reserved2 As Integer szPathName(OFS_MAXPATHNAME) As Byte End Type Public Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long Public Type OVERLAPPED Internal As Long InternalHigh As Long offset As Long OffsetHigh As Long hEvent As Long End Type Public Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As OVERLAPPED) As Long Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public hRich As Long, ReDLL As Long Public hFile As Long, fSiz As Long Public pcb As OVERLAPPED, ofs As OFSTRUCT Public dwCookie As Long, pbBuff As Long, cb As Long ', pcb As Long Public Const OF_READ = &H0 Public Const WM_USER = &H400 Public Const EM_STREAMIN = WM_USER + 73 Public Const SF_TEXT = &H1 Public Const SF_RTF = &H2 Public Const SF_RTFNOOBJS = &H3 Public Const SF_TEXTIZED = &H4 Public Const WM_SETTEXT = &HC Public Const EM_SETMODIFY = &HB9
Ответить
|