Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

Clipboard problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Park - 04 Sep 2005 01:01 GMT
I'm trying to use:

keybd_event(VK_SNAPSHOT, 0, 0, 0);
keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0);

to take a screenshot, and use:

Clipboard::GetImage();

to retrieve it, but it returns a nullptr. It's strange though because I know
the screenshot is taken since I can paste just fine in mspaint. If I press
print screen manually, the GetImage() method works as it should. I'm using
VC++ Express 2k5 August CTP. Help would be much appreciated.
David Lowndes - 04 Sep 2005 10:09 GMT
>I'm trying to use:
>
[quoted text clipped - 8 lines]
>the screenshot is taken since I can paste just fine in mspaint. If I press
>print screen manually, the GetImage() method works as it should.

James,

I'm wondering if there's some timing issue coming into effect.

Have you tried splitting up the keyboard event creation of the screen
shot and the call to GetImage so they're 2 manually instigated events
(say 2 separate push buttons on a form), and see if that makes any
difference.

Dave
Signature

MVP VC++ FAQ: http://www.mvps.org/vcfaq

James Park - 04 Sep 2005 18:51 GMT
> >I'm trying to use:
>>
[quoted text clipped - 18 lines]
> (say 2 separate push buttons on a form), and see if that makes any
> difference.

Well, one of the problems was that I didn't leave enough time between the
keystroke and the clipboard query, but there were other issues as well. For
some reason, using the code during a BackgroundWorker::DoWork failed, but
using it during a Form::Load worked. Another problem was that as I ran the
code in a loop a nullptr would come up if I switched the active window as it
was taking the shots. So the code was working like I wanted, but when I
alt-tabbed from an app window to VS, it'd give me a NullReferenceException,
and I'd grumble thinking it happened on the first pass. The problem worked
the other way too (i.e. from VS/system tray looping ss'ing app to
full-screen game), and the exception actually would occur on the first pass
and confuse me even more. It took me a long time to get my program working
though everything feels rather fragile, and I still don't get why things are
the way they are.
Atul - 06 Sep 2005 03:07 GMT
>For some reason, using the code during a BackgroundWorker::DoWork failed,
>but using it during a Form::Load worked.

I think this can be cured by calling Application.OleRequired for the
background thread.

-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls

>> >I'm trying to use:
>>>
[quoted text clipped - 33 lines]
> to get my program working though everything feels rather fragile, and I
> still don't get why things are the way they are.
James Park - 06 Sep 2005 22:55 GMT
> >For some reason, using the code during a BackgroundWorker::DoWork failed,
> >but using it during a Form::Load worked.
>
> I think this can be cured by calling Application.OleRequired for the
> background thread.

Thanks for the suggestion. Unfortunately, it didn't work.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.