• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

windows clipboard (reading)

Whats the way (if exists) to read the windows clipboard under Turbo Pascal 70 (DOS) loaded in windows98 ?
Especifically, is possible read a bmp or other usual graphic format..
Thanks
0
rdfloc
Asked:
rdfloc
1 Solution
 
VIBESPROCommented:
use intr = $2F, AX=1703 to read/write data...
it points to the windows clipboard
but it only works in real mode
 
you can use a "real mode interrupt callback" in order to use the function. a Real mode interrupt callback (i think) requires that there's a DPMI handler installed if you want it to work in protected mode

let me know if it works  
 

0
 
HypoCommented:
The way use it: is to use int 2Fh as Vibespro sugested... though the functions 1700h to 1705h and 1708h are used to handle the clipboard.

1700h = check WinOldAp version
1701h = open clipboard
1702h = flush/empty clipboard
1703h = set clipboard data
1704h = get clipboard data size
1705h = get clipboard data
1708h = close clipboard

and yes... It's possible to get bitmaps from the clipboard. I wrote you a little example... but as Vibespro said, it doesn't work with DPMI. (But that problem can be solved.)

select some text and copy it to the clipboard in windows... then change to pascal and run my example... It gives a correct result for me. :)

However... So far I've only made it to show the text result... Writing a bitmap viewer would take a little longer.

-------

Program WinOldAP_Clipboard;

uses crt;

Type TClipboard = array[1..65535] of byte;

const CB_Text            = $01;
      CB_Bitmap          = $02;
      CB_MetaFilePicture = $03;
      CB_SYLK            = $04;
      CB_DIF             = $05;
      CB_TIFF            = $06;
      CB_OEMText         = $07;
      CB_DIBBitmap       = $08;
      CB_SpecialFormat   = $80;
      CB_DSPText         = $81;
      CB_DSPBitmap       = $82;

var CBData : ^TClipboard;
    CBSize : longint;

Function GetWinOldApVer : word; assembler;
asm
  MOV AX,$1700
  INT $2F
end;

Function OpenClipboard : word; assembler;
asm
 MOV AX,$1701
 INT $2F
end;

Function CloseClipboard : word; assembler;
asm
 MOV AX,$1708
 INT $2F
end;

Function GetClipboardSize(Typ : word) : longint; assembler;
asm
  MOV AX,$1704
  MOV DX,Typ
  INT $2F
end;

Function GetClipboardData(Typ : word; var Dest) : word; assembler;
asm
  LES BX,Dest
  MOV DX,Typ
  MOV AX,$1705
  INT $2F
end;

Procedure WriteTextClipboardData(var C : TClipboard);
var n : word;
begin
 n := 1;
 while C[n] <> 0 do begin
  write(chr(C[n]));
  inc(n);
 end;
end;

begin
 clrscr;
 if GetWinOldApVer <> $1700 then begin
  {If GetWinOldApVer = $1700, clipboard are not supported.}
  OpenClipboard;
  CBSize := GetClipboardsize(CB_Text);
  if CBSize < 65535 then getmem(CBData,CBSize);
  if GetClipboardData(CB_Text,CBData^) <> 0
   then WriteTextClipboardData(CBData^);
  if CBSize < 65535 then Freemem(CBData,CBSize);
  CloseClipboard;
 end;
end.
0
 
rdflocAuthor Commented:

Well, as I said, i need preferrablely some way to get the windows clipboard when it contains a graphic format...
Can anyone post an example of way to display such graphics..

Thanks again
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now