写一个大一点的程序时面对的问题.(100分)

X

xwings

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在想写一个大一点的程序,就是稍微复杂一点的.
为了以后修改和扩充,我想采取多个单元的方式.
但是有好多问题了.
首先
一个主单元main.

一个全局变量定义单元. globe
一个通用的函数单元 . Funit
另外还要用到好多unit(windows ,dialog ,ExtCtrls, StdCtrls, MMSystem......)

目前的问题是:

1.各个单元的uses 语句如何写?
2.主单元要uses以上单元,但是globe 和 Funit 也要用部分系统unit. 是不是每个都要
写一堆uses unit?
3.我的funit单元中的函数使用到mainForm中的对象. 是不是要在里面uses main?
这样不是循环引用了么? 如何解决?

各位高手还有什么建议,请多多指教.

谢谢.
 
S

soj

Unregistered / Unconfirmed
GUEST, unregistred user!
Alt-F11 加入你要引用的单元
use 不会引起循环引用
所有单元只要你用到Form,就要use Form,Windows之类
和C++的.h不一样,.h是由于C++编译器慢的产物
建议 Delphi自己的Unit 在 interface下,自己变得unit 在implementation下
如下例,有问题多联系
coolsoj@163.net


unit uPrepare;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DBCtrls, Grids, Menus, Grids_ts, TSGrid, TSDBGrid,
ComCtrls, dxGrClms, dxDBGrid, dxTL, dxCntner , ADODB, dxDBTLCl, dxDBCtrl,Apputils,
DBGrids;

type
TfrmPrepare = class(TForm)
...
end;

var
frmPrepare: TfrmPrepare;

implementation

uses DataModule, uGLOBALS, uAddPrepare;

 
X

xwings

Unregistered / Unconfirmed
GUEST, unregistred user!
如果我在其它unit中用到了mainForm中的对象时,如何处理?
 
S

soj

Unregistered / Unconfirmed
GUEST, unregistred user!
use uMainform;
...
frmMain.xxxx;

 
X

xwings

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
顶部