Click here to Skip to main content
16,006,440 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Invert Color Pin
Nadroj22-Mar-04 15:18
Nadroj22-Mar-04 15:18 
GeneralRe: Invert Color Pin
Guerven22-Mar-04 15:49
Guerven22-Mar-04 15:49 
GeneralRe: Invert Color Pin
xstoneheartx22-Mar-04 23:47
xstoneheartx22-Mar-04 23:47 
GeneralRe: Invert Color Pin
xstoneheartx23-Mar-04 1:57
xstoneheartx23-Mar-04 1:57 
GeneralVB.NET Clipboard Change Pin
jordan200022-Mar-04 5:36
jordan200022-Mar-04 5:36 
GeneralRe: VB.NET Clipboard Change Pin
Dave Kreskowiak23-Mar-04 2:08
mveDave Kreskowiak23-Mar-04 2:08 
GeneralRe: VB.NET Clipboard Change Pin
jordan200023-Mar-04 5:30
jordan200023-Mar-04 5:30 
GeneralRe: VB.NET Clipboard Change Pin
Dave Kreskowiak23-Mar-04 6:06
mveDave Kreskowiak23-Mar-04 6:06 
Are you saying the when a user presses PrtScrn or Alt-PrtScrn, you want you app to be notified that there is something new on the clipboard?

If that's true, now I understand...

Ummm...OK.

Your going to have to override the WndProc function in your form to receive the WM_DRAWCLIPBOARD message and process it. You'll also need to process WM_CHANGECBCHAIN too if other applications register as clipboard viewers, you can repair the end of the chain if your suddently the last in the chain. You'll need to use the SendMessage, SetClipBoardViewer and ChangeClipboardChain functions, in user32.dll, and GetLastError, in kernel32, to handle this.

What your going to do is when your app starts, call SetClipBoardViewer with the window handle of your form. You'll have to save the return value as this is the handle of the next window in the clipboard viewer chain. Next, call GetLastError to see if what you got back was an error or a null handle.

Now, in you WndProc procedure, when you get the WM_DRAWCLIPBOARD message, you can use the standard .NET Clipboard functions to get the image from the clipboard and display it in a PictureBox if need be. You'll then need to use SendMessage to send the same message you got to the next window in the chain, (remember that return value from SetClipBoardViewer?) unless it's null.

Now, you may be wondering why you have to handle WM_CHANGECBCHAIN. This is because if the next window in the chain is the one that your supposed to send the WM_DRACLIPBOARD to, you'll need to know that it's been removed and you no longer have to send that message, or you'll need to send it to a different window now.

.
.
I've lost you, haven't I...?

Last but not least, when your app quits, you have to remove yourself from the viewer chain. This is done by calling ChangeClipboardChain with your window handle and the window handle of the window your supposed to be forwarding WM_DRAWCLIPBOARD messages to.

Simple, no? Smile | :)


RageInTheMachine9532
GeneralRe: VB.NET Clipboard Change Pin
Dave Kreskowiak23-Mar-04 6:23
mveDave Kreskowiak23-Mar-04 6:23 
GeneralDynaimic Context Menus With Icons and Text. Pin
EmanAli22-Mar-04 2:29
EmanAli22-Mar-04 2:29 
GeneralCreating The Real Ruler in vb.net like officeXp or WordPAd Pin
azeemgujjar21-Mar-04 23:52
azeemgujjar21-Mar-04 23:52 
GeneralRe: Creating The Real Ruler in vb.net like officeXp or WordPAd Pin
Steve S22-Mar-04 1:35
Steve S22-Mar-04 1:35 
GeneralRe: Creating The Real Ruler in vb.net like officeXp or WordPAd Pin
azeemgujjar22-Mar-04 8:50
azeemgujjar22-Mar-04 8:50 
GeneralRe: Creating The Real Ruler in vb.net like officeXp or WordPAd Pin
Edbert P22-Mar-04 15:57
Edbert P22-Mar-04 15:57 
GeneralRe: Creating The Real Ruler in vb.net like officeXp or WordPAd Pin
cnurse22-Mar-04 17:54
cnurse22-Mar-04 17:54 
GeneralRe: Creating The Real Ruler in vb.net like officeXp or WordPAd Pin
xstoneheartx22-Mar-04 23:59
xstoneheartx22-Mar-04 23:59 
GeneralAccelerator Keys Pin
cnurse21-Mar-04 18:38
cnurse21-Mar-04 18:38 
GeneralCommon Language Runtime Error when Loading vb.net Application in Win 98 Pin
Anonymous21-Mar-04 16:51
Anonymous21-Mar-04 16:51 
GeneralAccess VBA question Pin
gpa200021-Mar-04 6:38
gpa200021-Mar-04 6:38 
GeneralRe: Access VBA question Pin
Edbert P22-Mar-04 11:35
Edbert P22-Mar-04 11:35 
GeneralRe: Access VBA question Pin
gpa200022-Mar-04 20:41
gpa200022-Mar-04 20:41 
GeneralIntermittent: Multiple custom attributes of the same type found. Pin
cnurse20-Mar-04 23:19
cnurse20-Mar-04 23:19 
GeneralCheck if PC is Idle Pin
LC Chan20-Mar-04 20:16
LC Chan20-Mar-04 20:16 
GeneralSoftware Licensing Pin
Wayne Phipps20-Mar-04 8:17
Wayne Phipps20-Mar-04 8:17 
Generalprocess bar Pin
yousafkamal20-Mar-04 7:13
yousafkamal20-Mar-04 7:13 

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.