home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / msg_spy / droppad.frm next >
Text File  |  1994-05-22  |  5KB  |  143 lines

  1. VERSION 2.00
  2. Begin Form frmDragDrop 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Drop Pad"
  6.    ClientHeight    =   2676
  7.    ClientLeft      =   168
  8.    ClientTop       =   1560
  9.    ClientWidth     =   5592
  10.    Height          =   3120
  11.    Icon            =   DROPPAD.FRX:0000
  12.    Left            =   108
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   2676
  16.    ScaleWidth      =   5592
  17.    Top             =   1176
  18.    Width           =   5712
  19.    Begin MsgSpy MsgSpy1 
  20.       Left            =   4560
  21.       MessageNumber   =   563
  22.       SpyMode         =   1  'Single Message
  23.       Top             =   2100
  24.    End
  25.    Begin Label Label1 
  26.       Alignment       =   2  'Center
  27.       BackStyle       =   0  'Transparent
  28.       Caption         =   "with the file ready to view or edit."
  29.       FontBold        =   0   'False
  30.       FontItalic      =   0   'False
  31.       FontName        =   "MS Sans Serif"
  32.       FontSize        =   7.8
  33.       FontStrikethru  =   0   'False
  34.       FontUnderline   =   0   'False
  35.       Height          =   312
  36.       Index           =   3
  37.       Left            =   180
  38.       TabIndex        =   3
  39.       Top             =   2160
  40.       Width           =   5232
  41.    End
  42.    Begin Image Image1 
  43.       Height          =   516
  44.       Left            =   180
  45.       Picture         =   DROPPAD.FRX:0442
  46.       Top             =   120
  47.       Width           =   4236
  48.    End
  49.    Begin Label Label1 
  50.       Alignment       =   2  'Center
  51.       BackStyle       =   0  'Transparent
  52.       Caption         =   "(or its icon if minimized). Notepad will then be loaded"
  53.       FontBold        =   0   'False
  54.       FontItalic      =   0   'False
  55.       FontName        =   "MS Sans Serif"
  56.       FontSize        =   7.8
  57.       FontStrikethru  =   0   'False
  58.       FontUnderline   =   0   'False
  59.       Height          =   312
  60.       Index           =   2
  61.       Left            =   180
  62.       TabIndex        =   2
  63.       Top             =   1740
  64.       Width           =   5232
  65.    End
  66.    Begin Label Label1 
  67.       Alignment       =   2  'Center
  68.       BackStyle       =   0  'Transparent
  69.       Caption         =   "Use File Manager to drop text files onto this window"
  70.       FontBold        =   0   'False
  71.       FontItalic      =   0   'False
  72.       FontName        =   "MS Sans Serif"
  73.       FontSize        =   7.8
  74.       FontStrikethru  =   0   'False
  75.       FontUnderline   =   0   'False
  76.       Height          =   312
  77.       Index           =   1
  78.       Left            =   180
  79.       TabIndex        =   1
  80.       Top             =   1320
  81.       Width           =   5232
  82.    End
  83.    Begin Label Label1 
  84.       Alignment       =   2  'Center
  85.       BackStyle       =   0  'Transparent
  86.       Caption         =   "Message Spy Custom Control Demo Application"
  87.       FontBold        =   -1  'True
  88.       FontItalic      =   0   'False
  89.       FontName        =   "MS Sans Serif"
  90.       FontSize        =   7.8
  91.       FontStrikethru  =   0   'False
  92.       FontUnderline   =   -1  'True
  93.       Height          =   312
  94.       Index           =   0
  95.       Left            =   180
  96.       TabIndex        =   0
  97.       Top             =   840
  98.       Width           =   5232
  99.    End
  100. End
  101. '-------------------------------------------------
  102. '
  103. ' DropPad - a Message Spy Custom Control demo
  104. '
  105. ' Copyright (c) 1992-1994 Anton Software Limited.
  106. '
  107. '-------------------------------------------------
  108.  
  109. Option Explicit
  110.  
  111. Declare Sub DragAcceptFiles Lib "shell" (ByVal hWnd As Integer, ByVal fAccept As Integer)
  112. Declare Function DragQueryFile Lib "shell" (ByVal hDrop As Integer, ByVal iFile As Integer, ByVal lpszFile As String, ByVal cb As Integer) As Integer
  113. Declare Sub DragFinish Lib "shell" (ByVal hDrop As Integer)
  114.  
  115. Sub Form_Load ()
  116.     
  117.     ' Centre the logo.
  118.     Image1.Left = (frmDragDrop.Width - Image1.Width) / 2
  119.  
  120.     ' Subclass the main form.
  121.     MsgSpy1 = frmDragDrop.hWnd
  122.  
  123.     ' Tell Windows it can accept dropped files
  124.     ' from File Manager.
  125.     DragAcceptFiles frmDragDrop.hWnd, 1
  126.  
  127. End Sub
  128.  
  129. Sub MsgSpy1_MsgReceived (hWnd As Integer, Msg As Integer, WParam As Integer, LParam As Long)
  130.  
  131.     ' Get the file name.
  132.     Const BUFFER_SIZE = 126
  133.     Dim Filename As String * BUFFER_SIZE
  134.     Dim Result As Integer
  135.     Result = DragQueryFile(WParam, 0, Filename, BUFFER_SIZE)
  136.     DragFinish WParam
  137.     
  138.     ' And invoke Notepad to edit/view it.
  139.     Result = Shell("notepad.exe " & Filename, 1)
  140.  
  141. End Sub
  142.  
  143.