Recently, considering the overall framework of the MIS system interface, I decided to use MDI Child in the MDI Form+ module, but the MDI form's workspace always has annoying thick edges.
I found the solution to the C++ version from the Internet yesterday afternoon, and I spent some time to translate it into delphi. Haha, for your reference.
Write the following code in the MDI Form:
interface
TFmMain = class(TForm)
...
PRocedure FormCreate(Sender: TObject);
...
Private
...
procedure CreateDefWndProc();
PROCEDURE ClientWndProc(VAR Message: TMessage);
end;
Implementation
...
procedure TFmMain.CreateDefWndProc;
var
hWnd1 : HWND;
ccs: TClientCreateStruct;
Begin
ccs.hWindowMenu := 0;
ccs.idFirstChild := $FF00;
hWnd1 := CreateWindowEx(WS_EX_CLIENTEDGE,
'MDICLIENT', '', WS_CHILD or WS_VISIBLE or WS_GROUP or
WS_TABSTOP or WS_CLipCHILDREN or WS_HSCROLL or WS_VSCROLL or
WS_CLIPSIBLINGS or MDIS_ALLCHILDSTYLES, 0, 0, ClientWidth,
ClientHeight, Handle, 0, HInstance, @ccs);
FClientInstance := pointer(GetWindowLong(hWnd1,GWL_WNDPROC));
DestroyWindow(hWnd1);
end;
procedure TFmMain.ClientWndProc(var Message: TMessage);
//VAR
// MyDC : hDC;
Begin
if (Message.Msg = WM_ERASEBKGND) then
Begin
//The source program that simulates VCL here fills the client area with the background color of the main window.
//You can also draw a graphic in the client area.
FillRect(HDC(Message.WParam), ClientRect, Brush.Handle);
// MyDC := TWMEraseBkGnd(Message).DC;
//BitBlt(MyDC, (ClientWidth - imBack.Picture.Width)div 2,
// (ClientHeight - imBack.Picture.Height) div 2,
// imBack.Picture.Width, imBack.Picture.Height,
// imBack.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
Message.Result := 1;
end
else
Message.Result := CallWindowProc(FClientInstance, ClientHandle,
Message.Msg, Message.WParam, Message.LParam);
end;
procedure TFmMain.FormCreate(Sender: TObject);
Begin
//*********Removing MDIchild thick border***************
CreateDefWndProc();
SetWindowLong(ClientHandle, GWL_WNDPROC,
LongInt(MakeObjectInstance(ClientWndProc)));
SetWindowLong(ClientHandle,GWL_EXSTYLE,GetWindowLong(
ClientHandle,GWL_EXSTYLE) and (not WS_EX_CLIENTEDGE));
SetWindowPos(ClientHandle,0,0,0,0,0,SWP_FRAMECHANGED
or SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER);
//************************************************************
end;