FUNCTION x() AS LOGIC
//VAR z := System.Windows.Forms.Clipboard.GetDataObject()
LOCAL z AS IDataObject
TRY
z := System.Windows.Forms.Clipboard.GetDataObject()
IF z:GetDataPresent(DataFormats.Text)
? z:GetData(DataFormats.Text)
ENDIF
CATCH e AS Exception
? e
END
RETURN TRUE
This throws a Nullreference exception on z.
I suspect this has to do with me using an interface while having no clue at all, what i do
Any hint, please?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Local data As System.Windows.Forms.IDataObject
....
If (System.Windows.Forms.Clipboard.GetDataObject() != Null)
data := System.Windows.Forms.Clipboard.GetDataObject()
If (data:GetDataPresent(System.Windows.Forms.DataFormats.Bitmap))
image := (System.Drawing.Image)data:GetData(System.Windows.Forms.DataFormats.Bitmap, True)
....
FUNCTION x() AS LOGIC
TRY
VAR z := System.Windows.Forms.Clipboard.GetDataObject()
IF z?:GetDataPresent(DataFormats.Text) == true
? z:GetData(DataFormats.Text)
ENDIF
CATCH e AS Exception
? e
END
RETURN TRUE
LOCAL ido AS IDataObject
ido := Clipboard.GetDataObject()
IF ido:GetDataPresent(DataFormats.Text)
cPaste := ido:GetData(DataFormats.Text):ToString()
...
If it's not working, then I guess you that the latest "Copy" operation you did in WIndows was not with text?
Hi Chris,
tried "your" variant - NullReferenceExeption. I explicitely copied prior to check some text from editor with CTRL+C
Must be something silly here, as usual
FUNCTION b() AS LOGIC
LOCAL ido AS IDataObject
ido := System.Windows.Forms.Clipboard.GetDataObject()
IF ido:GetDataPresent(DataFormats.Text)
VAR cPaste := ido:GetData(DataFormats.Text):ToString()
? cPaste
ENDIF
RETURN TRUE
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Ah indeed, I have actually that code surrounded with a TRY...AND TRY, so I am never getting an exception
As the guys said above, you (we) should be checking if GetDataObject() returns NULL false.
If there does exist some test in the clipboard, i can't think why it might not be working for you. Just to be sure, pasting the text in an editor with CTRL+V does work, right?
Yes, i read that you get a null if clipboard is empty... But I tried with copied text, copied image, copied desktop link, I always get the null. Strange.
FTR, using VO's class, it works.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)