Click here to Skip to main content
15,916,945 members
Home / Discussions / C#
   

C#

 
GeneralRe: dll question Pin
Nick Parker10-Jul-03 8:39
protectorNick Parker10-Jul-03 8:39 
GeneralRe: dll question Pin
Heath Stewart10-Jul-03 9:00
protectorHeath Stewart10-Jul-03 9:00 
QuestionHow to Set Widths of Columns in a DataGrid, Anyone? Pin
Khang Nguyen10-Jul-03 6:17
Khang Nguyen10-Jul-03 6:17 
AnswerRe: How to Set Widths of Columns in a DataGrid, Anyone? Pin
Heath Stewart10-Jul-03 9:11
protectorHeath Stewart10-Jul-03 9:11 
GeneralRe: How to Set Widths of Columns in a DataGrid, Anyone? Pin
Khang Nguyen10-Jul-03 11:50
Khang Nguyen10-Jul-03 11:50 
GeneralExport Unmanaged DLL's classes instead of just function using PInvoke Pin
Anonymous10-Jul-03 5:40
Anonymous10-Jul-03 5:40 
GeneralRe: Export Unmanaged DLL's classes instead of just function using PInvoke Pin
leppie10-Jul-03 7:10
leppie10-Jul-03 7:10 
GeneralRe: Export Unmanaged DLL's classes instead of just function using PInvoke Pin
Anonymous10-Jul-03 7:36
Anonymous10-Jul-03 7:36 
GeneralRe: Export Unmanaged DLL's classes instead of just function using PInvoke Pin
leppie10-Jul-03 11:24
leppie10-Jul-03 11:24 
GeneralError Reading from MDB System Table Pin
SD310-Jul-03 5:17
SD310-Jul-03 5:17 
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 

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.