Attribute VB_Name = "WinFunctions" Option Explicit Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long 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 Private Declare Function GetTopWindow Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long Private Declare Function SendMessageByNum& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessId As Long, ByVal dwType As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Const WM_LBUTTONDBLCLICK = &H203 Private Const WM_MOUSEMOVE = &H200 Private Const WM_RBUTTONUP = &H205 Private Const WM_LBUTTONDOWN = &H201 Private Const WM_LBUTTONUP = &H202 Private Const WM_LBUTTONDBLCLK = &H203 Private Const WM_RBUTTONDOWN = &H204 Private Const WM_RBUTTONDBLCLK = &H206 Private Const WM_CHAR = &H102 Private Const WM_CLOSE = &H10 Private Const WM_USER = &H400 Private Const WM_COMMAND = &H111 Private Const WM_GETTEXT = &HD Private Const WM_GETTEXTLENGTH = &HE Private Const WM_KEYDOWN = &H100 Private Const WM_KEYUP = &H101 Private Const WM_MOVE = &HF012 Private Const WM_SETTEXT = &HC Private Const WM_CLEAR = &H303 Private Const WM_DESTROY = &H2 Private Const WM_SYSCOMMAND = &H112 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 Private Const SW_MINIMIZE = 6 Private Const SW_HIDE = 0 Private Const SW_MAXIMIZE = 3 Private Const SW_SHOW = 5 Private Const SW_RESTORE = 9 Private Const SW_SHOWDEFAULT = 10 Private Const SW_SHOWMAXIMIZED = 3 Private Const SW_SHOWMINIMIZED = 2 Private Const SW_SHOWMINNOACTIVE = 7 Private Const SW_SHOWNOACTIVATE = 4 Private Const SW_SHOWNORMAL = 1 Private Const HWND_TOP = 0 Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Const EWX_LOGOFF = 0 Private Const EWX_SHUTDOWN = 1 Private Const EWX_REBOOT = 2 Private Const EWX_FORCE = 4 Private Const RSP_SIMPLE_SERVICE = 1 Private Const RSP_UNREGISTER_SERVICE = 0 Private Const SPI_SCREENSAVERRUNNING = 97 Private Const STANDARD_RIGHTS_REQUIRED = &HF0000 Private Const Flags = SWP_NOSIZE Or SWP_NOMOVE Private Const GWL_STYLE = (-16) Private Const WS_SYSMENU = &H80000 Public Function CenterForm(TENProg As Form) TENProg.Top = (Screen.Height * 0.95) / 2 - TENProg.Height / 2 TENProg.Left = Screen.Width / 2 - TENProg.Width / 2 End Function Public Function StayOnTop(TheForm As Form) Dim SetWinOnTop As Long SetWinOnTop = SetWindowPos(TheForm.hWnd, HWND_TOPMOST, 0, 0, 0, 0, Flags) End Function Public Function NotOnTop(frm As Form) Dim SetWinOnTop As Long SetWinOnTop = SetWindowPos(frm.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, Flags) End Function Public Function TimeOUT(HesitateTime) Dim Hesitator As Long Hesitator& = Timer Do While Timer - Hesitator& < Val(HesitateTime) DoEvents Loop End Function Public Function HideTaskBar() Dim Handle As Long Handle& = FindWindow("Shell_TrayWnd", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowTaskBar() Dim Handle As Long Handle& = FindWindow("Shell_TrayWnd", vbNullString) ShowWindow Handle&, 1 End Function Public Function DestroyTaskBar() Dim Handle As Long Handle& = FindWindow("Shell_TrayWnd", vbNullString) SendMessage Handle&, WM_DESTROY, 0, 0 End Function Public Function HideStartButton() Dim Handle As Long, FindClass As Long FindClass& = FindWindow("Shell_TrayWnd", "") Handle& = FindWindowEx(FindClass&, 0, "Button", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowStartButton() Dim Handle As Long, FindClass As Long FindClass& = FindWindow("Shell_TrayWnd", "") Handle& = FindWindowEx(FindClass&, 0, "Button", vbNullString) ShowWindow Handle&, 1 End Function Public Function DestroyStartButton() Dim Handle As Long, FindClass As Long FindClass& = FindWindow("Shell_TrayWnd", "") Handle& = FindWindowEx(FindClass&, 0, "Button", vbNullString) SendMessage Handle&, WM_DESTROY, 0, 0 End Function Public Function HideTaskBarClock() Dim FindClass As Long, FindParent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", vbNullString) FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString) Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowTaskBarClock() Dim FindClass As Long, FindParent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", vbNullString) FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString) Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString) ShowWindow Handle&, 1 End Function Public Function DestroyTaskBarClock() Dim FindClass As Long, FindParent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", vbNullString) FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString) Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString) SendMessage Handle&, WM_DESTROY, 0, 0 End Function Public Function HideTaskBarIcons() Dim FindClass As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") Handle& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowTaskBarIcons() Dim FindClass As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") Handle& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString) ShowWindow Handle&, 1 End Function Public Function DestroyTaskBarIcons() Dim FindClass As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") Handle& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString) SendMessage Handle&, WM_DESTROY, 0, 0 End Function Public Function HideProgramsShowingInTaskBar() Dim FindClass As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") FindClass2& = FindWindowEx(FindClass&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "MSTaskSwWClass", vbNullString) Handle& = FindWindowEx(Parent&, 0, "SysTabControl32", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowProgramsShowingInTaskBar() Dim FindClass As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") FindClass2& = FindWindowEx(FindClass&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "MSTaskSwWClass", vbNullString) Handle& = FindWindowEx(Parent&, 0, "SysTabControl32", vbNullString) ShowWindow Handle&, 1 End Function Public Function DestroyProgramsShowingInTaskBar() Dim FindClass As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") FindClass2& = FindWindowEx(FindClass&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "MSTaskSwWClass", vbNullString) Handle& = FindWindowEx(Parent&, 0, "SysTabControl32", vbNullString) SendMessage Handle&, WM_DESTROY, 0, 0 End Function Function HideWindowsToolBar() Dim FindClass1 As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass1& = FindWindow("BaseBar", vbNullString) FindClass2& = FindWindowEx(FindClass1&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "SysPager", vbNullString) Handle& = FindWindowEx(Parent&, 0, "ToolbarWindow32", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowWindowsToolBar() Dim FindClass1 As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass1& = FindWindow("BaseBar", vbNullString) FindClass2& = FindWindowEx(FindClass1&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "SysPager", vbNullString) Handle& = FindWindowEx(Parent&, 0, "ToolbarWindow32", vbNullString) ShowWindow Handle&, 1 End Function Public Function DestroyWindowsToolBar() Dim FindClass1 As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass1& = FindWindow("BaseBar", vbNullString) FindClass2& = FindWindowEx(FindClass1&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "SysPager", vbNullString) Handle& = FindWindowEx(Parent&, 0, "ToolbarWindow32", vbNullString) SendMessage Handle&, WM_DESTROY, 0, 0 End Function Public Function PreventFromClosing() Dim process As Long process = GetCurrentProcessId() RegisterServiceProcess process, RSP_SIMPLE_SERVICE End Function Public Function UnPreventFromClosing() Dim process As Long process = GetCurrentProcessId() RegisterServiceProcess process, RSP_UNREGISTER_SERVICE End Function Public Function DisableCtrlAltDel() Dim ret As Integer Dim pOld As Boolean ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0) End Function Public Function EnableCtrlAltDel() Dim ret As Integer Dim pOld As Boolean ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0) End Function Public Function WINLogUserOff() ExitWindowsEx EWX_LOGOFF, 0 End Function Public Function WINForceClose() ExitWindowsEx EWX_FORCE, 0 End Function Public Function WINShutdown() ExitWindowsEx EWX_SHUTDOWN, 0 ExitWindowsEx EWX_SHUTDOWN, 0 ExitWindowsEx EWX_SHUTDOWN, 0 End Function Public Function WINReboot() ExitWindowsEx EWX_REBOOT, 0 ExitWindowsEx EWX_REBOOT, 0 ExitWindowsEx EWX_REBOOT, 0 End Function Public Function ShowIconOnTaskbar(Form As Form) Dim lStyle As Long lStyle = GetWindowLong(Form.hWnd, GWL_STYLE) Or WS_SYSMENU SetWindowLong Form.hWnd, GWL_STYLE, lStyle End Function Public Function MoveWindowWithOutBar(FormToMove As Image) ReleaseCapture SendMessage FormToMove.Container.hWnd, &HA1, 2, 0& End Function Public Function Replace(TestString As String, ChrToRelpace As String, ReplaceWith As String) As String 'Replace(into.Text, "", "") Dim i As Integer On Error Resume Next For i = 1 To Len(TestString) If Mid(TestString, i, Len(ChrToRelpace)) = ChrToRelpace Then Replace = Replace & ReplaceWith i = i + Len(ChrToRelpace) - 1 Else Replace = Replace & Mid(TestString, i, 1) End If Next End Function Public Function Degrees(Number As Double) As Double Dim Pie As Double Dim Radians As Double Pie = 3.14159265358979 Radians = (2 * Pie) / 360 Degrees = Number * Radians End Function Function FadeSide2SideForm(Form As Form, Color1 As Long, Color2 As Long) Dim X!, x2!, Y%, i%, red1%, green1%, blue1%, red2%, green2%, blue2%, pat1!, pat2!, pat3!, c1!, c2!, c3! ' find the length of the form and cut it into 80 pieces x2 = Form.ScaleWidth / 80 Y% = Form.ScaleHeight ' separating red, green, and blue in each of the two colors red1% = Color1 And 255 green1% = Color1 \ 256 And 255 blue1% = Color1 \ 65536 And 255 red2% = Color2 And 255 green2% = Color2 \ 256 And 255 blue2% = Color2 \ 65536 And 255 ' cut the difference between the two colors into 100 pieces pat1 = (red2% - red1%) / 80 pat2 = (green2% - green1%) / 80 pat3 = (blue2% - blue1%) / 80 ' set the c variables at the starting colors c1 = red1% c2 = green1% c3 = blue1% ' draw 80 different lines on the form For i% = 1 To 80 Form.Line (X, 0)-(X + x2, Y%), RGB(c1, c2, c3), BF X = X + x2 ' draw the Next line one step up from the old step c1 = c1 + pat1 ' make the c variable equal 2 it's Next step c2 = c2 + pat2 c3 = c3 + pat3 Next Form.CurrentX = 0 Form.CurrentY = 0 End Function Function FadeTop2BottomForm(Form As Form, Color1 As Long, Color2 As Long) Dim X!, x2!, Y%, i%, red1%, green1%, blue1%, red2%, green2%, blue2%, pat1!, pat2!, pat3!, c1!, c2!, c3! ' find the height of the form and cut it into 80 pieces x2 = Form.ScaleHeight / 80 Y% = Form.ScaleWidth ' separating red, green, and blue in each of the two colors red1% = Color1 And 255 green1% = Color1 \ 256 And 255 blue1% = Color1 \ 65536 And 255 red2% = Color2 And 255 green2% = Color2 \ 256 And 255 blue2% = Color2 \ 65536 And 255 ' cut the difference between the two colors into 100 pieces pat1 = (red2% - red1%) / 80 pat2 = (green2% - green1%) / 80 pat3 = (blue2% - blue1%) / 80 ' set the c variables at the starting colors c1 = red1% c2 = green1% c3 = blue1% ' draw 80 different lines on the form For i% = 1 To 80 Form.Line (0, X)-(Y%, X + x2), RGB(c1, c2, c3), BF X = X + x2 ' draw the Next line one step up from the old step c1 = c1 + pat1 ' make the c variable equal to it's Next step c2 = c2 + pat2 c3 = c3 + pat3 Next Form.CurrentX = 0 Form.CurrentY = 0 End Function Function FadeSide2SidePictureBox(Form As PictureBox, Color1 As Long, Color2 As Long) Dim X!, x2!, Y%, i%, red1%, green1%, blue1%, red2%, green2%, blue2%, pat1!, pat2!, pat3!, c1!, c2!, c3! ' find the length of the form and cut it into 80 pieces x2 = Form.ScaleWidth / 80 Y% = Form.ScaleHeight ' separating red, green, and blue in each of the two colors red1% = Color1 And 255 green1% = Color1 \ 256 And 255 blue1% = Color1 \ 65536 And 255 red2% = Color2 And 255 green2% = Color2 \ 256 And 255 blue2% = Color2 \ 65536 And 255 ' cut the difference between the two colors into 100 pieces pat1 = (red2% - red1%) / 80 pat2 = (green2% - green1%) / 80 pat3 = (blue2% - blue1%) / 80 ' set the c variables at the starting colors c1 = red1% c2 = green1% c3 = blue1% ' draw 80 different lines on the form For i% = 1 To 80 Form.Line (X, 0)-(X + x2, Y%), RGB(c1, c2, c3), BF X = X + x2 ' draw the Next line one step up from the old step c1 = c1 + pat1 ' make the c variable equal 2 it's Next step c2 = c2 + pat2 c3 = c3 + pat3 Next Form.CurrentX = 0 Form.CurrentY = 0 End Function Function FadeTop2BottomPictureBox(Form As PictureBox, Color1 As Long, Color2 As Long) Dim X!, x2!, Y%, i%, red1%, green1%, blue1%, red2%, green2%, blue2%, pat1!, pat2!, pat3!, c1!, c2!, c3! ' find the height of the form and cut it into 80 pieces x2 = Form.ScaleHeight / 80 Y% = Form.ScaleWidth ' separating red, green, and blue in each of the two colors red1% = Color1 And 255 green1% = Color1 \ 256 And 255 blue1% = Color1 \ 65536 And 255 red2% = Color2 And 255 green2% = Color2 \ 256 And 255 blue2% = Color2 \ 65536 And 255 ' cut the difference between the two colors into 100 pieces pat1 = (red2% - red1%) / 80 pat2 = (green2% - green1%) / 80 pat3 = (blue2% - blue1%) / 80 ' set the c variables at the starting colors c1 = red1% c2 = green1% c3 = blue1% ' draw 80 different lines on the form For i% = 1 To 80 Form.Line (0, X)-(Y%, X + x2), RGB(c1, c2, c3), BF X = X + x2 ' draw the Next line one step up from the old step c1 = c1 + pat1 ' make the c variable equal to it's Next step c2 = c2 + pat2 c3 = c3 + pat3 Next Form.CurrentX = 0 Form.CurrentY = 0 End Function