Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure TForm1.Button1Click(Sender: TObject);
for i := 0 to 3 do
procedure TForm1.Button2Click(Sender: TObject);
procedure TForm1.Button3Click(Sender: TObject);
var i, j : Integer;
for i := 0 to 3 do for j := 0 to 3 do
Создание меню. Компоненты MainMenu и PopupMenu
Создать главное меню, имеющее упрощенную структуру меню Windows: File, Edit, Run. В качестве реакции на выбор пункта меню выдавать сообщения о выборе соответствующего пункта.
Решение
1. Создадим новую папку, например D:MyProjectMAINMENU.
2. Откроем новый проект.
3. Из страницы Standard поместим на Form1 компонент MainMenu1.
4. В Инспекторе Объектов выберем свойство Items компонента MainMenu1, а затем щелкнем по кнопке с тремя точками. После этого на экране появится окно конструктора меню.
5. С помощью конструктора меню наберем элементы меню, указанные в условии
примера.
Напомним, что подчеркнутая буква в имени пункта означает клавишу быстрого перехода. С помощью этой клавиши можно осуществить быстрый переход на данный элемент меню. Задать клавишу быстрого перехода можно с помощью символа &, помещаемого перед соответствующим символом текста. Например: &File, Cu&t.
Обратите внимание, что, вводя название элемента меню, вы задаете значение свойства Caption для этого элемента меню. Для того чтобы ввести код клавиши быстрого управления, например Ctrl+S для пункта Save, необходимо для соответствующего элемента меню выбрать свойство ShortCut в Инспекторе Объектов и в выпадающем списке выбрать нужное значение. Для того чтобы элемент меню представлял собой разделительную линию, следует его свойству Caption задать значение ‘-‘. Для создания подменю, например для пункта Reopen, следует выбрать нужный элемент меню и щелкнуть правой кнопкой мыши. В появившемся контекстном меню конструктора выберите пункт Create Submenu. Далее введите пункты подменю.
6. Если вы ввели все пункты меню, то закройте окно конструктора меню. На форме Form1 осталось созданное меню. Для определения реакции на выбор пунктов меню следует по очереди выбирать все пункты меню и щелкать по ним мышкой. В результате появится окно Редактора Кода, в котором нужно ввести программный код для обработчика события OnClick. Например, для элемента меню New обработчик события OnClick будет иметь вид:
procedure TForm1.New1Click(Sender: TObject);
ShowMessage(‘Выбран пункт New’);
Здесь ShowMessage — это стандартная функция, выводящая на экран окно с заданным сообщением.
7. Сохраните проект и запустите его на выполнение.
Приведем полный текст сформированного модуля.
Текст модуля Unit1.pas
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Menus;
I have written 2 packages: MEComps_DXE5 and AMLComps_DXE5. The latter depends on the former. Both should be multi-platform: Win32, Win64, and (in the future) OSX.
When I open the first package MEComps_DXE5, I am able to compile it, build it and install it. I get some warnings, as this library contains code that must also compile on old D5, but the build succeeds and creates the dcu and dcp files where expected.
When I open the second package AMLComps_DXE5, I find this situation:
- If I do not declare the dependency on MEComps_DXE5, the package will compile and build correctly (no errors, dcu and dcp files are generated), but Delphi will warn me that it has implicitly imported units from MEComps_DXE5, and ask me to add the package to the dependency list (Requires)
- If the dependency is declared, then the compilation will fail with «[dcc32 Fatal Error] MEComps_DXE5.dpk(52): F2063 Could not compile used unit ‘MEClasses.pas'» , where MEClasses is the first unit of the MEComps_DXE5 package.
I’ve been trying to solve this for a few days now, but to no avail. I’m working on two fronts:
- Why is Delphi even trying to compile the other package? I have just built and installed it, and have all dcus and the dcp.
- Why is the compilation failing?
As to the first question I have no clue whatsoever.
As to the second question, the documentation is useless in this case. It explains why not being able to compile a used unit is fatal, and states that the cause is determined by looking at the previous errors. But in this case, there are NO previous errors.
As MEComps_DXE5 actually compiles and builds on its own, I doubt this has anything to do with syntax or code. It would seem to be that the compiler is not able to find something it needs to compile those units.
The two packages reside each in their own directory. I put the MECompsWin32 dcu directory on the library path and on the browsing path. The IDE actually has no problems looking up the used units.
I also checked the dcc32 command line and it seems that all envolved directories are known to the compiler.
Other info I can add:
- Both packages have their own include file (in their source directory). I’m not sure if these are to be included in the package contains list or not, but I’ve tried both ways and nothing seemed to change.
- Both packages have a corresponding Delphi 5 package which includes some of the same units and code (different dpk though). These compile and build correctly. Delphi 5 dcu files are generated in the source directory. Can this create problems with the XE5 compiler?
- Here is the complete code for the MEComps_DXE5 package. I see a lot of compiler directives that Delphi inserted when it created the empty package. I didn’t touch those:
‘ошибку выдает вот сдесь if dlgOpen1.Execute then а вот весь код программы (это я пытаюсь сделать самый простой аудио плеер.. .
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MPlayer;
type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
OpenDialog1: TOpenDialog;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
var
Form1: TForm1;
procedure TForm1.Button4Click(Sender: TObject);
if dlgOpen1.Execute then
mp1.FileName:=dlgopen1.FileName;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
mp1.stop;
button3.Enabled:=false;
button2.Enabled:=True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mp1.PauseOnly;
button2.Enabled:=false;
button3.Enabled:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if button2.Enabled=false then
mp1.Pesume
else
begin
mp1.Open;
mp1.Play;
end;
button2.Enabled:=false;
button3.Enabled:=false;
end;