Visual Basic 6 Black Book:Connecting To The Windows API And Visual C++
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Finally, when the user releases the mouse button, we release the mouse with ReleaseCapture and reset the Boolean flags:
Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, _
y As Single)
If blnAmCapturing Then
ReleaseCapture
blnStartCapture = False
blnAmCapturing = False
Command1.Caption = "Start capture"
End If
End Sub
Thats itnow run the program, as shown in Figure 23.6. Click the button in the program and drag the mouse. No matter where you drag the mouse, the mouse location is displayed in the text boxes in the program. Weve captured the mouse. To release the mouse, just release the mouse button.
Figure 23.6 Using the mouse outside a program.
Theres one peculiarity you should know about here: starting with Windows 95, you can only capture the mouse for one mouse operation; when you finish with the mouse, it is released. That means if you start the mouse drag by pressing the mouse button while inside the programs window, everything is finethe program retains control of the mouse while you drag. If, on the other hand, you press the mouse button outside the programs window and start to drag, the mouse is released.
You can remedy this problem, as we do in our screen capture program later in this chapter, by using the right mouse button for mouse operations. In that program, we have the users drag the mouse by pressing the mouse button in the programs window, dragging the mouse to the top left of the rectangle they want to capture, then use the right mouse button (while holding the left one down) to capture that rectangle.
The code for this program is located in the mousecap folder on this books accompanying CD-ROM.
Copying Bitmaps Between Device Contexts Quickly
One of the most common reasons to use Windows API functions is to make fast bitmap transfers, which you can do with the BitBlt function. This function lets you copy a bitmap from one device context to another very quickly:
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As _
Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal _
nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal _
ySrc As Long, ByVal dwRop As Long) As Long
Heres what this functions arguments mean:
hDestDCThe destination device context to copy to
xThe x-coordinate of the upper-left corner of the destination rectangle
yThe y-coordinate of the upper-left corner of the destination rectangle
nWidthThe width of the destination rectangle and source bitmap
nHeightThe height of the destination rectangle and source bitmap
hSrcDCThe source device context to copy from
xSrcThe logical x-coordinate of the upper-left corner of the source bitmap
ySrcThe logical y-coordinate of the upper-left corner of the source bitmap
dwRopThe raster operation to be performed
You can find the possible values for the dwRop argument in Table 23.4.
Table 23.4 BitBlt raster operations.
dwRop Constant
Operation
SRCCOPY = &HCC0020
destination = source
SRCPAINT = &HEE0086
destination = source OR destination
SRCAND = &H8800C6
destination = source AND destination
SRCINVERT = &H660046
destination = source XOR destination
SRCERASE = &H440328
destination = source AND (NOT destination)
NOTSRCCOPY = &H330008
destination = (NOT source)
NOTSRCERASE = &H1100A6
destination = (NOT src) AND (NOT destination)
MERGECOPY = &HC000CA
destination = (source AND pattern)
MERGEPAINT = &HBB0226
destination = (NOT source) OR destination
PATCOPY = &HF00021
destination = pattern
PATPAINT = &HFB0A09
destination = pattern OR source
PATINVERT = &H5A0049
destination = pattern XOR destination
DSTINVERT = &H550009
destination = (NOT destination)
BLACKNESS = &H42
destination = BLACK
WHITENESS = &HFF0062
destination = WHITE
Well put BitBlt to work when we capture the screen in the next topic.
Capturing Images From The Screen
Well put together the previous topics in this chapter into one substantial screen capture example: screencap. Using this program, you can capture sections of the screen and display them in a picture box.
When you run this program, press the left mouse button on the programs form, then drag the mouse to the top left of the rectangular region you want to capture. Then, using the right mouse button (while holding the left one down) draw the rectangle you want to capture. A box outlining that region will appear on the screen as you move the mouse, as shown in Figure 23.7.
Figure 23.7 Outlining a region on the screen.
When you release the mouse buttons, the region youve outline appears in the picture box in the program, as shown in Figure 23.8. Youve captured an image from the screen.
Figure 23.8 Capturing a region of the screen.
Why do we have to drag the mouse before making the screen capture? Theres a peculiarity in mouse capture starting in Windows 95: when you capture the mouse, you can only hold it until you finish with a mouse operation; when you do, the mouse is released. To hold the mouse, we start the dragging process in the programs form itself and only release all mouse buttons when were done capturing the image we want.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
index (795)793 79520030817180632id!795index (792)795 800790 792792 (2)mbdch20 792mbdch20 795więcej podobnych podstron