Hallo allerseits
In früheren Windows-Versionen gab es ein Tool zum Anzeigen des Inhaltes der Zwischenablage.
Ich habe nun mal versucht, die Funktionalität mittels XProfan nachzubilden. Wie beim Original wird die Anzeige bei jeder Änderung des Inhaltes der Zwischenablage automatisch aktualisiert. Das Ganze sollte ab Profan7 laufen. Es können Texte und Bilder dargestellt werden.
Kleiner Wermutstropfen, wenn das Programm minimiert ist, zeigt die Vorschau ün der Taskleiste den letzten Zustand der Zwischenablage vor dem Verkleinern. Aber das machen Profiprogramme auch nicht besser.
Code
$H windows.ph
$H messages.ph
Declare Titel$, NextViewer&, LastSender&, Text&, Static&, IsText&, IsPic&, Font&, Static$
Declare Rect#
Declare Bitmap#
Declare Buffer#
Struct Rect = ~TRect
Struct Bitmap = ~TBitmap
DIM Rect#, Rect
DIM Bitmap#, Bitmap
DIM Buffer#, 60
Proc BildHolen
Declare _Ratio!, _Ratio$, _BMH&
If ~OpenClipBoard(%HWnd) <> 0
_BMH& = ~GetClipboardData(~cf_Bitmap)
~GetObject(_BMH&, 28, Bitmap#)
~CloseClipboard()
MCLS Bitmap#.bmWidth&, Bitmap#.bmheight&
StartPaint -1
ClipLoadBMP 0, 0; 0
Endpaint
' Verhältnis Breite zu Höhe für Anzeige berechnen
_Ratio! = Bitmap#.bmheight& / Bitmap#.bmWidth&
_Ratio$ = " [B : H = 1 : ' + Format$ ('0.00', _Ratio!) + ']"
If _Ratio! < 1
_Ratio! = Bitmap#.bmWidth& / Bitmap#.bmheight&
_Ratio$ = " [B : H = ' + Format$ ('0.00', _Ratio!) + ' : 1]"
EndIf
Static$ = "Bild (" + Str$(Bitmap#.bmWidth&) + " x " + Str$(Bitmap#.bmheight&) + ") Pixel"
SetText Static&, Static$ + _Ratio$
IsPic& = 1
Else
SetText Static&, "Bildholen gescheitert"
IsPic& = 0
EndIf
EndProc
Proc BildSetzen
Declare _Zoom1!, _Zoom2!, _BW&, _BH&
Case IsPic& = 2 : BildHolen ' War Fenster verkleinert, Bild jetzt holen
' BildHolen funktioniert nicht, wenn Programm verkleinert!
If IsPic& = 1
' Proportional in vorhandene Fenstergröße einpassen
_Zoom1! = %BMPX / Rect#.Right&
_Zoom2! = %BMPY / (Rect#.Bottom& - 22)
If _Zoom1! > _Zoom2!
_BW& = %BMPX / _Zoom1!
_BH& = %BMPY / _Zoom1!
Else
_BW& = %BMPX / _Zoom2!
_BH& = %BMPY / _Zoom2!
EndIf
MCopySizedBMP 0, 0 - %BMPX, %BMPY > 0, 0 - _BW&, _BH&; 0 ' Bild in Fenster einzoomen
EndIf
EndProc
Proc Size ' Größenänderung Fenster
Case ~IsIconic(%HWnd) : Return ' nichts tun bei verkleinertem Fenster
' Vorschau wird ohnehin nicht aktualisiert
' und Bildeinfügen ist hier nicht möglich
CLS ~GetSysColor(~Color_BtnShadow)
~GetClientRect(%HWnd, Rect#)
SetWindowPos Static& = 0, (Rect#.Bottom& - 22) - (Rect#.Right& - 3), 22
If IsText& ' Textdisplay einpassen
SetWindowPos Text& = 0, 0 - Rect#.Right&, Rect#.Bottom& - 23
SetText Static&, Static$
ShowWindow(Text&, 1)
ElseIf IsPic& ' Bild einpassen
BildSetzen
Else
SetText Static&, Static$
EndIf
EndProc
Proc ShowText ' Steuerung Sichtbarkeit Textdisplay
Parameters _Text&
IsText& = _Text&
Case IsText& : IsPic& = 0
ShowWindow (Text&, IsText&)
EndProc
Proc TextFormat ' Aktion Text
Declare _Text$, _Len&
_Text$ = GetClip$()
_Len& = Len (_Text$)
ShowText 1
SetText Text&, _Text$
Static$ = "Text (" + Str$(_Len&) + " Zeichen)"
EndProc
Proc BildFormat ' Aktion Bild
ShowText 0
IsPic& = 2 ' Veranlaßt Bildholen wenn Fenster anzeigebereit ist
EndProc
Proc XFormat ' Aktion Unbekanntes Format
Parameters _Static$
ShowText 0
Static$ = _Static$
IsPic& = 0
EndProc
Proc ClipAction ' Änderungen des Inhalts der Zwischenanlage auswerten
Declare _Icon&
CLS ~GetSysColor(~Color_BtnShadow)
If ~CountClipboardFormats()
If ~IsClipboardFormatAvailable(~cf_Text)
Textformat
ElseIf ~IsClipboardFormatAvailable(~cf_Bitmap)
BildFormat
Else
XFormat "Nicht darstellbar"
EndIf
Else
XFormat "Leer"
EndIf
Size
Case NextViewer& : SendMessage(NextViewer&, ~wm_DrawClipboard, &uwParam, &ulParam)
' Kommando durchreichen an nächsten Viewer
EndProc
Proc CBChain ' Änderung der Viewerkette behandeln
If &uwParam = NextViewer&
NextViewer& = &ulParam
ElseIf NextViewer& <> 0
SendMessage(NextViewer&, ~wm_ChangeCBChain, &uwParam, &ulParam)
EndIf
EndProc
Proc MakeTextDisplay
Font& = ~GetStockObject(~Default_GUI_Font)
~GetObject(Font&, 60, Buffer#)
Long Buffer#, 0 = 16
Long Buffer#, 4 = 0
Font& = ~CreateFontIndirectA(Buffer#) ' Eigenen Font basiert auf Systemschrift Default_GUI_Font
SetDialogFont Font&
Text& = Create("MultiEdit", %HWnd, "", 0, 0, 0, -1) ' Textanzeige
SendMessage(Text&, ~em_SetReadOnly, 1, 0) ' Text als NurLesen anzeigen
IsText& = 1
Static& = Control("Static", "", $50000000, 0, 0, 0, 0, %HWnd, 100, %HInstance, $200) ' Statusanzeige
Size
EndProc
WindowStyle 575
WindowTitle "ClipView"
Window %MaxX\12, %MaxY\12 - %MaxX\2, %MaxY\2
UseIcon "Windows"
CLS ~GetSysColor(~Color_BtnShadow)
Set("FastMode", 1)
Set("ErrorLevel", 0)
MakeTextDisplay
NextViewer& = ~SetClipboardViewer(%HWnd) ' Viewer anmelden
UserMessages ~wm_DrawClipboard, ~wm_ChangeCBChain
ClipAction
While 1
WaitInput
If %Key = 2
Break
ElseIf %Key = 4
Size
ElseIf %UMessage = ~wm_DrawClipboard
ClipAction
ElseIf %UMessage = ~wm_ChangeCBChain
CBChain
EndIf
EndWhile
Dispose Rect#
Dispose Bitmap#
Dispose Buffer#
DeleteObject Font&
~ChangeClipboardChain(%HWnd, NextViewer&) ' Viewer abmelden, unbedingt bei Ende ausführen!!!
Alles anzeigen
Gruß Volkmar