Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > How to choose a pixel


Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2006, 11:21 PM
pfox_64 pfox_64 is offline
Newcomer
 
Join Date: Apr 2006
Posts: 3
Talking How to choose a pixel


ok i need to know how to monitor a pixel. i want to create a program that lets u select a pixel then monitor it for change. after it changes it will play a sound. i have only worked on basic forms and the like. I just need some help on how to use the mouse to select a pixel.
Reply With Quote
  #2  
Old 12-08-2006, 11:32 PM
Volte's Avatar
Volte Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,343
Default

Do you mean a pixel anywhere on the screen, or just on one of your own forms? You can use the GetPixel API to get the color of a pixel, and if you want to get the color of a pixel anywhere on the screen use the GetDC API with an hWnd parameter of 0 to get the hDC of the whole screen.
Reply With Quote
  #3  
Old 12-08-2006, 11:40 PM
pfox_64 pfox_64 is offline
Newcomer
 
Join Date: Apr 2006
Posts: 3
Default

i need to be able to select the pixel to be monitored with the mouse. So i could monitor a pixel anywhere on the screen
Reply With Quote
  #4  
Old 12-09-2006, 12:06 AM
Volte's Avatar
Volte Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,343
Default

The simplest way to do this is most likely to make it so rather than clicking on a specific pixel, the user has to push a specific key to select the pixel on which the mouse is hovering. The reason for this is that it's difficult to make your app process a click outside the main app window, so the program would lose focus and not be able to process the click.

Alternatively, you could "fake" it using a screenshot of the whole screen (This module includes a function that lets to take a screenshot of an hDC and return a Picture object called hDCToPicture. You could show that picture on a fullscreen form that allows you to click on it, return the pixel color, hide the form and continue normally. If it's done right it should look fairly transparent (other than any on-screen animation).
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->