GP SoftwareTwitter
Opus FAQsManualCommandsObjects

How to make the plugin available only in the preview panel

plugin-development

#1

How to judge in the Dvp_createviewer function?

(dwFlags and Dvpcvf_preview) = True?


#2

Correct.


#3

How to disable my plugin in response to the left mouse button double-click?


#4

I think the flag gets passed to DVP_IdentifyFile (and similar DVP_IdentifyBytes, etc. functions), and if you make that return false (when the flag is set) then the viewer should skip your plugin.


#5

You're right!!!:fu::fu::fu:


#6

How do I prevent the viewer pane from appearing at the same time as the view window? My plugin is not yet Multi-threaded.


#7

That depends how you're writing/designing the plugin and the language you're using.

It will need to support being called on multiple threads to work. (Each viewer instance will only be on a single thread per viewer, but calls into the plugin can come from any thread.)


#8

NFO View plugin code

BOOL DVP_IdentifyFile(HWND hWnd,LPTSTR lpszName,LPVIEWERPLUGINFILEINFO lpVPFileInfo,HANDLE hAbortEvent)
{
	lpVPFileInfo->dwFlags = DVPFIF_CanReturnViewer;

	lpVPFileInfo->wMajorType = DVPMajorType_Text;
	lpVPFileInfo->wMinorType = 0;

	lpVPFileInfo->szImageSize.cx = 0;
	lpVPFileInfo->szImageSize.cy = 0;
	lpVPFileInfo->iNumBits = 0;

	if (NULL != lpVPFileInfo->lpszInfo && 0 != lpVPFileInfo->cchInfoMax)
	{
		lpVPFileInfo->lpszInfo[0] = _T('\0');
	}

	return(TRUE);
}

BOOL DVP_IdentifyFileStream(HWND hWnd,LPSTREAM lpStream,LPTSTR lpszName,LPVIEWERPLUGINFILEINFO lpVPFileInfo,DWORD dwStreamFlags)
{
	return(DVP_IdentifyFile(hWnd, lpszName, lpVPFileInfo, NULL));
}

//HWND DVP_Configure(HWND hWndParent,HWND hWndNotify,DWORD dwNotifyData)
//{
//	NNfoConfig::NNC_CongifData cd;
//	cd.hDllModule		= s_hDllModule;
//	cd.hWndNotify		= hWndNotify;
//	cd.dwNotifyData		= dwNotifyData;
//	cd.dw64OpusVersion	= getOpusVersionNumber();
//	cd.hWndViewer		= NULL;
//
//	return(CreateDialogParam(s_hDllModule, MAKEINTRESOURCE(IDD_CONFIG), hWndParent,
//								NNfoConfig::configDlgProc,
//								reinterpret_cast<LPARAM>(&cd)));
//}

HWND DVP_CreateViewer(HWND hWnd,LPRECT lpRc,DWORD dwFlags)
{
	return(CNfoViewerWindow::CreateViewerWindow(s_hDllModule, hWnd, lpRc, dwFlags));
}

my code

const
  //press Ctrl + Shift + G get new PluginGUID
  Plugin_GUID          : TGUID     = '{2F2FC0CB-6D8D-4FCF-94B7-5D2515FEF2A6}';
  Plugin_VersionHigh   : DWORD     = $00000000;
  Plugin_VersionLow    : DWORD     = $00000001;

  Plugin_HandleExts    : PChar     = '*.ocx';  // separated by ";", example: '.txt;.html'
  Plugin_Name          : PChar     = 'Delphi Plugin Sample';
  Plugin_Description   : PChar     = 'Delphi Viewer Plugin Sample';
  Plugin_Copyright     : PChar     = 'Copyright (C)';
  Plugin_URL           : PChar     = '';

  Plugin_MinFileSize   : DWORDLONG = 0;
  Plugin_MaxFileSize   : DWORDLONG = $01400000; // 20971520(2Mib);
  Plugin_MajorFileType : Word      = DVPMajorType_Text;

function DVP_Identify(var InitInfo: TViewerPluginInfo): BOOL; cdecl;
//function DVP_Identify(InitInfo: PViewerPluginInfo): BOOL; cdecl;
begin
  Result := False;

  InitInfo.dwFlags               := DVPFIF_ExtensionsOnly or DVPFIF_InitialDisable;

  InitInfo.dwVersionHigh         := Plugin_VersionHigh;
  InitInfo.dwVersionLow          := Plugin_VersionLow;

  InitInfo.lpszHandleExts        := Plugin_HandleExts;
  InitInfo.lpszName              := Plugin_Name;
  InitInfo.lpszDescription       := Plugin_Description;
  InitInfo.lpszCopyright         := Plugin_Copyright;
  InitInfo.lpszURL               := Plugin_URL;

  InitInfo.dwlMinFileSize        := Plugin_MinFileSize;
  InitInfo.dwlMaxFileSize        := Plugin_MaxFileSize;
  InitInfo.dwlMinPreviewFileSize := Plugin_MinFileSize;
  InitInfo.dwlMaxPreviewFileSize := Plugin_MaxFileSize;
  InitInfo.uiMajorFileType       := Plugin_MajorFileType;   //DVPMajorType_Other;
  InitInfo.idPlugin              := Plugin_GUID;

  Result:= True;
end;

function DVP_IdentifyFile(hWnd: HWND; lpszName: LPSTR; var lpVPFileInfo: TViewerPluginFileInfo; hAbortEvent: THANDLE): BOOL; cdecl;
//function DVP_IdentifyFile(hWnd: HWND; lpszName: LPSTR; lpVPFileInfo: PViewerPluginFileInfo; hAbortEvent: THANDLE): BOOL; cdecl;
begin
    lpVPFileInfo.dwFlags        := DVPFIF_CanReturnViewer;
    lpVPFileInfo.wMajorType     := Plugin_MajorFileType;
    lpVPFileInfo.wMinorType     := 0;
    lpVPFileInfo.szImageSize.cx := 0;
    lpVPFileInfo.szImageSize.cy := 0;
    lpVPFileInfo.iNumBits       := 0;
    Result := True;
end;

function DVP_CreateViewer(hWndParent: HWND; lpRc: TRECT; dwFlags: DWORD): HWND; cdecl;
begin
//  if dwFlags <> 0 then  // dwFlags: in view window = 0x00000000, in view plane = 0x0000000C
    Result := CreateForm(hWndParent, dwFlags);
end;


exports DVP_Identify     name DVPFUNCNAME_IDENTIFY;
exports DVP_CreateViewer name DVPFUNCNAME_CREATEVIEWER;
exports DVP_IdentifyFile name DVPFUNCNAME_IDENTIFYFILE;

NFO View plugin does not respond to a double-click event, my plugin will double-click the Event. What is this for?