Q&A

  • 메뉴를 Coolbar위에 올렸는데요. --꼭 갈쳐주세영
책에 예제 보니깐 메뉴를 툴바 위에 올려 놓는 예제가 있길래 MDI창에서 한번 따라 해봤는데..

차일드 창 최대화하면 작은창 최대화, 최소화 버튼 등이 안 보이네요...

쿨바에 가려서 안 보이는거 같은데...

이거 좀 누구 해결해 주세요...

흑흑...

전체 소스입니다.



unit MainFrm;



interface



uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,

StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, MdiChildFrm,

ToolWin;



type

TMainForm = class(TForm)

mmMain: TMainMenu;

mmiFile: TMenuItem;

mmiNew: TMenuItem;

mmiClose: TMenuItem;

mmiWindow: TMenuItem;

N1: TMenuItem;

mmiExit: TMenuItem;

mmiHide: TMenuItem;

mmiShow: TMenuItem;

mmiHideForm: TMenuItem;

CoolBar1: TCoolBar;

ToolBarMenu: TToolBar;

procedure mmiNewClick(Sender: TObject);

procedure mmiCloseClick(Sender: TObject);

procedure mmiExitClick(Sender: TObject);

procedure mmiHideClick(Sender: TObject);

procedure mmiShowClick(Sender: TObject);

procedure mmiHideFormClick(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

procedure CreateMDIChild(const Name: string);

public

HideForm: TMDIChildForm;

Hidden: Boolean;

end;



var

MainForm: TMainForm;



implementation



{$R *.DFM}



procedure TMainForm.CreateMDIChild(const Name: string);

var

MdiChild: TMDIChildForm;

begin

MdiChild := TMDIChildForm.Create(Application);

MdiChild.Caption := Name;

end;



procedure TMainForm.mmiNewClick(Sender: TObject);

begin

CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1));

end;



procedure TMainForm.mmiCloseClick(Sender: TObject);

begin

if ActiveMDIChild <> nil then

ActiveMDIChild.Close;

end;



procedure TMainForm.mmiExitClick(Sender: TObject);

begin

Close;

end;



procedure TMainForm.mmiHideClick(Sender: TObject);

begin

if Assigned(HideForm) then

ShowWindow(HideForm.Handle, SW_HIDE);

Hidden := True;

end;



procedure TMainForm.mmiShowClick(Sender: TObject);

begin

if Assigned(HideForm) then

SetWindowPos(HideForm.handle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE

or SWP_NOMOVE or SWP_SHOWWINDOW);

Hidden := False;

end;



procedure TMainForm.mmiHideFormClick(Sender: TObject);

begin

if not Assigned(HideForm) then

begin

if MessageDlg('Create Hidden?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then

begin

LockWindowUpdate(Handle);

try

HideForm := TMDIChildForm.Create(Application);

HideForm.Caption := 'HideForm';

ShowMessage('Form created and hidden. Press OK to show form');

finally

LockWindowUpdate(0);

end;

end

else begin

HideForm := TMDIChildForm.Create(Application);

HideForm.Caption := 'HideForm';

end;

end

else if not Hidden then

HideForm.SetFocus;

end;



procedure TMainForm.FormCreate(Sender: TObject);



var

I, ToolSize: Integer;

mItem: TMenuItem;

tb: TToolButton;



begin

// FileName := '';

// Modified := False;

{ Application.Title := Caption;



// ComboFont.Items := Screen.Fonts;

// ComboFont.ItemIndex := ComboFont.Items.IndexOf (

// RichEdit.Font.Name);



{Hints are customized in this version, as we use both the short

and the long portion of the Hint string property

// move captions to hints, removing the &







// populate the control bar menu

for I := 0 to ControlBar.ControlCount - 1 do

begin

mItem := TMenuItem.Create (Self);

mItem.Caption := ControlBar.Controls [I].Name;

mItem.Tag := Integer (ControlBar.Controls [I]);

// mItem.OnClick := BarMenuClick;

// BarMenu.Items.Add (mItem);

end;

}

// create the buttons of the menu toolbar

ToolSize := 0;

for I := mmMain.Items.Count - 1 downto 0 do

begin

tb := TToolButton.Create (ToolBarMenu);

tb.Parent := ToolBarMenu;

tb.AutoSize := True;

tb.Grouped := True;

tb.Caption := mmMain.Items[I].Caption;

tb.MenuItem := mmMain.Items[I];

Inc (ToolSize, tb.Width);

end;

// size the menu toolbar

ToolBarMenu.Width := 500;

// hide the standard menu, using the form's Menu property

Menu := nil;



end;



end.

0  COMMENTS