Newsgroup: it.comp.lang.visual-basic
Titolo: ridimensionamento MDI di access

Buongiorno
In una database ho usato la funzione movewindow per dimensionare la
finestra iniziale, fin qui tutto ok, come faccio per non fare modificare
le misure che ho impostato?
Grazie
Marco
-- 
questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news
 segnala gli abusi ad 
ab...@newsland.it

 Marco
Innanzitutto potresti togliere i pulsanti di Minimize/Maximize/Restore
poi devi rimuovere i Menù per questo potresti usare il codice
sottoriportato.
Ora per evitare invece il dimesionamento(qualora la MDI non sia 
massimizzata) serve Subclassarla per intercettare i Messaggi
WM_SYSCOMMAND
  ed il parametro wParam:
   SC_SIZE  (questo in realtà non funzionerà devi usare
             altri valori che non ho sotto mano)
   SC_MOVE
imponendo l'Exit dalla procedura per non farla eseguire.
In questo modo otterrai che la MDI rimarrà Bloccata.
Il problema è che per farlo devi subclassare il tutto in un 
Modulo all'apertura, ma fai molta attenzione alla chiusura
del SubClassing all'uscita.
API obbligatorio metti tutta questa robaccia in un Modulo 
quindi chiama da dove vuoi : 
Call ShowCloseBtn(True) 
Call ShowCloseBtn(False) 
'------------------- MODULO ----------------------------- 
Option Compare Database 
Option Explicit 
Private Const SW_HIDE = 0 
Private Const SW_SHOWNORMAL = 1 
Private Const SW_NORMAL = 1 
Private Const SW_SHOWMINIMIZED = 2 
Private Const SW_SHOWMAXIMIZED = 3 
Private Const SW_MAXIMIZE = 3 
Private Const SW_SHOWNOACTIVATE = 4 
Private Const SW_SHOW = 5 
Private Const SW_MINIMIZE = 6 
Private Const SW_SHOWMINNOACTIVE = 7 
Private Const SW_SHOWNA = 8 
Private Const SW_RESTORE = 9 
Private Const SW_SHOWDEFAULT = 10 
Private Const SW_MAX = 10 
Private Const GWL_STYLE = -16 
Private Const WS_SYSMENU = &H80000 
Private Const WM_NCPAINT = &H85 
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 GetWindowLong Lib "user32" _ 
 Alias "GetWindowLongA" (ByVal hWnd As Long, _ 
 ByVal nIndex As Long) As Long 
Private Declare Function apiFindWindow Lib "user32" Alias _ 
    "FindWindowA" (ByVal strClass As String, _ 
    ByVal lpWindow As String) As Long 
Private Declare Function apiSendMessage Lib "user32" Alias _ 
    "SendMessageA" (ByVal hWnd As Long, ByVal Msg As Long, ByVal _ 
    wParam As Long, lParam As Long) As Long 
Private Declare Function apiSetForegroundWindow Lib "user32" Alias _ 
    "SetForegroundWindow" (ByVal hWnd As Long) As Long 
Private Declare Function apiShowWindow Lib "user32" Alias _ 
    "ShowWindow" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long 
Private Declare Function apiIsIconic Lib "user32" Alias _ 
    "IsIconic" (ByVal hWnd As Long) As Long 
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long,
_ 
         ByVal bRevert As Long) As Long 
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As 
Long, _ 
   ByVal nPos As Long) As Long 
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
   ByVal nPosition As Long, ByVal wFlags As Long) As Long 
Public Function ShowCloseBtn(ShowIt As Boolean) 
    Dim mhWnd        As Long 
    Dim lngOldStyle  As Long 
    Dim lngNewStyle  As Long 
    mhWnd = Application.hWndAccessApp 
    ' Get the current window style of the form. 
    lngOldStyle = GetWindowLong(mhWnd, GWL_STYLE) 
    If ShowIt Then 
        ' Turn on the bit that enables system menu. 
        lngNewStyle = lngOldStyle Or WS_SYSMENU 
    Else 
        ' Turn off the bit the shows the system menu. 
        lngNewStyle = lngOldStyle And Not WS_SYSMENU 
    End If 
    ' Questa Funzione suggerita da Maurizio Borrelli 
    ' Serve per rimuovere anche il Menù POPUP della CaptionBar 
    Call RemoveItem(mhWnd) 
    ' Set the new window style. 
    Call SetWindowLong(mhWnd, GWL_STYLE, lngNewStyle) 
    ' The 1 as the third parameter tells 
    ' the window to repaint its entire border. 
    Call apiSendMessage(mhWnd, WM_NCPAINT, 1, 0) 
ExitHere: 
    Exit Function 
HandleErrors: 
    Select Case err.Number 
        Case Else 
            MsgBox err.Number & " " & err.Description 
    End Select 
    Resume ExitHere 
End Function 
Sub RemoveItem(hWnd As Long) 
      Dim hMnu, y, i 
      Const MF_BYPOSITION As Long = 1024 
      Const MF_GRAYED As Long = 1 
      Const MF_DISABLED As Long = 2 
      hMnu = GetSystemMenu(hWnd, 0) 
      For i = 6 To 0 Step -1 
         y = RemoveMenu(hMnu, i, MF_BYPOSITION) 
      Next i 
End Sub 
@Alex
-- 
Posted via Mailgate.ORG Server - 
http://www.Mailgate.ORG