25. august 2004 - 14:40Der er
4 kommentarer og 1 løsning
Forhindre bruger i lukning af program
Hej,
Jeg sidder og sysler med et projekt, hvor excel bruges til at generere nogle rapporter. Jeg vil gerne på en enkel måde kunne forhindre brugeren i at lukke excel ned.
Er det muligt at fjerne "det lille kryds" oppe i systembar, så brugeren ikke umiddelbart kan lukke programmet,
eller er der andre gode ideer ?
Jeg vil gerne lave en løsning der kan laves fra excels VBA..
Ok, det giver nogle muligheder... men det jeg gerne vil, er at forhindre brugeren i at kunne lukke excel ( f.eks ved et uheld)... (mit problem er at det tager meget lang tid at starte applikationen op igen)...
Synes godt om
Slettet bruger
26. august 2004 - 21:36#3
Hvis Excel kører usynligt fra starten, vil brugeren ikke kunne lukke den ned medmindre de dræber Excel processen fra Task Manageren. Du skal bare huske at lukke Excel ned fra koden f.eks.
For god ordens skyld, her er den løsning jeg har fundet...
Private Const MF_BYPOSITION As Long = &H400 ''' Deletes the menus byposition (this is our default)
Private Const MF_BYCOMMAND As Long = &H0 ''' Deletes the menu by Command ID. This is rarely used and is shown here for information purposes only.
Private Const mlNUM_SYS_MENU_ITEMS As Long = 9 ''' This is the number of items on the system menu
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
' Comments: Deletes the system control menu of the specified window. ' ' Arguments: DialogCaption The caption of the window whose control ' menu you want to delete. If not specified, ' Application.Caption is assumed. ' Public Sub DisableActiveDialogMenuControls(DialogCaption As String) Dim lHandle As Long, lCount As Long On Error Resume Next DialogCaption = DialogCaption & vbNullChar lHandle = FindWindowA(vbNullString, DialogCaption)
' Only continue if the passed window handle isn't zero.
If lHandle <> 0 Then
' There are 9 items on the application control menu. ' Loop through and disable each one.
For lCount = 1 To mlNUM_SYS_MENU_ITEMS
' The nPosition of the DeleteMenu function will always be 0, ' because as we delete each menu item, the next one moves up ' into the first position (index of 0).
DeleteMenu GetSystemMenu(lHandle, False), 0, MF_BYPOSITION Next lCount
End If
End Sub
' Comments: Restores the system control menu of the specified window. ' ' Arguments: szCaption (Optional) The caption of the window whose control ' menu you want to delete. If not specified, ' Application.Caption is assumed. '
Public Sub EnableActiveDialogMenuControls(DialogCaption As String)
Dim lHandle As Long On Error Resume Next DialogCaption = DialogCaption & vbNullChar lHandle = FindWindowA(vbNullString, DialogCaption)
' Passing True to the bRevert argument of the GetSystemMenu API restores ' the control menu of the specified window.
GetSystemMenu lHandle, True
End Sub
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.