<< Click to Display Table of Contents >> Navigation: Commands > Change the way the mouse works(main and thumbnail view, left and right button) |
COMPDF_SelectMode = 133
a) Changes the way the left mouse button works in main viewer. The following modes are possible:
wpmouse_Pan = 0
The user can press and drag the mouse to move the displayed area.
wpmouse_SelectText = 1
The user can click and drag the mouse to select text. The selected text can be extracted with COMPDF_GetTextLen/COMPDF_GetTextBuf.
wpmouse_DrawCustom = 2
The user can click and drag the mouse to draw a frame. When the frame is completed, the message WM_PDF_STAMPTEXT is sent which triggers the event OnSelRectEvent. This can be also used to zoom to a rectangle (with Command(COMPDF_ZOOM, "RECT") or to capture a frame as bitmap or to copy text (see COMPDF_CopyToClibrd) on clipboard.
Example:
procedure TWPViewPDFDemo.DoSelRectEvent(Sender: TObject; const PageNr: Integer;
R: TRect);
begin
if FSelectZoomRect then
begin
Screen.Cursor := crDefault;
WPViewPDF1.CommandStr(COMPDF_ZOOM, 'RECT');
end else
// This code is used to capture a bitmap
if FSaveToClip then
begin
if WPViewPDF1.CommandEx(COMPDF_SaveBMPToClipboard, 200)>0 then // Save in 200 dpi quality
ShowMessage('An image @200 dpi was copied to clipboard.');
end else
// This code is used to capture as text
if FCopyTextRect then
begin
if WPViewPDF1.CommandEx(COMPDF_CopyToClibrd,8)>0 then
ShowMessage('Text copied to clipboard.');
end;
end;
wpmouse_DrawObject = 3
The user can draw a rectangle - a new object will be created when finished. See "Draw Shapes". The object must be first initialized with COMPDF_MouseAddDrawObject.
wpmouse_SelectPage = 4
When the user click, the page is selected. Also see ViewOptions.
wpmouse_SelectObject = 5
The user can select and move draw objects.
wpmouse_Point = 6
Do nothing.
wpmouse_SelectPath = 7
Reserved. Cannot be used in Standard and PLUS edition.
wpmouse_UserDefined = 8, the mouse down event is now triggered
If the value is >90, the current value is returned.
b) To change the way the right mouse button works, add 100 to the above values.
c) To change the way the left mouse button works in the thumbnail view (left panel), add 200 to the above values.
d) To change the way the right mouse button works in the thumbnail view, add 300 to the above values.
To disable the internal use of the middle mouse button (=autoscroll) call this command:
WPViewPDF1.Command(COMPDF_RefineMouseMode, '0', 1);
If used, a click to zoom can be implemented:
procedure TWPViewPDFDemo.WPViewMouseDown(
Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not FZoomed and (Button=mbMiddle) then
begin
WPViewPDF1.command(COMPDF_ZoomSaveRestore, 1); // Save Position
WPViewPDF1.command(COMPDF_Zoom, 'MP', 200);
FZoomed := true;
end;
end;
The VCL defines this function to get and set the mouse mode:
function TWPViewPDF.MouseMode(
element : TWPMouseModeElement;
value : TWPMouseMode) : TWPMouseMode;
var i : Integer;
begin
if value=wpmInvalid then
i := Command(COMPDF_SelectMode,
90+(100*Integer(element)))
else i := Command(COMPDF_SelectMode,
Integer(value)+(100*Integer(element)));
if (i>=0) and (i<=Integer(High(TWPMouseMode))) then
Result := TWPMouseMode(i)
else Result := wpmInvalid;
end;