Skip to content

Commit

Permalink
Improved: MDI Form
Browse files Browse the repository at this point in the history
  • Loading branch information
XusinboyBekchanov committed Aug 5, 2022
1 parent e17a18b commit a3ed159
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
32 changes: 31 additions & 1 deletion mff/Form.bas
Expand Up @@ -716,6 +716,21 @@ Namespace My.Sys.Forms
' End Select
' End Function

Function Form.HookClientProc(hDlg As HWND, uMsg As UINT, WPARAM As WPARAM, LPARAM As LPARAM) As LRESULT
Dim As Form Ptr frm = GetProp(hDlg, "MFFControl")
If frm Then
Select Case uMsg
Case WM_WINDOWPOSCHANGING
Dim As WINDOWPOS Ptr lpwp = Cast(WINDOWPOS Ptr, LPARAM)
lpwp->x = frm->FClientX
lpwp->y = frm->FClientY
lpwp->cx = frm->FClientW
lpwp->cy = frm->FClientH
End Select
End If
Return CallWindowProc(GetProp(hDlg, "@@@@Proc"), hDlg, uMsg, WPARAM, LPARAM)
End Function

Private Sub Form.HandleIsAllocated(ByRef Sender As Control)
If Sender.Child Then
Dim As HMENU NoNeedSysMenu
Expand Down Expand Up @@ -748,6 +763,10 @@ Namespace My.Sys.Forms
FClientStruct.hWindowMenu = 0 'GetSubMenu(GetMenu(.FHandle), WINDOWMENU)
FClientStruct.idFirstChild = &H00FF
.FClient = CreateWindowEx(0, "MDICLIENT", "", WS_CHILD Or WS_VISIBLE Or WS_VSCROLL Or WS_HSCROLL Or WS_CLIPSIBLINGS Or WS_CLIPCHILDREN, 0, 0, 100, 100, .FHandle, Cast(HMENU, &hcac), Instance, @FClientStruct)
If GetWindowLongPtr(.FClient, GWLP_WNDPROC) <> @HookClientProc Then
SetProp(.FClient, "MFFControl", Sender.Child)
SetProp(.FClient, "@@@@Proc", Cast(..WNDPROC, SetWindowLongPtr(.FClient, GWLP_WNDPROC, CInt(@HookClientProc))))
End If
ShowWindow(.FClient, SW_SHOW)
Case fsMDIChild
If .FParent Then
Expand Down Expand Up @@ -1057,10 +1076,21 @@ Namespace My.Sys.Forms
Canvas.HandleSetted = False
Return
Case WM_SIZE
'Dim As Rect rc1
'If FClient <> 0 Then GetClientRect FClient, @rc1
If Not IsIconic(FHandle) Then
RequestAlign
End If
If OnResize Then OnResize(This, This.Width, This.Height)
'If FClient <> 0 Then
' Dim As Rect rc2
' GetClientRect FClient, @rc2
' If rc1.Right <> rc2.Right OrElse rc1.Bottom <> rc2.Bottom Then
' 'msg.hWnd = FClient
' msg.Result = -4
' Return
' End If
'End If
Case WM_CLOSE
If OnClose Then
OnClose(This, Action)
Expand All @@ -1087,7 +1117,7 @@ Namespace My.Sys.Forms
mi = FMenuItems.Items[i]
With *mi
If .Command = msg.wParamLo Then
If .OnClick Then .OnClick(*mi)
If .onClick Then .onClick(*mi)
msg.Result = -2
msg.Msg = 0
Exit For
Expand Down
3 changes: 2 additions & 1 deletion mff/Form.bi
Expand Up @@ -94,8 +94,9 @@ Namespace My.Sys.Forms
#else
Declare Static Sub HandleIsAllocated(ByRef Sender As Control)
Declare Static Sub HandleIsDestroyed(ByRef Sender As Control)
Declare Static Sub WndProc(ByRef Message As Message)
Declare Static Sub WNDPROC(ByRef Message As Message)
#ifdef __USE_WINAPI__
Declare Static Function HookClientProc(hDlg As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
Declare Virtual Sub SetDark(Value As Boolean)
#endif
#endif
Expand Down

0 comments on commit a3ed159

Please sign in to comment.