SDI 로만 작업해 오다 MDI 가 필요하여 웹서핑하여 자료를 모아 보도록 하겠습니다.
1. MDI 폼에서 SDI 가 크라이언트 영역을 벗어나면 자동으로 스크롤 바가 생깁니다. 이 스크롤 바를 없애고 싶으면
- 메인폼에
function ClientWindowProc(wnd: HWND; msg: Cardinal; wparam, lparam: Integer): Integer; stdcall;
var
f: Pointer;
Begin
f := Pointer(GetWindowLong(wnd, GWL_USERDATA));
case msg of
WM_NCCALCSIZE: begin
if (GetWindowLong(wnd, GWL_STYLE) and (WS_HSCROLL or WS_VSCROLL)) <> 0 Then
SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE) and not(WS_HSCROLL or WS_VSCROLL));
end;
end;
Result := CallWindowProc(f, wnd, msg, wparam, lparam);
end;
- 폼 생성 시
procedure TfrmMain.FormCreate(Sender: TObject);
begin
if ClientHandle <> 0 Then begin
if GetWindowLong(ClientHandle, GWL_USERDATA) <> 0 then Exit;
SetWindowLong(ClientHandle, GWL_USERDATA, SetWindowLong(ClientHandle, GWL_WNDPROC, Integer(@ClientWindowProc)));
end;
end;
2. 차일드폼이 미니마이즈 될때 엠디아이 크라이언트 영역 아래쪽에 네모로 보입니다. 이게 보기 싫어 안보이게 하려면..
- 베이직 폼을 하나 만들고
type
TfrmBase = class(TForm)
private
{ Private declarations }
public
procedure WMSize(var M: TWMSIZE); message WM_Size;
end;
- 구현(Implementation) 영역에
procedure TfrmBase.WMSize(var M: TWMSIZE);
begin
if M.SizeType = Size_Minimized then begin
ShowWindow(Handle, Sw_Hide);
M.Result := 0;
end
else inherited;
end;
- 차일드 폼이 이 베이직 폼을 승계 하면 됩니다.
TfrmChildForm = class(TfrmBase) // 그냥 만든 후 수정해주어도 됩니다.
private
public
end;
댓글 없음:
댓글 쓰기