Skip to content

Instantly share code, notes, and snippets.

@timsneath
Created September 22, 2020 05:10
Show Gist options
  • Save timsneath/c0e64ac7896523d50219ffaa3debe86f to your computer and use it in GitHub Desktop.
Save timsneath/c0e64ac7896523d50219ffaa3debe86f to your computer and use it in GitHub Desktop.
IFileDialog.dart (extract)
import 'dart:ffi';
import 'package:ffi/ffi.dart';
// more imports
import 'IModalWindow.dart';
/// @nodoc
const IID_IFileDialog = '{42f85136-db7e-439c-85f1-e4075d135fc8}';
typedef _SetFileTypes_Native = Int32 Function(
Pointer obj, Uint32 cFileTypes, Pointer<COMDLG_FILTERSPEC> rgFilterSpec);
typedef _SetFileTypes_Dart = int Function(
Pointer obj, int cFileTypes, Pointer<COMDLG_FILTERSPEC> rgFilterSpec);
typedef _SetFileTypeIndex_Native = Int32 Function(
Pointer obj, Uint32 iFileType);
typedef _SetFileTypeIndex_Dart = int Function(Pointer obj, int iFileType);
//...
/// {@category Interface}
/// {@category com}
class IFileDialog extends IModalWindow {
// vtable begins at 4, ends at 26
IFileDialog(Pointer<COMObject> ptr) : super(ptr);
int SetFileTypes(int cFileTypes, Pointer<COMDLG_FILTERSPEC> rgFilterSpec) =>
Pointer<NativeFunction<_SetFileTypes_Native>>.fromAddress(
ptr.ref.vtable.elementAt(4).value)
.asFunction<_SetFileTypes_Dart>()(
ptr.ref.lpVtbl, cFileTypes, rgFilterSpec);
int SetFileTypeIndex(int iFileType) =>
Pointer<NativeFunction<_SetFileTypeIndex_Native>>.fromAddress(
ptr.ref.vtable.elementAt(5).value)
.asFunction<_SetFileTypeIndex_Dart>()(ptr.ref.lpVtbl, iFileType);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment