by experttano (1 Submission)
Category: Windows API Call/Explanation
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (8 Votes)
Build MDI form via Windows API.
This code is very usefull to
sublsclass and handle
MDI Main form and child.
You can use thes code as you like without any limitations.
Please vote me.
Inputs
nothing
Assumes
Public Function WinMDIMain() As Long
Dim wndcls As WNDCLASSEX
Dim message As Msg
wndcls.cbSize = Len(wndcls)
wndcls.style = CS_HREDRAW + CS_VREDRAW
wndcls.lpfnWndProc = GetFuncPtr(AddressOf MDIClientHandler)
wndcls.cbClsExtra = 0
wndcls.cbWndExtra = 0
wndcls.hInstance = App.hInstance
wndcls.hIcon = 0
wndcls.hCursor = LoadCursor(0, IDC_ARROW)
wndcls.hbrBackground = COLOR_WINDOW
wndcls.lpszMenuName = 0
wndcls.lpszClassName = APP_NAME
If RegisterClassEx(wndcls) = 0 Then
MsgBox "Can't Register Class"
Exit Function
End If
wndcls.style = 0
wndcls.lpfnWndProc = GetFuncPtr(AddressOf MDIChildHandler)
wndcls.cbClsExtra = 0
wndcls.cbWndExtra = 0
wndcls.hInstance = App.hInstance
wndcls.hIcon = 0
wndcls.hCursor = LoadCursor(0, IDC_ARROW)
wndcls.hbrBackground = COLOR_WINDOW
wndcls.lpszMenuName = 0
wndcls.lpszClassName = CHILD_NAME
If RegisterClassEx(wndcls) = 0 Then
MsgBox "Can't Register Class"
Exit Function
End If
'Main form
hWnd = CreateWindowEx(0&, APP_NAME, _
App.ProductName, WS_OVERLAPPEDWINDOW, _
CW_USEDEFAULT, 0, _
CW_USEDEFAULT, 0, 0&, 0&, _
App.hInstance, 0&)
While (GetMessage(message, hWnd, 0, 0)) And message.message <> WM_NULL
TranslateMessage message
DispatchMessage message
DoEvents
Wend
WinMDIMain = message.wParam
End Function
Code Returns
nothing
Side Effects
nothing
API Declarationsso many:)
Download API MDIForm (4 KB)