在sendmessage后面加一句        Form1.Move 0, 0, Screen.Width, Screen.Height
虽然可以用但是弹出了一个对话框最大化是不能调整或移动,正在试新方法

解决方案 »

  1.   

    If Msg = WM_NCLBUTTONDBLCLK Then '''如果鼠标双击标题栏
            SendMessage Form1.hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0&
             'Form1.WindowState = 2    '''用此方法设置效果一样
       else
        WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
       End If
      

  2.   

    回  jennyvenus() : 你这个 ELSE 加的是重复的,你发现没有?
      

  3.   

    i think this is good1)
    Public Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Select Case Msg
            Case WM_NCLBUTTONDBLCLK
                WndProc = CallWindowProc(prevWndProc, hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0&)
            Case Else
                WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
        End Select
    End Function2)
    Private Sub Form_Unload(Cancel As Integer)
        SetWindowLong Me.hwnd, GWL_WNDPROC, prevWndProc
    End Sub
      

  4.   

    这是仿照sdk编程vb写的窗口过程
    Public Function WindowProc(ByVal handle_of_window As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim ps As PAINTSTRUCT
        Dim rc As RECT
        Dim hdc As Long
        Dim str As String
        Select Case message
            Case WM_PAINT
                hdc = BeginPaint(handle_of_window, ps)
                Call GetClientRect(handle_of_window, rc)
                str = "hello, world!"
                Call DrawText(hdc, str, Len(str), rc, DT_SINGLELINE Or DT_CENTER Or DT_VCENTER)
                Call EndPaint(handle_of_window, ps)
                Exit Function
            Case WM_DESTROY
                PostQuitMessage 0&
                Exit Function
            Case Else
                WindowProc = DefWindowProc(handle_of_window, message, wParam, lParam)
        End Select
    End Function这是汇编的
    WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM 
        .IF uMsg==WM_DESTROY                           ; if the user closes our window 
            invoke PostQuitMessage,NULL             ; quit our application 
        .ELSE 
            invoke DefWindowProc,hWnd,uMsg,wParam,lParam     ; Default message processing 
            ret 
        .ENDIF 
        xor eax,eax 
        ret 
    WndProc endp 这是c的
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message) 
        {
            case WM_COMMAND:
                switch LOWORD(wParam)
                {
                    case IDM_HELLO:
                       MessageBox(hWnd, "欧阳软件学习网欢迎你!", "欧阳软件学习网", MB_OK);
                       break;
                    case IDM_TEST:
                       MessageBox(hWnd, "测试菜单功能!", "欧阳软件学习网", MB_OK);
                       break;
                    case IDM_EXIT:
                       DestroyWindow(hWnd);
                       break;
                    default:
                       return DefWindowProc(hWnd, message, wParam, lParam);
                }
                break;      
            case WM_PAINT:   //窗口刷新
                Display(hWnd);
                break;
            case WM_DESTROY:  //关闭窗口
                PostQuitMessage(0);  //发送关闭消息
                break;
            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
       }
       return 0;
    }
      

  5.   

    我知道了,是我理解出问题,就是你说的那样。多谢了!完整的是这样:
    =================================='''form 代码:
    Private Sub Form_Load()
        prevWndProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
        SetWindowLong Me.hwnd, GWL_WNDPROC, AddressOf WndProc
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        SetWindowLong Me.hwnd, GWL_WNDPROC, prevWndProc
        End
    End Sub'''moudule 代码:
    Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongDeclare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDeclare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongDeclare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPublic Const GWL_WNDPROC = (-4)
    Public Const SC_MAXIMIZE = &HF030&
    Public Const WM_SYSCOMMAND = &H112
    Public Const WM_NCLBUTTONDBLCLK = &HA3Public prevWndProc As Long        ''''默认窗口程序地址Public Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    On Error GoTo ShowErr
            If Msg = WM_NCLBUTTONDBLCLK Then
                If Form1.WindowState <> 2 Then
                    SendMessage Form1.hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0&
                Else
                    WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
                End If
            Else
                WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
            End If
        Exit Function
    ShowErr:
        MsgBox Err.Source & "-" & Err.Description
    End Function
      

  6.   

    在窗口过程中用postmessage发送消息