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..
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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  

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;
  MOV AX,$1700
  INT $2F

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

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

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

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

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

 if GetWinOldApVer <> $1700 then begin
  {If GetWinOldApVer = $1700, clipboard are not supported.}
  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);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.