我有一个数据模块(TfDB)我想添加这个功能
Function GetZone(zone :string):string;
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我收到此错误...外部声明不满意:TfDB.GetZone
unit MyDataModule;
interface
uses
System.SysUtils, System.Classes, Data.DB, Data.Win.ADODB;
type
TfDB = class(TDataModule)
dbconnection: TADOConnection;
private
{ Private declarations }
public
Function GetZone(zone :string):string;
end;
var
fDB: TfDB;
implementation
{%CLASSGROUP 'System.Classes.TPersistent'}
{$R *.dfm}
Function GetZone(zone:string):string;
begin
if zone = 'FLayout1' then
result := '1';
if zone = 'FLayout2' then
result := '2';
if zone = 'FLayout3' then
result := '3';
if zone = 'FLayout4' then
result := '4' ;
if zone = 'FBoneYard' then
result := …Run Code Online (Sandbox Code Playgroud) 目前,当我点击一个按钮时,它将在新表格上创建一些形状.一旦我关闭新表格,我怎么能破坏它所形成的形状.
如果需要,我可以添加更多信息,但希望有一种简单的方法可以在表单关闭时销毁所有TMachine实例.
TMachine 是一个TShape类
procedure TFLayout1.GetClick(Sender: TObject);
var
azone: string;
adept: string;
machine : TMachine;
begin
fdb.count := 0; //keeps track of number of machines in zone
azone := MyDataModule.fDB.GetZone(Name); //gets name of zone
adept := TButton(Sender).Name; //gets name of dept
fdeptlayout.ListBox1.Clear;
fdeptlayout.show;
with fdeptlayout.ADOQuery1 do
begin
sql.Clear;
sql.BeginUpdate;
sql.Add('SELECT');
sql.Add(' *');
sql.Add('FROM');
sql.Add(' `MList`');
sql.Add('WHERE `Zone` = :myzone ');
sql.Add(' AND `Dept` = :mydept');
sql.EndUpdate;
parameters.ParamByName('myzone').Value := azone;
parameters.ParamByName('mydept').Value := adept;
open;
end;
//gets number of machines in total …Run Code Online (Sandbox Code Playgroud) 我有一个问题,当我去if语句中添加更多"名称"时.我很难看到那里是否准备就绪.因此,有一个更干净的方式来写这个我可以很容易地看到那里有什么名字读?
function TfDB.GetW(name: string) :integer;
begin
result := 0;
if (name = 'Destacker') or (name='Router') or (name = 'Turn Table') Then
result := 57;
if (name = 'Laser Marker') then
result := 66;
if (name = 'SP28')OR(name='Chamber') OR (name = 'CM402') OR (name = 'SP60') then
result := 65;
if (name = 'Conveyor') OR (name = 'Slide Gate') OR (name = 'Washer') then
result := 51;
if (name = 'BTU') OR (name = 'Furukawa') OR (name = 'Radial') OR (name …Run Code Online (Sandbox Code Playgroud) 我在地图上绘制六边形.由于某种原因,它只会创建一行.我相信我的循环是正确的.如果开启
glVertex3f(((sin(i/6.0*2*PI))/10)+RowOffset,((cos(i/6.0*2*pi))/10)+CollumnOffset,-2);
Run Code Online (Sandbox Code Playgroud)
我换RowOffset和CollumnOffset 然后我得到一个列.
procedure TFCreatemap.menuArea;
var
I: Integer;
Row,Collumn: Integer;
RowOffset,CollumnOffset: double;
TotalRow,TotalCollumn:integer;
begin
Row := 0;
Collumn:= 0;
CollumnOffset := -0.9;
TotalRow := 11;
TotalCollumn := 11;
while Collumn < TotalCollumn do
begin
CollumnOffset := CollumnOffset+0.4;
RowOffset:= -0.9;
while Row < TotalRow do
begin
RowOffset := RowOffset+ 0.2;
glBegin(GL_POLYGON);
for I := 0 to 6 do
begin
glVertex3f(((sin(i/6.0*2*PI))/10)+RowOffset,((cos(i/6.0*2*pi))/10)+CollumnOffset,-2);
end; {for}
glEnd;
Row:= Row+1;
end; {end collumns with}
Collumn:= Collumn+1;
end; {end rows with}
end;
Run Code Online (Sandbox Code Playgroud)
我的左/上也是-1比1
好吧不确定这是正确的方式,甚至是正确的方式,但我已经看到了并开始使用它,假设您有6个文件
main.cpp
main.h
car.cpp
car.h
speed.cpp
speed.h
Run Code Online (Sandbox Code Playgroud)
我试图得到用作材质纹理的jpg的名称.但不知道如何把它作为一个字符串.
我有这个注意:CreateCube [1]是一个数组中的TCube组件
CreateCube[1].Material.Texture.CreateFromFile(gamedir+'\pics\'+blocktype);
Run Code Online (Sandbox Code Playgroud)
blocktype将在哪里
grass.jpg
dirt.jpg
snow.jpg
stone.jpg
Run Code Online (Sandbox Code Playgroud)
等...但是一旦它被分配后如何获得类型?目前我texture在记录中有一个字符串cube.
cube.texture := createCube[i].Material.Texture.?????
Run Code Online (Sandbox Code Playgroud)
什么属性将名称作为字符串?
我正在尝试为游戏制作一个TCard组件.我应该从哪个班级派生出来?
这是一个像MTG或yu gi哦的纸牌游戏.该卡应具有空白图像,并且在创建时将加载前视图或后视图.
如果它加载前视图,则必须有一些标签(对于power/cost/def/text等属性).卡必须是可点击的.
type
TCard = class(zzzzzzzzz)
private
Run Code Online (Sandbox Code Playgroud)
现在一旦完成,我是否必须向构造函数/析构函数添加任何内容?目前我有:
constructor TCard.Create(AOwner: Tcomponent);
begin
inherited Create(AOwner);
end;
{******************************************************************************}
{ Free any resources allocated to component }
destructor TCard.Destroy;
begin
inherited Destroy;
end;
Run Code Online (Sandbox Code Playgroud)
另外我认为我添加了onclick部分,但不确定.在我发表的出版物中
{Inherited properties}
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnClick;
property OnDblClick;
Run Code Online (Sandbox Code Playgroud)
等等...
只是用delphi学习一些OpenGL并尝试简单但没有得到结果的东西,我相信我应该得到一个深绿色的形式.但是当我跑这个我什么也得不到.也没有错误.也许错过了什么?
unit First1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls,OpenGL, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
GLContext : HGLRC;
ErrorCode: GLenum;
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
var
pfd: TPixelFormatDescriptor;
FormatIndex: integer;
begin
fillchar(pfd,SizeOf(pfd),0);
with pfd do
begin
nSize := SizeOf(pfd);
nVersion := 1; {The current version of the desccriptor is 1}
dwFlags := …Run Code Online (Sandbox Code Playgroud) 我想知道是否有办法改变TShape的方向,而不是方形,我想旋转它看起来像一个钻石..
如果不是TShape的方式,怎么办呢?
我需要在每次关闭或重新启动计算机时进行计数。因此,我相信我可以通过将批处理文件添加到开始菜单来完成此操作。因此,每次您打开 PC 时,它都会运行。当它运行时应该
open c:\count.txt
read in the value on that text file
add 1 to it
write the value to the text file
exit.
Run Code Online (Sandbox Code Playgroud)
但我没有太多使用批处理文件,并且不知道如何从文本文件中读取数字。
delphi ×8
delphi-xe2 ×6
opengl ×2
batch-file ×1
c++ ×1
firemonkey ×1
header-files ×1
include ×1
vcl ×1