Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
QuestionWhy DataSet Not Updated, Any Gurus? Pin
Khang Nguyen10-Jul-03 5:14
Khang Nguyen10-Jul-03 5:14 
AnswerRe: Why DataSet Not Updated, Any Gurus? Pin
Heath Stewart10-Jul-03 9:14
protectorHeath Stewart10-Jul-03 9:14 
GeneralRe: Why DataSet Not Updated, Any Gurus? Pin
Khang Nguyen10-Jul-03 11:54
Khang Nguyen10-Jul-03 11:54 
GeneralC#, Java and memory Pin
albean10-Jul-03 4:52
albean10-Jul-03 4:52 
GeneralRe: C#, Java and memory Pin
Ylis10-Jul-03 5:01
Ylis10-Jul-03 5:01 
GeneralRe: C#, Java and memory Pin
KingTermite11-Jul-03 7:44
KingTermite11-Jul-03 7:44 
Generalaccessing the key buffer Pin
Ylis10-Jul-03 4:51
Ylis10-Jul-03 4:51 
GeneralRe: accessing the key buffer Pin
Heath Stewart10-Jul-03 11:00
protectorHeath Stewart10-Jul-03 11:00 
Since your application doesn't worn the desktop window, you'd have to set a Windows hook. They're not as hard as you think, and MSDN even has examples. Lookup the functions SetWindowsHookEx and UnhookWindowsHook. The topic "Win32 Hooks" even has sample code.

Another way might be to P/Invoke the functions SetClipboardViewer and ChangeClipboardChain. Then call SetClipboardViewer with your window handle (Form.Handle.ToInt32()). When the clipboard is changed, your application is sent the WM_DRAWCLIPBOARD message (DWORD, 0x0308). You must also P/Invoke SendMessage so that when WM_CHANGECBCHAIN is passed (when the clipboard chain changes, i.e. a viewer is added or removed) you can pass the HANDLEs that you received from calling SetClipboardViewer. This may sound complicated, but it's not. Essentially, you're just inserting yourself in a chain and handling messages passed to that chain. When you get the WM_DRAWCLIPBOARD message, you can use all the .NET class library's members for accessing the clipboard, checking for DataFormats.Bitmap or some other string (even your own). This would tell you that an image was copied, though, not that the PrintScreen key was pressed.

You could compare the size of the image with the size of the screen, but that only gives you a probable screenshot.

Basically, a windows hook is the way to go if you want a true handle for PrintScreen. The other is just an alternative if you just want to know when an image was copied to the clipboard.

 

Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN

GeneralRe: accessing the key buffer Pin
Ylis11-Jul-03 12:51
Ylis11-Jul-03 12:51 
GeneralWindows Application Startup Pin
bcox10-Jul-03 4:34
bcox10-Jul-03 4:34 
GeneralCombo Box Pin
totig10-Jul-03 4:23
totig10-Jul-03 4:23 
GeneralDisplay a form in a windows service Pin
Anonymous9-Jul-03 23:38
Anonymous9-Jul-03 23:38 
GeneralWebservice error: underlying connection was closed Pin
BigAndy9-Jul-03 22:39
BigAndy9-Jul-03 22:39 
GeneralRe: Webservice error: underlying connection was closed Pin
Kannan Kalyanaraman10-Jul-03 0:40
Kannan Kalyanaraman10-Jul-03 0:40 
GeneralContextMenu & TextBox Pin
almigrp9-Jul-03 20:27
almigrp9-Jul-03 20:27 
GeneralRe: ContextMenu & TextBox Pin
Heath Stewart10-Jul-03 3:32
protectorHeath Stewart10-Jul-03 3:32 
GeneralRe: ContextMenu & TextBox Pin
KingTermite11-Jul-03 7:49
KingTermite11-Jul-03 7:49 
GeneralRe: ContextMenu & TextBox Pin
almigrp11-Jul-03 21:23
almigrp11-Jul-03 21:23 
QuestionImage Transform ? Pin
azusakt9-Jul-03 20:18
azusakt9-Jul-03 20:18 
GeneralImage effects Pin
Meysam Mahfouzi9-Jul-03 20:09
Meysam Mahfouzi9-Jul-03 20:09 
QuestionMessage Box ? Pin
Asim N.9-Jul-03 19:11
Asim N.9-Jul-03 19:11 
AnswerRe: Message Box ? Pin
J. Dunlap9-Jul-03 19:35
J. Dunlap9-Jul-03 19:35 
GeneralC# full screen Pin
Meysam Mahfouzi9-Jul-03 17:17
Meysam Mahfouzi9-Jul-03 17:17 
GeneralRe: C# full screen Pin
J. Dunlap9-Jul-03 17:20
J. Dunlap9-Jul-03 17:20 
GeneralRe: C# full screen Pin
Meysam Mahfouzi9-Jul-03 19:42
Meysam Mahfouzi9-Jul-03 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.