掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
独自Recordをクリップボードで出し入れしたい (ID:26587)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
おかげさまで、なんとかサンプルプログラムが思い通りに動きました。 ありがとうございました。 procedure TForm1.Button1Click(Sender: TObject); var MS:TMemoryStream; DataHandle:THandle; Pnt:Pointer; Len:Byte; Inte:Integer; begin MS := TMemoryStream.Create; try Len := Length(Edit1.Text) + 1; MS.Write(Len,SizeOf(Len)); MS.Write(PChar(Edit1.text)^,Len); Inte := ComboBox1.ItemIndex; MS.Write(Inte,SizeOf(Integer)); Len := Length(Edit2.Text) + 1; MS.Write(Len,SizeOf(Len)); MS.Write(PChar(Edit2.text)^,Len); Inte := ComboBox2.ItemIndex; MS.Write(Inte,SizeOf(Integer)); // //メモリ確保 DataHandle := GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE,MS.Size); //メモリのポインタ取得 Pnt := GlobalLock(DataHandle); MS.Position := 0;//巻き戻し MS.ReadBuffer(Pnt^,MS.Size); finally MS.Free; end; //クリップボードへの書き込み ClipBoard.Open; ClipBoard.Clear; ClipBoard.SetAsHandle(MyFormat,DataHandle); GlobalUnLock(DataHandle); ClipBoard.Close; end; procedure TForm1.Button2Click(Sender: TObject); var DataHandle:THandle; Pnt:Pointer; MS:TMemoryStream; Len:Byte; StMem:PChar; Inte:Integer; begin //クリップボード読み出し if Clipboard.HasFormat(MyFormat) then begin ClipBoard.Open; DataHandle := ClipBoard.GetAsHandle(MyFormat); Pnt := GlobalLock(DataHandle); MS := TMemoryStream.Create; try MS.WriteBuffer(Pnt^,GlobalSize(DataHandle)); GlobalUnLock(DataHandle); MS.Position := 0; MS.Read(Len,SizeOf(Len)); StMem := StrAlloc(Len); MS.Read(StMem^,Len); Edit1.Text := StMem; MS.Read(Inte,SizeOf(Integer)); ComboBox1.ItemIndex := Inte; MS.Read(Len,SizeOf(Len)); StMem := StrAlloc(Len); MS.Read(StMem^,Len); Edit2.Text := StMem; MS.Read(Inte,SizeOf(Integer)); ComboBox2.ItemIndex := Inte; finally MS.Free; end; Clipboard.Close; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.