home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD14474232001.psc / VBSnipletKeeper / Module1.bas < prev    next >
Encoding:
BASIC Source File  |  2001-01-31  |  8.1 KB  |  246 lines

  1. Attribute VB_Name = "Module1"
  2. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  3. Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
  4. Private Declare Function CHOOSECOLOR Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long
  5. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  6. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  7. Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  8.  
  9.  
  10.  
  11. Private Const GWL_EXSTYLE = (-20)
  12. Private Const WS_EX_WINDOWEDGE = &H100
  13. Private Const WS_EX_CLIENTEDGE = &H200
  14. Private Const WS_EX_STATICEDGE = &H20000
  15. Private Const SWP_SHOWWINDOW = &H40
  16. Private Const SWP_HIDEWINDOW = &H80
  17. Private Const SWP_FRAMECHANGED = &H20
  18. Private Const SWP_NOACTIVATE = &H10
  19. Private Const SWP_NOCOPYBITS = &H100
  20. Private Const SWP_NOMOVE = &H2
  21. Private Const SWP_NOOWNERZORDER = &H200
  22.  
  23. Private Const SWP_NOREDRAW = &H8
  24. Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
  25. Private Const SWP_NOSIZE = &H1
  26. Private Const SWP_NOZORDER = &H4
  27. Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
  28. Private Const SWP_FLAGS = SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
  29. Private Const HWND_NOTOPMOST = -2
  30.  
  31.  
  32.  
  33.  
  34. Public TimeOpen As Single
  35. Public CodeDBPath As String
  36. Public Db As Database
  37. Public RecSet As Recordset
  38. Public Extra As String
  39. Public Config As Conf
  40.  
  41.  
  42. Enum WinShow
  43.     vsHide = 0
  44.     vsNormal = 1
  45.     vsMinSized = 2
  46.     vsMaxSized = 3
  47. End Enum
  48.  
  49. Private Type OPENFILENAME
  50.     lStructSize As Long
  51.     hwndOwner As Long
  52.     hInstance As Long
  53.     lpstrFilter As String
  54.     lpstrCustomFilter As String
  55.     nMaxCustFilter As Long
  56.     nFilterIndex As Long
  57.     lpstrFile As String
  58.     nMaxFile As Long
  59.     lpstrFileTitle As String
  60.     nMaxFileTitle As Long
  61.     lpstrInitialDir As String
  62.     lpstrTitle As String
  63.     flags As Long
  64.     nFileOffset As Integer
  65.     nFileExtension As Integer
  66.     lpstrDefExt As String
  67.     lCustData As Long
  68.     lpfnHook As Long
  69.     lpTemplateName As String
  70. End Type
  71.  
  72. Type Conf
  73.     Font_Name As String
  74.     Font_Size As String
  75.     Fore_Colour As String
  76.     Back_Colour As String
  77. End Type
  78.  
  79. Private Type CHOOSECOLOR
  80.     lStructSize As Long
  81.     hwndOwner As Long
  82.     hInstance As Long
  83.     rgbResult As Long
  84.     lpCustColors As String
  85.     flags As Long
  86.     lCustData As Long
  87.     lpfnHook As Long
  88.     lpTemplateName As String
  89. End Type
  90. Public Sub FlatBorder(ByVal hWnd As Long)
  91. Dim TFlat As Long
  92.     TFlat = GetWindowLong(hWnd, GWL_EXSTYLE)
  93.     TFlat = TFlat And Not WS_EX_CLIENTEDGE Or WS_EX_STATICEDGE
  94.     SetWindowLong hWnd, GWL_EXSTYLE, TFlat
  95.     SetWindowPos hWnd, 0, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOZORDER Or SWP_FRAMECHANGED Or SWP_NOSIZE Or SWP_NOMOVE
  96.   
  97. End Sub
  98. Function WriteINIChanges()
  99.     SaveSetting "VbCode32", "Config", "FontName", Config.Font_Name
  100.     SaveSetting "VbCode32", "Config", "FontSize", Config.Font_Size
  101.     SaveSetting "VbCode32", "Config", "ForeColour", Config.Fore_Colour
  102.     SaveSetting "VbCode32", "Config", "BackColour", Config.Back_Colour
  103.     
  104. End Function
  105. Function ReadWriteINI()
  106.     Config.Font_Name = GetSetting("VbCode32", "Config", "FontName")
  107.     Config.Font_Size = GetSetting("VbCode32", "Config", "FontSize")
  108.     Config.Fore_Colour = GetSetting("VbCode32", "Config", "ForeColour")
  109.     Config.Back_Colour = GetSetting("VbCode32", "Config", "BackColour")
  110.     
  111.     If Config.Font_Name = "" Then
  112.         SaveSetting "VbCode32", "Config", "FontName", "Courier New"
  113.     End If
  114.  
  115.     If Config.Font_Size = "" Then
  116.         SaveSetting "VbCode32", "Config", "FontSize", "10"
  117.     End If
  118.  
  119.     If Config.Fore_Colour = "" Then
  120.         SaveSetting "VbCode32", "Config", "ForeColour", "0"
  121.     End If
  122.  
  123.     If Config.Back_Colour = "" Then
  124.         SaveSetting "VbCode32", "Config", "BackColour", "16777215"
  125.     End If
  126.     
  127. End Function
  128. Public Function ShowColor(Handle As Long) As Long
  129. Dim TCol As CHOOSECOLOR
  130. Dim Custcolor(41) As Long
  131. Dim lReturn As Long
  132.     
  133.     TCol.lStructSize = Len(TCol)
  134.     TCol.hwndOwner = Handle
  135.     TCol.hInstance = App.hInstance
  136.     TCol.lpCustColors = StrConv(CustomColors, vbUnicode)
  137.     TCol.flags = 0
  138.     
  139.     If CHOOSECOLOR(TCol) <> 0 Then
  140.         ShowColor = TCol.rgbResult
  141.         CustomColors = StrConv(TCol.lpCustColors, vbFromUnicode)
  142.     Else
  143.         ShowColor = -1
  144.     End If
  145.  
  146. End Function
  147. Private Function RemoveNulls(lzString As String) As String
  148. Dim Xpos As Integer
  149.     Xpos = InStr(lzString, vbNullChar)
  150.     If Xpos > 0 Then
  151.         lzString = Left(lzString, Len(lzString) - 1)
  152.         RemoveNulls = lzString
  153.     End If
  154.     
  155. End Function
  156. Public Function OpenFile(Pattern As String) As String
  157.  Dim ofn As OPENFILENAME
  158.     ofn.lStructSize = Len(ofn)
  159.     ofn.hwndOwner = Form1.hWnd
  160.     ofn.hInstance = App.hInstance
  161.     ofn.lpstrFilter = Pattern
  162.         ofn.lpstrFile = Space$(254)
  163.         ofn.nMaxFile = 255
  164.         ofn.lpstrFileTitle = Space$(254)
  165.         ofn.nMaxFileTitle = 255
  166.         ofn.lpstrInitialDir = App.Path & "\"
  167.         ofn.lpstrTitle = "Open Text File"
  168.         ofn.flags = 0
  169.         
  170.         a = GetOpenFileName(ofn)
  171.         If (a) Then
  172.                 OpenFile = RemoveNulls(Trim(ofn.lpstrFile))
  173.         End If
  174.         
  175.  End Function
  176. Public Function OpenMid() As String
  177.  Dim ofn As OPENFILENAME
  178.     ofn.lStructSize = Len(ofn)
  179.     ofn.hwndOwner = Form1.hWnd
  180.     ofn.hInstance = App.hInstance
  181.     ofn.lpstrFilter = "All Files(*.mid Multmedia Files)" + Chr$(0) + "*.mid"
  182.         ofn.lpstrFile = Space$(254)
  183.         ofn.nMaxFile = 255
  184.         ofn.lpstrFileTitle = Space$(254)
  185.         ofn.nMaxFileTitle = 255
  186.         ofn.lpstrInitialDir = App.Path & "\"
  187.         ofn.lpstrTitle = "Mid Files"
  188.         ofn.flags = 0
  189.         
  190.         a = GetOpenFileName(ofn)
  191.         If (a) Then
  192.                 OpenMid = RemoveNulls(Trim(ofn.lpstrFile))
  193.         End If
  194.         
  195.  End Function
  196. Public Function RunProgram(mHwnd As Long, ProgramNamePath As String, ShowWindow As WinShow)
  197.     ShellExecute mHwnd, vbNullString, ProgramNamePath, vbNullString, vbNullString, ShowWindow
  198.     
  199. End Function
  200. Function CenterForm(Frm As Form)
  201.     With Frm
  202.         .Top = (Screen.Height - Frm.Height) / 2
  203.         .Left = (Screen.Width - Frm.Width) / 2
  204.     End With
  205.     
  206. End Function
  207. Public Function FolderExists(ByVal Foldername As String) As Integer
  208.     If Dir(Foldername, vbDirectory) = "" Then FolderExists = 0 Else FolderExists = 1
  209.     
  210. End Function
  211. Public Function FileExists(ByVal Filename As String) As Integer
  212.     If Dir(Filename) = "" Then FileExists = 0 Else FileExists = 1
  213.     
  214. End Function
  215. Function SerachSites(SiteOp As Integer, SerachFor As String, WebWin As WebBrowser)
  216. Dim Site1, Site2, Site3, Site4 As String
  217.     
  218.     Site1 = "http://www.codearchive.com/search/search.cgi?startat=0&search=" & SerachFor & "§ion=VB"
  219.     Site2 = "http://search.atomz.com/search/?sp-a=000700ff-sp00000000&sp-q=" & SerachFor
  220.     Site3 = "http://www.vbcode.com/asp/code.asp?SortBy=&lstCategory=&KeywordSearch=" & SerachFor & "&SearchType=ExactPhrase&intpage=1"
  221.     Site4 = "http://www.vb-world.net/cgi-bin/searchredir.cgi?search=" & SerachFor & "&whereto=VBWORLD"
  222.     
  223.     Select Case SiteOp
  224.         Case 1
  225.             WebWin.Navigate Site1
  226.         Case 2
  227.             WebWin.Navigate Site2
  228.         Case 3
  229.             WebWin.Navigate Site3
  230.         Case 4
  231.             WebWin.Navigate Site4
  232.         End Select
  233.         
  234. End Function
  235. Function AddBackSlash(Pathname As String) As String
  236. Dim TBackSlash As String
  237.  
  238.     If Not Right(Pathname, 1) = "\" Then
  239.         TBackSlash = Pathname & "\"
  240.     Else
  241.         TBackSlash = Pathname
  242.     End If
  243.     AddBackSlash = TBackSlash
  244.     
  245. End Function
  246.