WinAPI: 剪下板函數

GetOpenClipboardWindow: HWND; {}GetPriorityClipboardFormat( var paFormatPriorityList; {} cFormats: Integer {}): Integer; {}IsClipboardFormatAvailable( format: UINT {}): BOOL;EmptyClipboard: BOOL; {}GetClipboardFormatName(

使用剪下板[2]: Assign、HasFormat

準備工作: 在表單上放置一個 TPanel; 在 TPanel 上放一個 TImage; 另外需要三個按鈕.本例:第一版代碼:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Button1: TButton;

使用剪下板[3]: SetComponent、GetComponent

本例示範把一個組件(TEdit)放入剪下板, 又取出(放到一個 TPanel 上)的過程.放入剪下板的方法是個過程: SetComponent(要放入的組件);取出的方法是個函數: GetComponent(指定屬主, 指定父視窗): 函數返回取出的組件的控制代碼.取出以前, 最好要判斷一下當前剪下板中是不是個組件: HasFormat(CF_COMPONENT); 取出以前還必須要註冊要取出的組件類, 譬如: RegisterClasses([TEdit]);準備工作: 在表單上添加

使用剪下板[5]: SetAsHandle、GetAsHandle – 自訂格式

如果要在剪下板中存放自己的格式, 需要用到 SetAsHandle、GetAsHandle 兩個方法.SetAsHandle(用於剪下板的格式ID, 資料的記憶體控制代碼); 看這個方法的兩個參數都有點麻煩.自訂剪下板格式要用 RegisterClipboardFormat 函數; 第二個參數是記憶體控制代碼而不是記憶體位址, 能分配記憶體並返回控制代碼的函數暫時我只知道 GlobalAlloc、GlobalReAlloc 兩個函數, 使用它們分配用於剪下板的記憶體時還須使用

PChar 類型的又一些用法

//使用 PChar^var p: PChar;begin p := PChar('abcd'); ShowMessage(p); {abcd} ShowMessage(p^); {a} p := p + 2; ShowMessage(p^); {c} Dec(p); ShowMessage(p^); {b} ShowMessage(p); {bcd}end;//遍曆 PChar 中的字元var p: PChar;begin p := PChar('

通過 TStringList 給系列數字倒排序 – 回複 lancerning 的問題

問題來源: http://www.cnblogs.com/del/archive/2008/04/07/1134178.html#1141173unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton;

WinAPI: GetSystemMetrics – 擷取系統度量等數值資訊

聲明:GetSystemMetrics( nIndex: Integer {參數, 詳見下表}): Integer;舉例 - 擷取螢幕解析度:var cx,cy: Integer;begin {通過 GetSystemMetrics 函數擷取螢幕解析度} cx := GetSystemMetrics(SM_CXSCREEN); cy := GetSystemMetrics(SM_CYSCREEN); ShowMessageFmt('Width:%d; Height:%d', [cx,

用 TStringList 存取結構的例子 – 回複 Test1234 的問題

問題來源: http://www.cnblogs.com/del/archive/2008/04/25/973346.html#1171532unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton;

System.New、System.Dispose – 為某個指標申請和釋放記憶體

舉例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender:

WinAPI: 快速鍵函數匯總

function LoadAccelerators( hInstance: HINST; {} lpTableName: PChar {}): HACCEL; {}function CreateAcceleratorTable( var Accel; {} Count: Integer {}): HACCEL; {}function CopyAcceleratorTable( hAccelSrc: HACCEL; {}

理解 Delphi 的類(十) – 深入方法[21] – 開放數組參數

//給一個整型開放數組求和的函數function MyFun(const arr: array of Integer): Integer;var i: Integer;begin Result := 0; for i in arr do Result := Result + i;end;{測試1:}procedure TForm1.Button1Click(Sender: TObject);var num: Integer;begin num := MyFun([1,2,3]);

數組竟然可以這樣定義

//這是常規思路:const arr: array[0..1] of Char = ('A','B');begin ShowMessage(arr); {AB} ShowMessage(IntToStr(Length(arr))); {2}end;//沒想到可以這樣:const arr: array[Boolean] of Char = ('A','B');begin ShowMessage(arr); {AB}

一行代碼設定顏色的控制項

本例:提示: 建立工程後, 添加 TColorBox、TColorListBox、TColorGrid、TButtonColor 四個控制項, 分別雙擊它們建立預設事件, 然後貼入下面代碼:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ColorGrd, StdCtrls, TeCanvas, ExtCtrls;type

使用 WM_NCHITTEST 訊息判斷滑鼠所在視窗的部位

本例:WM_NCHITTEST 訊息返回後, 訊息的 Result 參數表示了滑鼠所在視窗的部位.表單設計步驟: 建立工程後, 隨便添加一個菜單; 設定表單的 AutoScroll 屬性為 True, 並添加一個 Panel 放在合適的位置, 以讓視窗出現捲軸.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,

WinAPI: 菜單函數匯總

function LoadMenu( hInstance: HINST; {} lpMenuName: PChar {}): HMENU; {}function LoadMenuIndirect( lpMenuTemplate: Pointer {}): HMENU; {}function GetMenu( hWnd: HWND {}): HMENU; {}function SetMenu( hWnd: HWND; {}

給系統功能表添加功能表項目

本例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure SysMenu(var msg: TWMMenuSelect); message

建立異形視窗[1]

本例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure FormCreate(Sender: TObject); procedure

關於 Lo、Hi、LoWord、HiWord

Cardinal 是 4 位元組無符號的整型, 先看一個例數:Cardinal 例數:4277991664按位元組劃分:第四位元組第三位元組第二位元組第一位元組二進位:11111110111111001111100011110000十六進位:FEFCF8F0十進位:254252248240按雙位元組劃分:高兩位低兩位二進位:11111110111111001111100011110000十六進位:FEFCF8F0十進位:6527663728//可以用 Lo

格式化輸出函數(1): Format

var s: string;begin //指令類型 type s := Format('最大整數是: %d; 最小整數是: %d',[MaxInt,Low(Integer)]); //返回: 最大整數是: 2147483647; 最小整數是: -2147483648 { 提示: 格式指令必須以 % 開始, 不區分大小寫, %d 代表一個整數; 第二個參數是一個變體數組 } s := Format('最大的無負號整數是: %u',[High(Cardinal)]); //返回:

判斷一個數組的長度用 Length 還是 SizeOf ?

最近發現一些代碼, 甚至有一些專家代碼, 在遍曆數組時所用的數組長度竟然是 SizeOf(arr); 這不合適!如果是一維數組、且元素大小是一個位元組, 這樣用看不出錯誤, 譬如:var arr1: array[0..9] of Char; arr2: array[0..9] of Byte;begin ShowMessageFmt('%d,%d,%d,%d',[Length(arr1), SizeOf(arr1),

總頁數: 61357 1 .... 4789 4790 4791 4792 4793 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.