Wednesday, September 2, 2020

Paste) - Delphi Code

Clipboard Basics (Cut/Copy/Paste) - Delphi Code The Windows Clipboard speaks to the compartment for any content or designs that are cut, duplicated or glued from or to an application. This article will tell you the best way to utilize the TClipboard item to execute cut-duplicate glue highlights in your Delphi application. Clipboard in General As you most likely know, the Clipboard can hold just one bit of a similar sort of information for cut, reorder at once. In the event that we send new data in a similar organization to the Clipboard, we clear out what was there previously, yet the substance of the Clipboard remains with the Clipboard significantly after we glue those substance into another program. TClipboard So as to utilize the Windows Clipboard in our applications, we should add the ClipBrd unit to the utilizations proviso of the task, aside from when we confine cutting, reordering to the segments previously having worked in help for Clipboard strategies. Those parts are TEdit, TMemo, TOLEContainer, TDDEServerItem, TDBEdit, TDBImage and TDBMemo. The ClipBrd unit consequently speaks to a TClipboard object called Clipboard. Well utilize the CutToClipboard, CopyToClipboard, PasteFromClipboard, Clear and HasFormat strategies to manage Clipboard tasks and text/realistic control. Send and Retrieve Text So as to send some content to the Clipboard the AsText property of the Clipboard object is utilized. In the event that we need, for instance, to send the string data contained in the variable SomeStringData to the Clipboard (clearing out whatever text was there), well utilize the accompanying code: utilizes ClipBrd; ... Clipboard.AsText : SomeStringData_Variable; To recover the content data from the Clipboard well use utilizes ClipBrd; ... SomeStringData_Variable : Clipboard.AsText; Note: on the off chance that we just need to duplicate the content from, lets state, Edit segment to the Clipboard, we don't need to incorporate the ClipBrd unit to the utilizations condition. The CopyToClipboard technique for TEdit duplicates the chose text in the alter control to the Clipboard in the CF_TEXT design. technique TForm1.Button2Click(Sender: TObject) ; start  â /the accompanying line will choose  â /ALL the content in the alter control  â {Edit1.SelectAll;}  â Edit1.CopyToClipboard; end; Clipboard Images To recover graphical pictures from the Clipboard, Delphi must realize what sort of picture is put away there. Correspondingly, to move pictures to the clipboard, the application must mention to the Clipboard what kind of designs it is sending. A portion of the potential estimations of the Format boundary follow; there are a lot more Clipboard designs gave by Windows. CF_TEXT - Text with each line finishing with a CR-LF combination.CF_BITMAP - A Windows bitmap graphic.CF_METAFILEPICT - A Windows metafile graphic.CF_PICTURE - An object of type TPicture.CF_OBJECT - Any industrious article. The HasFormat technique returns True if the picture in the Clipboard has the correct configuration: in the event that Clipboard.HasFormat(CF_METAFILEPICT) at that point ShowMessage(Clipboard has metafile) ; Utilize the Assign strategy to send (dole out) a picture to the Clipboard. For instance, the accompanying code duplicates the bitmap from a bitmap object named MyBitmap to the Clipboard: Clipboard.Assign(MyBitmap) ; All in all, MyBitmap is an object of type TGraphics, TBitmap, TMetafile or TPicture. To recover a picture from the Clipboard we need to: confirm the configuration of the current substance of the clipboard and utilize the Assign strategy for the objective item: {place one catch and one picture control on form1} {Prior to executing this code press Alt-PrintScreen key combination} utilizes clipbrd; ... system TForm1.Button1Click(Sender: TObject) ; start on the off chance that Clipboard.HasFormat(CF_BITMAP) at that point Image1.Picture.Bitmap.Assign(Clipboard) ; end; More Clipboard Control Clipboard stores data in numerous organizations so we can move information between applications utilizing various arrangements. When perusing data from the clipboard with Delphis TClipboard class, we are constrained to standard clipboard positions: text, pictures, and metafiles. Assume youre working between two distinctive Delphi applications; how might you characterize custom clipboard position so as to send and get information between those two projects? With the end goal of investigation, lets state you are attempting to code a Paste menu thing. You need it to be crippled when there is no content in the clipboard (as an example). Since the whole procedure with the clipboard happens in the background, there is no technique for TClipboard class that will educate you when some adjustment in the substance of the clipboard has occurred. The thought is to snare in the clipboard warning framework, so youre ready to access and react to occasions when the clipboard changes. To appreciate greater adaptability and usefulness, managing clipboard change warnings and custom clipboard groups tuning in to the Clipboard is important.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.