跨應用程式複製 貼上文字能保留文字格式的原理是什麼?

時間 2021-06-01 11:46:48

1樓:魯哈花

複製的時候,看似你只複製了文字,實則複製了文字和其他很多描述資訊,包括他的格式是什麼樣子的,包括他的格式用這種方式描述和那種方式描述分別是什麼樣子的。貼上的時候你要只索取文字也可以,例如記事本,那你就會有文字;如果索取帶格式的文字也行,例如word,那你就會有帶格式的文字。

格式並不是猜出來了,是早就儲存到剪貼簿的。

2樓:RednaxelaFX

Windows的話,剪下板是有格式的,而且應用在把資料放上剪下板時(copy/cut動作)可以同時提供多種不同格式的資料;然後應用在從剪下板獲取資料(paste動作)時則可以指定自己要使用哪種格式來獲取。

請參考MSDN的文件,講得非常詳細:

Clipboard Formats (Windows) <- 有標準格式和私有格式。請留意這段:

Multiple Clipboard Formats

A window can place more than one clipboard object on the clipboard, each representing the same information in a different clipboard format. When placing information on the clipboard, the window should provide data in as many formats as possible. To find out how many formats are currently used on the clipboard, call the CountClipboardFormats function.

Clipboard formats that contain the most information should be placed on the clipboard first, followed by less descriptive formats. A window pasting information from the clipboard typically retrieves a clipboard object in the first format it recognizes. Because clipboard formats are enumerated in the order they are placed on the clipboard, the first recognized format is also the most descriptive.

For example, suppose a user copies styled text from a word-processing document. The window containing the document might first place data on the clipboard in a registered format, such as RTF. Subsequently, the window would place data on the clipboard in a less descriptive format, such as text (CF_TEXT).

When the content of the clipboard is pasted into another window, the window retrieves data in the most descriptive format it recognizes. If the window recognizes RTF, the corresponding data is pasted into the document. Otherwise, the text data is pasted into the document and the formatting information is lost.

GetClipboardData function (Windows) <- 通過這個函式獲取剪下板資料要指定格式。

如何理解Web應用程式的MVC模型?

4年前的提問了呀,不知道現在理解的如何了。mvc最早是出現在設計模式裡面。mvc是一直綜合性的設計模式,簡單的說就是通過c把兩個東東整合在一起。其實呢沒有啥嚴謹的規定,設計模式是一直思維方式,一直解決問題的思路。那麼按照這種思路,不同的程式語言就有了不同的實現方式。前端用後端也有,各個語言也都有。還...

使用Qt開發應用程式時,使用MySQL資料庫還是使用Qt自帶的SQLite資料庫呢,用哪個會方便簡單?

資料庫,只要不用到特性和方言,基礎的sql區別都不大,上手難度也沒太大差別 選型取決於用途 如果是做產品的,mysql 相對好些 如果只是做玩具,sqlite 也不差 SQLite當然更簡單,更容易上手,MySQL你好歹還要安裝配置一下才可以用。Qt中還可以以 記憶體資料庫 的方式使用SQLite。...

為什麼 DirectX 應用程式(比如遊戲)內使用者介面的操作感,總是不如 Windows 原生 GUI 那樣自然?

鄧鋆 如果你的機器效能足夠把DirectX OpenGL程式的幀率跑到螢幕重新整理率以上,那麼操縱感只會更強不會更差。之所以感覺到 遲滯 多半是遊戲的其他圖形內容太多,圖形渲染的效能不足,或者是開啟了三倍 多倍緩衝或預渲染 留意你的選項 導致你感受到了較大的延遲,這對UI的體驗影響很大。你試試徹底不...

如何限制應用程式申請不必要許可權?

介君 許可權修改器就OK,不需要root,安裝包處入手處限制去除許可權。已安裝的程式也可以修改,不過,需重灌。個別軟體做了許可權校驗功能,修改後會無法使用 兩個版本 貌似不是一個作者 版本一英文許可權版,1.6以上系統都可支援 本身僅一個許可權 寫入SD卡許可權 原理 安裝包處限制許可權 版本二許可...

你每天都在用的手機應用程式是什麼?

波波魯 1.每天抖音15分鐘。蘋果可以設定軟體應用時間在抖音裡除了刷到一些娛樂之外,可以學到的東西也是很多2.每日藝術3分鐘左右。每天看一篇名作,並瞭解故事。豐富知識還能提高審美3.每天必點雜誌迷 就想看看雜誌嘻嘻 4.交流電口學習 每天必上線一次,然後和別人練練口語 有時候也會點開,找別人聊嗑 幽...