|
MDI에서 Child가 영역 밖으로 나가면 스크롤 바가 안생기도록 하는 델파이 소스인데요....
빌더로 바꿨는데 제대로 작동을 안하네요...뭐가 잘못됐을까요?
//------------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Menus, Unit2;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
F1: TMenuItem;
N1: TMenuItem;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
procedure FormCreate(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
protected
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
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 TForm1.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;
procedure TForm1.N1Click(Sender: TObject);
begin
TForm2.Create(Self);
end;
end.
//------------------------------------------------------------------------------
빌더로 변경한겁니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Main.h"
#include "About.h"
#include "Unit1.H"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
LRESULT ClientWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
WNDPROC f = (WNDPROC)GetWindowLong(hWnd, GWL_USERDATA);
if (uMsg == WM_NCCALCSIZE)
{
if ((GetWindowLong(hWnd, GWL_STYLE) & (WS_HSCROLL | WS_VSCROLL)) != 0)
{
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~(WS_HSCROLL | WS_VSCROLL));
}
}
return CallWindowProc((FARPROC)f, hWnd, uMsg, wParam, lParam);
}
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent *Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
if (ClientHandle != 0)
{
if (GetWindowLong(ClientHandle, GWL_USERDATA) != 0) return;
SetWindowLong(ClientHandle, GWL_WNDPROC, (LONG)ClientWindowProc);
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::NewFormMenuClick(TObject *Sender)
{
TMDIChild *pChild;
pChild = new TMDIChild(this);
}
//---------------------------------------------------------------------------
|