home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / ID_Card_Ma2071636202007.psc / Form1.frm < prev    next >
Text File  |  2007-06-20  |  16KB  |  494 lines

  1. VERSION 5.00
  2. Begin VB.Form frmID_ICMWIC 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   " ID CARD MAKER WEBCAM IMAGE CAPTURE"
  5.    ClientHeight    =   9135
  6.    ClientLeft      =   1890
  7.    ClientTop       =   1215
  8.    ClientWidth     =   11850
  9.    ForeColor       =   &H00000000&
  10.    Icon            =   "Form1.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   609
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   790
  17.    Begin VB.CommandButton Command8 
  18.       Height          =   735
  19.       Left            =   10080
  20.       Picture         =   "Form1.frx":1002
  21.       Style           =   1  'Graphical
  22.       TabIndex        =   16
  23.       ToolTipText     =   "SHOW HELP"
  24.       Top             =   8280
  25.       Width           =   735
  26.    End
  27.    Begin VB.Frame Frame2 
  28.       Caption         =   "WEBCAM CAPTURE  && SAVE OPTIONS"
  29.       Height          =   1335
  30.       Left            =   5160
  31.       TabIndex        =   11
  32.       Top             =   7680
  33.       Width           =   3975
  34.       Begin VB.CommandButton Command2 
  35.          Enabled         =   0   'False
  36.          Height          =   735
  37.          Left            =   3000
  38.          Picture         =   "Form1.frx":1CCC
  39.          Style           =   1  'Graphical
  40.          TabIndex        =   15
  41.          ToolTipText     =   "SAVE CAPTURED PICTURE AS A JPEG"
  42.          Top             =   360
  43.          Width           =   735
  44.       End
  45.       Begin VB.CommandButton Command3 
  46.          Enabled         =   0   'False
  47.          Height          =   735
  48.          Left            =   960
  49.          Picture         =   "Form1.frx":2596
  50.          Style           =   1  'Graphical
  51.          TabIndex        =   14
  52.          ToolTipText     =   "STOP WEBCAM "
  53.          Top             =   360
  54.          Width           =   735
  55.       End
  56.       Begin VB.CommandButton Command4 
  57.          Height          =   735
  58.          Left            =   120
  59.          Picture         =   "Form1.frx":28A0
  60.          Style           =   1  'Graphical
  61.          TabIndex        =   13
  62.          ToolTipText     =   "START WEBCAM CAPTURE"
  63.          Top             =   360
  64.          Width           =   735
  65.       End
  66.       Begin VB.CommandButton Command5 
  67.          Enabled         =   0   'False
  68.          Height          =   735
  69.          Left            =   2160
  70.          Picture         =   "Form1.frx":2BAA
  71.          Style           =   1  'Graphical
  72.          TabIndex        =   12
  73.          ToolTipText     =   "CAPTURE STOPPED WEBCAM IMAGE"
  74.          Top             =   360
  75.          Width           =   735
  76.       End
  77.    End
  78.    Begin VB.Frame Frame1 
  79.       Caption         =   "WEBCAM SETUP OPTIONS"
  80.       Height          =   1335
  81.       Left            =   240
  82.       TabIndex        =   8
  83.       Top             =   7680
  84.       Width           =   2415
  85.       Begin VB.CommandButton Command6 
  86.          Height          =   735
  87.          Left            =   240
  88.          Picture         =   "Form1.frx":3474
  89.          Style           =   1  'Graphical
  90.          TabIndex        =   10
  91.          ToolTipText     =   "WEBCAM SET UP OPTIONS"
  92.          Top             =   360
  93.          Width           =   735
  94.       End
  95.       Begin VB.CommandButton Command7 
  96.          Height          =   735
  97.          Left            =   1320
  98.          Picture         =   "Form1.frx":377E
  99.          Style           =   1  'Graphical
  100.          TabIndex        =   9
  101.          ToolTipText     =   "WEBCAM IMAGE SIZE AND SELECT CAM OPTIONS"
  102.          Top             =   360
  103.          Width           =   735
  104.       End
  105.    End
  106.    Begin VB.TextBox Text1 
  107.       Height          =   285
  108.       Left            =   5040
  109.       TabIndex        =   7
  110.       Text            =   "Text1"
  111.       Top             =   7238
  112.       Width           =   6735
  113.    End
  114.    Begin VB.PictureBox Picture3 
  115.       Height          =   6975
  116.       Left            =   6000
  117.       ScaleHeight     =   6915
  118.       ScaleWidth      =   5715
  119.       TabIndex        =   6
  120.       Top             =   120
  121.       Width           =   5775
  122.    End
  123.    Begin VB.PictureBox Picture2 
  124.       Height          =   6975
  125.       Left            =   120
  126.       ScaleHeight     =   6915
  127.       ScaleWidth      =   5715
  128.       TabIndex        =   5
  129.       Top             =   120
  130.       Width           =   5775
  131.       Begin VB.Image Image1 
  132.          Height          =   5280
  133.          Left            =   240
  134.          Top             =   0
  135.          Width           =   4800
  136.       End
  137.    End
  138.    Begin VB.CommandButton Command1 
  139.       Height          =   735
  140.       Left            =   11040
  141.       Picture         =   "Form1.frx":4448
  142.       Style           =   1  'Graphical
  143.       TabIndex        =   4
  144.       ToolTipText     =   "EXIT THIS SCREEN:- BY THE NEAREST DOOR!"
  145.       Top             =   8280
  146.       Width           =   735
  147.    End
  148.    Begin VB.PictureBox Picture1 
  149.       Height          =   885
  150.       Left            =   9600
  151.       ScaleHeight     =   825
  152.       ScaleWidth      =   1305
  153.       TabIndex        =   3
  154.       Top             =   2160
  155.       Visible         =   0   'False
  156.       Width           =   1365
  157.    End
  158.    Begin VB.FileListBox File1 
  159.       Height          =   1650
  160.       Left            =   570
  161.       Pattern         =   "*.bmp"
  162.       TabIndex        =   1
  163.       Top             =   1290
  164.       Visible         =   0   'False
  165.       Width           =   1425
  166.    End
  167.    Begin VB.Timer Timer1 
  168.       Left            =   6000
  169.       Top             =   6720
  170.    End
  171.    Begin VB.Label Label2 
  172.       Alignment       =   2  'Center
  173.       AutoSize        =   -1  'True
  174.       BackColor       =   &H00FF0000&
  175.       BackStyle       =   0  'Transparent
  176.       Caption         =   "Each Picture saved in folder ..\myPic\"
  177.       BeginProperty Font 
  178.          Name            =   "MS Sans Serif"
  179.          Size            =   13.5
  180.          Charset         =   0
  181.          Weight          =   400
  182.          Underline       =   0   'False
  183.          Italic          =   0   'False
  184.          Strikethrough   =   0   'False
  185.       EndProperty
  186.       Height          =   360
  187.       Left            =   210
  188.       TabIndex        =   2
  189.       Top             =   7200
  190.       Width           =   4665
  191.    End
  192.    Begin VB.Label Label1 
  193.       Alignment       =   1  'Right Justify
  194.       Height          =   255
  195.       Left            =   840
  196.       TabIndex        =   0
  197.       Top             =   3720
  198.       Width           =   945
  199.    End
  200.    Begin VB.Image Image2 
  201.       Appearance      =   0  'Flat
  202.       Height          =   315
  203.       Left            =   840
  204.       Picture         =   "Form1.frx":5112
  205.       Top             =   3720
  206.       Width           =   930
  207.    End
  208. End
  209. Attribute VB_Name = "frmID_ICMWIC"
  210. Attribute VB_GlobalNameSpace = False
  211. Attribute VB_Creatable = False
  212. Attribute VB_PredeclaredId = True
  213. Attribute VB_Exposed = False
  214. '******************************************
  215. '
  216. '   collected,Converted and Edited by :
  217. '        Mohammed Samir Fayed
  218. '              10/2004
  219. '
  220. '******************************************
  221.  
  222. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  223. Private Declare Sub ReleaseCapture Lib "user32" ()
  224. Const WM_NCLBUTTONDOWN = &HA1
  225. Const HTCAPTION = 2
  226.  
  227.     Private m_TimeToCapture_milliseconds As Integer
  228.     
  229.     Private m_Width As Long
  230.     Private m_Height As Long
  231.     
  232.     Private mCapHwnd As Long
  233.    
  234.     Private bStopped As Boolean
  235. 'Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  236. 'Private Declare Function ReleaseCapture Lib "user32" () As Long
  237. Private CurX As Double
  238. Private CurY As Double
  239.  
  240. Private Const WM_PAINT = &HF
  241. Private Const WM_PRINT = &H317
  242. Private Const PRF_CLIENT = &H4&    ' Draw the window's client area
  243. Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows
  244. Private Const PRF_OWNED = &H20&    ' Draw all owned windows
  245.  
  246. Private Sub Command1_Click()
  247. Timer1.Enabled = False
  248.     If mCapHwnd <> 0 Then StopWork
  249.     Unload Me
  250.     frmID_Card.WindowState = vbNormal
  251.  
  252. End Sub
  253.  
  254. Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  255. '*******************************************************
  256. '*            set the command button cursor            *
  257. '*******************************************************
  258. Command1.MousePointer = 99
  259. Command1.MouseIcon = LoadResPicture(103, vbResCursor)
  260. End Sub
  261.  
  262. Private Sub Command2_Click()
  263. On Error Resume Next
  264. DoEvents
  265. If Dir(App.Path & "\myPic", vbDirectory) = "" Then MkDir (App.Path & "\myPic")
  266.  
  267. File1.Path = App.Path & "\myPic"
  268. File1.Pattern = "*.jpg"
  269. File1.Refresh
  270.  
  271.  
  272.     Picture1.Picture = Picture3.Picture 'Image1.Picture
  273.     SAVEJPEG App.Path & "\myPic\" & Text1.Text & ".jpg", 100, Me.Picture1
  274.   DoEvents
  275.   
  276. Command2.Enabled = False
  277. End Sub
  278.  
  279. Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  280. '*******************************************************
  281. '*            set the command button cursor            *
  282. '*******************************************************
  283. Command2.MousePointer = 99
  284. Command2.MouseIcon = LoadResPicture(103, vbResCursor)
  285. End Sub
  286.  
  287. Private Sub Command3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  288. '*******************************************************
  289. '*            set the command button cursor            *
  290. '*******************************************************
  291. Command3.MousePointer = 99
  292. Command3.MouseIcon = LoadResPicture(103, vbResCursor)
  293. End Sub
  294.  
  295. Private Sub Command4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  296. '*******************************************************
  297. '*            set the command button cursor            *
  298. '*******************************************************
  299. Command4.MousePointer = 99
  300. Command4.MouseIcon = LoadResPicture(103, vbResCursor)
  301. End Sub
  302.  
  303. Private Sub Command5_Click()
  304. '*******************************************************
  305. '*          show the card preview window               *
  306. '*        minimises the main design window             *
  307. '*******************************************************
  308. Dim rv As Long
  309.  
  310. '* this came straight from ms technet!
  311. Picture3.AutoRedraw = True
  312. rv = SendMessage(Picture2.hwnd, WM_PAINT, Picture3.hdc, 0)
  313. rv = SendMessage(Picture2.hwnd, WM_PRINT, Picture3.hdc, PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
  314. Picture3.Picture = Picture3.image
  315. Picture3.AutoRedraw = False
  316.  
  317. Command5.Enabled = False
  318. Command2.Enabled = True
  319. End Sub
  320.  
  321. Private Sub Command5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  322. '*******************************************************
  323. '*            set the command button cursor            *
  324. '*******************************************************
  325. Command5.MousePointer = 99
  326. Command5.MouseIcon = LoadResPicture(103, vbResCursor)
  327. End Sub
  328.  
  329. Private Sub Command6_Click()
  330. On Error Resume Next
  331.   If mCapHwnd = 0 Then Exit Sub
  332.  
  333.     Call SendMessage(mCapHwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0)
  334.     DoEvents
  335. End Sub
  336.  
  337. Private Sub Command6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  338. '*******************************************************
  339. '*            set the command button cursor            *
  340. '*******************************************************
  341. Command6.MousePointer = 99
  342. Command6.MouseIcon = LoadResPicture(103, vbResCursor)
  343. End Sub
  344.  
  345. Private Sub Command7_Click()
  346. On Error Resume Next
  347.     
  348.     If mCapHwnd = 0 Then Exit Sub
  349.  
  350.     Call SendMessage(mCapHwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0)
  351.     DoEvents
  352. End Sub
  353.  
  354. Private Sub Command7_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  355. '*******************************************************
  356. '*            set the command button cursor            *
  357. '*******************************************************
  358. Command7.MousePointer = 99
  359. Command7.MouseIcon = LoadResPicture(103, vbResCursor)
  360. End Sub
  361.  
  362. Private Sub Command8_Click()
  363. '*******************************************************
  364. '*                      show help                      *
  365. '*******************************************************
  366. frmID_Help.Show
  367. frmID_Help.Command5.Enabled = True
  368. End Sub
  369.  
  370. Private Sub Command8_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  371. '*******************************************************
  372. '*            set the command button cursor            *
  373. '*******************************************************
  374. Command8.MousePointer = 99
  375. Command8.MouseIcon = LoadResPicture(103, vbResCursor)
  376. End Sub
  377.  
  378. Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  379. '*******************************************************
  380. '*               set the select drag cursor            *
  381. '*******************************************************
  382. CurX = X
  383. CurY = Y
  384. Image1.MousePointer = 99
  385. Image1.MouseIcon = LoadResPicture(101, vbResCursor)
  386. End Sub
  387. Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  388. '*******************************************************
  389. '*       set cursor & drag the picture around          *
  390. '*******************************************************
  391. If Button = 2 Then
  392. Image1.Move Image1.Left + (X - CurX), Image1.Top + (Y - CurY)
  393. Image1.MousePointer = 99
  394. Image1.MouseIcon = LoadResPicture(101, vbResCursor)
  395. End If
  396. End Sub
  397. Private Sub Command3_Click()
  398. StopWork
  399.     Command6.Enabled = False
  400.     Command7.Enabled = False
  401.     Command3.Enabled = False
  402.     Command4.Enabled = True
  403.     Command5.Enabled = True
  404. End Sub
  405.  
  406. Private Sub Command4_Click()
  407.  Start
  408.  Command6.Enabled = True
  409. Command7.Enabled = True
  410. Command3.Enabled = True
  411. Command4.Enabled = False
  412. End Sub
  413.  
  414. Private Sub Form_Load()
  415. On Error Resume Next
  416.     m_TimeToCapture_milliseconds = 100
  417.     m_Width = 352
  418.     m_Height = 288
  419.     bStopped = True
  420.     mCapHwnd = 0
  421.     
  422. End Sub
  423.  
  424. Public Sub Start()
  425.     On Error Resume Next
  426.     If mCapHwnd <> 0 Then Exit Sub
  427.     FrameNum = 0
  428.     
  429.     Timer1.Interval = m_TimeToCapture_milliseconds
  430.  
  431.     ' for safety, call stop, just in case we are already running
  432.     Me.Timer1.Enabled = False
  433.  
  434.     ' setup a capture window
  435.     mCapHwnd = capCreateCaptureWindowA("WebCap", 0, 0, 0, m_Width, m_Height, Me.hwnd, 0)
  436.     DoEvents
  437.     
  438.     ' connect to the capture device
  439.     Call SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0)
  440.     DoEvents
  441.     
  442.     Call SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0)
  443.  
  444.     ' set the timer information
  445.     bStopped = False
  446.     Me.Timer1.Enabled = True
  447.         
  448.  
  449. End Sub
  450.     
  451. Public Sub StopWork()
  452.     On Error Resume Next
  453.     ' stop the timer
  454.     bStopped = True
  455.     Timer1.Enabled = False
  456.  
  457.     ' disconnect from the video source
  458.     DoEvents
  459.  
  460.     Call SendMessage(mCapHwnd, WM_CAP_DISCONNECT, 0, 0)
  461.     mCapHwnd = 0
  462.  
  463. End Sub
  464.  
  465.  
  466. Private Sub Timer1_Timer()
  467. On Error Resume Next
  468.  
  469.     ' pause the timer
  470.     Timer1.Enabled = False
  471.  
  472.     ' get the next frame;
  473.     Call SendMessage(mCapHwnd, WM_CAP_GET_FRAME, 0, 0)
  474.  
  475.     ' copy the frame to the clipboard
  476.     Call SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0)
  477.  
  478.     ' For some reason, the API is not resizing the video
  479.     ' feed to the width and height provided when the video
  480.     ' feed was started, so we must resize the image here
  481.     ' Image1.Stretch = True
  482.             
  483.     ' get from the clipboard
  484.     Image1.Picture = Clipboard.GetData
  485.          
  486.          
  487.     ' restart the timer
  488.     DoEvents
  489.     If Not bStopped Then
  490.         Timer1.Enabled = True
  491.     End If
  492.  
  493. End Sub
  494.