Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/11/2006, 17:20
Avatar de dogduck
dogduck
 
Fecha de Ingreso: enero-2006
Ubicación: ¿Atlantida, Hesperides, Islas afortunadas?
Mensajes: 2.231
Antigüedad: 19 años, 1 mes
Puntos: 19
Para formatear disquete en VB:

http://www.telecable.es/personales/j....htm?vbesp.htm
Código:
Call FmFormat(form1)


Type Rect
    Left As Integer
    Top As Integer
    Right As Integer
    Bottom As Integer
End Type


Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As Rect)
Declare Function IsWindow Lib "User" (ByVal hWnd As Integer) As Integer
Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String, ByVal nCmdShow As Integer) As Integer
Declare Function SetActiveWindow Lib "User" (ByVal hWnd As Integer) As Integer
Declare Function GetActiveWindow Lib "User" () As Integer
Declare Function LockWindowUpdate Lib "User" (ByVal hwndLock As Integer) As Integer
Declare Function GetDesktopWindow Lib "User" () As Integer
Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Integer
Const WM_COMMAND = &H111
Const WM_CLOSE = &H10
Dim wFlag%
Dim lpDlgRect As Rect
Dim lpDskRect As Rect
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4

Sub CenterDialog (WinText As String)
   Do
    If FindWindow(0&, WinText) Then Exit Do
    x% = DoEvents()
   Loop

 wnd% = GetActiveWindow()
 Call GetWindowRect(wnd%, lpDlgRect)
 wdth% = lpDlgRect.Right - lpDlgRect.Left
 hght% = lpDlgRect.Bottom - lpDlgRect.Top
 Call GetWindowRect(GetDesktopWindow(), lpDskRect)
 Scrwdth% = lpDskRect.Right - lpDskRect.Left
 Scrhght% = lpDskRect.Bottom - lpDskRect.Top
 x% = (Scrwdth% - wdth%) / 2
 Y% = (Scrhght% - hght%) / 2
 Call SetWindowPos(wnd%, 0, x%, Y%, 0, 0, SWP_NOZORDER Or SWP_NOSIZE)
End Sub

Sub FMFormat (F As Form)

    FMhWnd = FindWindow("WFS_Frame", 0&)

    If FMhWnd = 0 Then
    i% = WinExec("Winfile", 0)
    FMhWnd = FindWindow("WFS_Frame", 0&)
       If FMhWnd = 0 Then
           MsgBox "FileMan ain't home"
           Exit Sub
       End If
    wFlag = 1
    End If

    i% = LockWindowUpdate(GetDesktopWindow())

    i% = PostMessage(FMhWnd, WM_COMMAND, &HCB, 0)

    Call CenterDialog("Format Disk")

    i% = LockWindowUpdate(0)

    wnd% = GetActiveWindow()

    While IsWindow(wnd%)
    x = DoEvents()
    Wend

    x = DoEvents()

    If wFlag Then
    wFlag = 0
    i% = PostMessage(FMhWnd, WM_CLOSE, 0, 0)
    End If

    i% = SetActiveWindow(F.hWnd)

End Sub