home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / zuck / vbaust1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  9.5 KB  |  299 lines

  1. VERSION 2.00
  2. Begin Form CmdTextLines 
  3.    Caption         =   "Accessing the Windows API"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   1755
  6.    ClientTop       =   2295
  7.    ClientWidth     =   7365
  8.    Height          =   4710
  9.    Left            =   1695
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4020
  12.    ScaleWidth      =   7365
  13.    Top             =   1665
  14.    Width           =   7485
  15.    Begin PictureBox MenuPicture 
  16.       Height          =   495
  17.       Left            =   3780
  18.       Picture         =   VBAUST1.FRX:0000
  19.       ScaleHeight     =   465
  20.       ScaleWidth      =   465
  21.       TabIndex        =   15
  22.       Top             =   3360
  23.       Width           =   495
  24.    End
  25.    Begin CommandButton Command1 
  26.       Caption         =   "Menu"
  27.       Height          =   375
  28.       Left            =   1740
  29.       TabIndex        =   14
  30.       Top             =   1020
  31.       Width           =   1275
  32.    End
  33.    Begin CommandButton CmdBitBlt 
  34.       Caption         =   "BitBlt"
  35.       Height          =   375
  36.       Left            =   1740
  37.       TabIndex        =   13
  38.       Top             =   600
  39.       Width           =   1275
  40.    End
  41.    Begin CommandButton CmdTextLines 
  42.       Caption         =   "TextLines"
  43.       Height          =   375
  44.       Left            =   1740
  45.       TabIndex        =   12
  46.       Top             =   180
  47.       Width           =   1275
  48.    End
  49.    Begin TextBox Text1 
  50.       Height          =   1335
  51.       Left            =   4320
  52.       MultiLine       =   -1  'True
  53.       TabIndex        =   11
  54.       Text            =   "This text box contains multiple lines.  The Windows API provides a mechanism for manipulating a text box on a line oriented basis."
  55.       Top             =   2520
  56.       Width           =   2355
  57.    End
  58.    Begin CommandButton CmdGetProfile 
  59.       Caption         =   "GetProfile"
  60.       Height          =   375
  61.       Left            =   180
  62.       TabIndex        =   10
  63.       Top             =   3540
  64.       Width           =   1335
  65.    End
  66.    Begin CommandButton CmdModuleUsage 
  67.       Caption         =   "ModuleUsage"
  68.       Height          =   375
  69.       Left            =   180
  70.       TabIndex        =   9
  71.       Top             =   3120
  72.       Width           =   1335
  73.    End
  74.    Begin CommandButton CmdDrawText 
  75.       Caption         =   "DrawText"
  76.       Height          =   375
  77.       Left            =   180
  78.       TabIndex        =   8
  79.       Top             =   2700
  80.       Width           =   1335
  81.    End
  82.    Begin CommandButton CmdNumColors 
  83.       Caption         =   "NumColors"
  84.       Height          =   375
  85.       Left            =   180
  86.       TabIndex        =   7
  87.       Top             =   2280
  88.       Width           =   1335
  89.    End
  90.    Begin Timer Timer1 
  91.       Interval        =   200
  92.       Left            =   6780
  93.       Top             =   2460
  94.    End
  95.    Begin CommandButton CmdMinProgman 
  96.       Caption         =   "MinProgMan"
  97.       Height          =   375
  98.       Left            =   180
  99.       TabIndex        =   5
  100.       Top             =   1860
  101.       Width           =   1335
  102.    End
  103.    Begin CommandButton CmdSetText 
  104.       Caption         =   "SetText"
  105.       Height          =   375
  106.       Left            =   180
  107.       TabIndex        =   4
  108.       Top             =   1440
  109.       Width           =   1335
  110.    End
  111.    Begin CommandButton CmdBrushDraw 
  112.       Caption         =   "BrushDraw"
  113.       Height          =   375
  114.       Left            =   180
  115.       TabIndex        =   3
  116.       Top             =   1020
  117.       Width           =   1335
  118.    End
  119.    Begin CommandButton CmdRectDraw 
  120.       Caption         =   "RectDraw"
  121.       Height          =   375
  122.       Left            =   180
  123.       TabIndex        =   2
  124.       Top             =   600
  125.       Width           =   1335
  126.    End
  127.    Begin PictureBox Picture1 
  128.       Height          =   1815
  129.       Left            =   4320
  130.       ScaleHeight     =   1785
  131.       ScaleWidth      =   2865
  132.       TabIndex        =   1
  133.       Top             =   240
  134.       Width           =   2895
  135.    End
  136.    Begin CommandButton CmdHwndRect 
  137.       Caption         =   "HwndRect"
  138.       Height          =   375
  139.       Left            =   180
  140.       TabIndex        =   0
  141.       Top             =   180
  142.       Width           =   1335
  143.    End
  144.    Begin Label labelkeys 
  145.       BorderStyle     =   1  'Fixed Single
  146.       Height          =   255
  147.       Left            =   4320
  148.       TabIndex        =   6
  149.       Top             =   2100
  150.       Width           =   2895
  151.    End
  152.    Begin Menu Mnu_Top 
  153.       Caption         =   "Menu"
  154.       Begin Menu mnu_entry 
  155.          Caption         =   "Entry #1"
  156.          Index           =   0
  157.       End
  158.       Begin Menu mnu_entry 
  159.          Caption         =   "Entry #2"
  160.          Index           =   1
  161.       End
  162.    End
  163. ' ------------------------------------------------------------------------
  164. '     VBits1.FRM -- Demonstration of Windows API Access
  165. '                       Copyright (C) 1993 Desaware
  166. '  You have a royalty-free right to use, modify, reproduce and distribute
  167. '  this file (and/or any modified version) in any way you find useful,
  168. '  provided that you agree that Desaware has no
  169. '  warranty, obligation or liability for its contents.
  170. ' ------------------------------------------------------------------------
  171. Option Explicit
  172. Sub CmdBitBlt_Click ()
  173.     Dim rc As RECT
  174.     Dim di%
  175.     GetClientRect picture1.hWnd, rc
  176.     ' Copy left half of picture to right half
  177.     di% = BitBlt(picture1.hDC, rc.right / 2, 0, rc.right / 2, rc.bottom, picture1.hDC, 0, 0, SRCCOPY)
  178. End Sub
  179. Sub CmdBrushDraw_Click ()
  180.     Dim hbrush%, oldbrush%, di%
  181.     ' Create the red brush
  182.     hbrush% = CreateSolidBrush%(&HFF&)
  183.     ' Select if for use.
  184.     oldbrush% = SelectObject%(picture1.hDC, hbrush%)
  185.     ' Draw with it
  186.     di% = Rectangle(picture1.hDC, 10, 10, 75, 75)
  187.     ' Select it out of the hDC before deleting it.
  188.     hbrush% = SelectObject%(picture1.hDC, oldbrush%)
  189.     di% = DeleteObject%(hbrush%)
  190. End Sub
  191. Sub CmdDrawText_Click ()
  192.     Dim rc As RECT
  193.     Dim outp$
  194.     Dim di%
  195.     ' Get coordinates of the picture control
  196.     GetClientRect picture1.hWnd, rc
  197.     ' Shrink it a bit
  198.     InflateRect rc, -5, -5
  199.     outp$ = "This is a demonstration of word wrapping. "
  200.     outp$ = outp$ + "And this is the second line that "
  201.     outp$ = outp$ + "demonstrates word wrapping."
  202.     di% = DrawText(picture1.hDC, outp$, Len(outp$), rc, DT_WORDBREAK)
  203. End Sub
  204. Sub CmdGetProfile_Click ()
  205.     Dim prof As String * 64
  206.     Dim di%
  207.     di% = GetProfileString("Windows", "Device", "", prof, 63)
  208.     MsgBox prof, 0, "Default Printer is"
  209. End Sub
  210. Sub CmdHwndRect_Click ()
  211.     Dim rc As RECT
  212.     Dim comma$
  213.     GetWindowRect hWnd, rc
  214.     comma$ = " , "
  215.     MsgBox rc.left & comma$ & rc.top & comma$ & rc.right & comma$ & rc.bottom, 0, "Window Rectangle in Screen Coordinates"
  216. End Sub
  217. Sub CmdMinProgman_Click ()
  218.     Dim proghWnd%
  219.     proghWnd% = FindWindowByString(0, "Program Manager")
  220.     If proghWnd% <> 0 Then  ' Minimize it if it exists
  221.         CloseWindow proghWnd%
  222.     End If
  223.         
  224. End Sub
  225. Sub CmdModuleUsage_Click ()
  226.     Dim hinst%, usage%
  227.     Dim usewnd%
  228.     usewnd% = FindWindowByString(0, "Print Manager")
  229.     If (usewnd%) Then
  230.         hinst% = GetWindowWord%(usewnd, GWW_HINSTANCE)
  231.         ' usage% = GetModuleUsage%(hins%)  ' Parameter error!
  232.         ' usage% = GetModuleUsage%(usage%)  ' Parameter error!
  233.         usage% = GetModuleUsage%(hinst%)
  234.         MsgBox Str$(usage%), 0, "Module Usage"
  235.     Else
  236.         MsgBox "Window Not Found"
  237.     End If
  238. End Sub
  239. Sub CmdNumColors_Click ()
  240.     Dim numplanes%, numbitspixel%
  241.     Dim numcolors&
  242.     numplanes% = GetDeviceCaps%(hDC, PLANES)
  243.     numbitspixel% = GetDeviceCaps%(hDC, BITSPIXEL)
  244.     ' Left shift operation
  245.     numcolors& = 2 ^ (numplanes% * numbitspixel%)
  246.     MsgBox Str$(numcolors&), 0, "Total Colors"
  247. End Sub
  248. Sub CmdRectDraw_Click ()
  249.     Dim di%
  250.     di% = Rectangle(picture1.hDC, 5, 5, 50, 50)
  251. End Sub
  252. Sub CmdSetText_Click ()
  253.     Static tog%
  254.     If tog% Then
  255.         Caption = "Accessing the Windows API"
  256.         tog% = False
  257.     Else
  258.         SetWindowText hWnd, "This is a new caption"
  259.         ' The Windows API function also effects the Caption Property
  260.         MsgBox Caption, 0, "Caption property is now"
  261.         tog% = True
  262.     End If
  263. End Sub
  264. Sub CmdTextLines_Click ()
  265.     Dim lines%
  266.     lines% = SendMessageBynum(text1.hWnd, EM_GETLINECOUNT, 0, 0)
  267.     MsgBox Str$(lines%), 0, "Lines in Text1"
  268. End Sub
  269. Sub Command1_Click ()
  270.     Dim menucmd%, submenu%, itemid%
  271.     Dim di%
  272.     ' Get handle to popup menu
  273.     submenu% = GetSubMenu(GetMenu(hWnd), 0)
  274.     ' Get command ID of second entry
  275.     itemid% = GetMenuItemId%(submenu%, 1)
  276.     di% = ModifyMenu(submenu%, 1, MF_BYPOSITION Or MF_BITMAP, itemid%, CLng(MenuPicture.Picture))
  277. End Sub
  278. Sub mnu_entry_Click (Index As Integer)
  279.     MsgBox "Menu entry # " & Index & " pressed."
  280. End Sub
  281. Sub Picture1_DblClick ()
  282.     picture1.Cls
  283. End Sub
  284. Sub Timer1_Timer ()
  285.     Dim numlockstate%
  286.     Dim caplockstate%
  287.     Dim scrollstate%
  288.     Dim res$
  289.     ' Get the state of the keys
  290.     numlockstate% = GetKeyState%(VK_NUMLOCK)
  291.     caplockstate% = GetKeyState%(VK_CAPITAL)
  292.     scrollstate% = GetKeyState%(VK_SCROLL)
  293.     ' And build a display string
  294.     If numlockstate% And &H1 Then res$ = "NUM "
  295.     If caplockstate% And &H1 Then res$ = res$ + "CAP "
  296.     If scrollstate% And &H1 Then res$ = res$ + "SCROLL"
  297.     labelkeys.Caption = res$
  298. End Sub
  299.