如何设计程序框架,需要做些什么?(100分)

  • 主题发起人 主题发起人 yuwei0527p
  • 开始时间 开始时间
Y

yuwei0527p

Unregistered / Unconfirmed
GUEST, unregistred user!
偶刚刚学会写些代码,请说详细些。
 
给你推荐一本书,有电子版的,自己找一下《代码大全第二版》,对你会有帮助的
 
{
¿ò¼ÜTsysFrame v1.0
ÈÕÆÚ:2005-9-1
Éè¼Æ:ÕÅÊÀƽ
}
unit PSysFrame;
interface
uses
Dialogs,
PDM,
Forms,
SysConfigUnit,
GUIDGeneratorUnit,
PTuser,
PTSYS,
PTLOG,
PTFun,
PTView,
pTOp_Ticket,
Windows,
InIfiles,
Classes,
SysUtils,
StrUtils,
EquipCacheUnit,
EquipInfoUnit,
EquipContainerUnit,
AOITEquipContainerUnit,
EquipValueUnit,
AOITEquipValueUnit,
OperationCacheUnit,
VGGraphUnit,
MessageManagerUnit,
DB,
ADODB,
TicketLogicUnit,
MainFormUnit,
GraphShowUnit,
GraphTicketUnit,
PrintTicketShowU,
ModuleGrantU,
TicketToMISUnit,
PTLocal_Cache, messages, shellapi;
type
TSysFrame = class
private
HotKeyId: integer;
public
FHwnd: thandle;
Guid: TGUIDGenerator;
ModuleGrant: TModuleGrant;
SysConfig: TSysConfig;
//ϵͳÅäÖÃÀà
PrintTicketShow: TPrintTicketShow;
MessageManager: TMessageManager;
Fun: TFun;
Log: TLog;
Sys: TSys;
User: TUser;
//È«¾ÖÓû§±äÁ¿
Op_Ticket: TOp_Ticket;
//Ö¸ÁîƱ
View: TView;
TicketLogic: TTicketLogic;
DBConn: TADOConnection;
DM: TDM;
EquipInfo: TEquipInfo;
EquipContainer: TEquipContainer;
EquipValue: TEquipValue;
OpCache: TOperationCache;
VGGraph: TVGGraph;
MainForm: TMainForm;
DataToMis: TDataToMis;
Local_Cache: TLocal_Cache;
//zsp 2006-8-2
//ReportFileId: string;
//PrintReportPathFile: string;
function SaveToReportFile(): Boolean;
//±£´æ±¨±íÎļþ
functiondo
wnLoadReportFile(): string;
overload;
//±£´æ±¨±íÎļþ
ZSP 2006-6-19 Ôö¼Ó
functiondo
wnLoadReportFile(filename: string): string;
overload;
//±£´æ±¨±íÎļþ
ZSP 2006-6-19 Ôö¼Ó
function ClearFile(): Boolean;
//ɾ³ýÎļþ
constructor Create;
destructor Destroy;
override;
procedure CommWndProc(var msg: tmessage);
procedure ExecHelpFile;
end;

var
KJ: TSysFrame;
implementation
uses
Controls, PConst;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMFolderFieldNames}
function TSysFrame.SaveToReportFile(): Boolean;
//±£´æ±¨±íÎļþ
var
SQLs: string;
begin
result := False;
SQLs := 'select FILE_DATA From Sys_Print_Files WHERE FILE_ID = ' + Fun.SafetySQL(PrintTicketShow.GetMainTicket.ReportFileId);
with DM.CreateQry(SQLs)do
begin
try
if RecordCount <> 0 then
begin
Edit;
TBlobField(FieldByName('FILE_DATA')).SaveToFile(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile);
Post;
result := True;
end;
finally
Free;
end;
end;
//with
end;

function TSysFrame.DownLoadReportFile(): string;
//±&pound;&acute;&aelig;±¨±í&Icirc;&Auml;&frac14;&thorn;
ZSP 2006-6-19 &Ocirc;&ouml;&frac14;&Oacute;
begin
result := '';
DM.SQL := 'select FILE_DATA From Sys_Print_Files WHERE FILE_ID = ' +
#39 + '2767E50010CE44ACA98C3A696E4F7580' + #39;
DM.OpenSQL;
if DM.RecordCount = 0 then
EXIT;
Result := ExtractFilepath(paramstr(0)) + 'temp/' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.FR3';
TBlobField(DM.Q1.FieldByName('FILE_DATA')).SaveToFile(Result);
end;

function TSysFrame.DownLoadReportFile(filename: string): string;
//±&pound;&acute;&aelig;±¨±í&Icirc;&Auml;&frac14;&thorn;
ZSP 2006-6-19 &Ocirc;&ouml;&frac14;&Oacute;
begin
result := '';
DM.SQL := 'select FILE_DATA From Sys_Print_Files WHERE FILE_ID = ' +
#39 + '2767E50010CE44ACA98C3A696E4F7580' + #39;
DM.OpenSQL;
if DM.RecordCount = 0 then
EXIT;
TBlobField(DM.Q1.FieldByName('FILE_DATA')).SaveToFile(filename);
result := filename;
end;

function TSysFrame.ClearFile(): Boolean;
//&Eacute;&frac34;&sup3;&yacute;&Icirc;&Auml;&frac14;&thorn;
var
Attrs: integer;
//&Icirc;&Auml;&frac14;&thorn;&Ecirc;&ocirc;&ETH;&Ocirc;
begin
Result := true;
// if FileExists(PrintReportPathFile) then
begin
Attrs := FileGetAttr(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile);
if ((Attrs and SysUtils.faReadOnly) = SysUtils.faReadOnly) then
FileSetAttr(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile, (Attrs - SysUtils.faReadOnly));
if ((Attrs and SysUtils.faHidden) = SysUtils.faHidden) then
FileSetAttr(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile, (Attrs - SysUtils.faHidden));
if ((Attrs and SysUtils.faSysFile) = SysUtils.faSysFile) then
FileSetAttr(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile, (Attrs - SysUtils.faSysFile));
try
Result := DeleteFile(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile);
except
Result := False;
end;
end;
end;

constructor TSysFrame.Create;
begin
Self.DM := PDM.DM;
Self.DBConn := Self.DM.ADOConnection1;
Guid := TComGUIDGenerator.Create;
PrintTicketShow := TPrintTicketShow.Create;
SysConfig := PrintTicketShow;
MessageManager := TMessageManager.Create(Self.Guid);

ModuleGrant := TModuleGrant.Create;
Log := tlog.Create;
Sys := tsys.Create;
SYS.SetKey;
User := TUser.Create;
View := TView.Create;
EquipContainer := TAOITEquipContainer.Create(Self.DM.ADOConnection1);
EquipInfo := TEquipInfo.Create(Self.DM.ADOConnection1, Self.EquipContainer);
EquipValue := TAOITEquipValue.Create(Self.DM.ADOConnection1, Self.EquipInfo, self.EquipContainer);
Self.OpCache := TOperationCache.Create(Self.DM.ADOConnection1);
Application.CreateForm(TMainForm, MainForm);
Fun := tfun.Create(MainForm);
Self.VGGraph := TVGGraph.Create(Self.DM.ADOConnection1, Sys.CurPath, MainForm.vgctrlLib, Self.Guid, true);
//self.GraphShow := TGraphTicket.Create(self.MessageManager,self.MainForm.CurrentVG,self.VGGraph,self.EquipInfo,self.EquipValue,self.EquipContainer,self.OpCache,'123456789');
Op_Ticket := TOp_Ticket.Create;
//&Ouml;&cedil;&Aacute;&icirc;&AElig;±
TicketLogic := TTicketLogic.Create(Self.DM.ADOConnection1, Self.EquipInfo, Self.EquipValue);
self.DataToMis := TDataToMis.Create;
Local_Cache := TLocal_Cache.Create;
//zsp 2006-8-2
if not DirectoryExists(Sys.CurPath + 'Temp/') then
CreateDir(Sys.CurPath + 'Temp/');
PrintTicketShow.SetOpTicketFR3PathFile(Sys.CurPath + 'Temp/' + Guid.GetGuid + '.fr3');
SaveToReportFile();
FHwnd := AllocateHWnd(CommWndProc);
HotKeyId := GlobalAddAtom('{CD38D3F6-4F2A-4BC9-B14F-A93C6E08CE5C}') - $C000;
//RegisterHotKey(Handle&pound;&not;
HotKeyId&pound;&not;
MOD_ALT&pound;&not;
VK_F1)&pound;&raquo;&iexcl;&iexcl;
RegisterHotKey(FHwnd, HotKeyId, 0, VK_F1);
end;

destructor TSysFrame.Destroy;
begin
UnRegisterHotKey(FHwnd, HotKeyId);
DeallocateHWnd(FHwnd);
self.DataToMis.Free;
Self.TicketLogic.Free;
Self.VGGraph.Free;
Self.MainForm.Free;
View.Free;
EquipInfo.Free;
EquipContainer.Free;
EquipValue.Free;
OpCache.Free;
MessageManager.Free;
KJ.ModuleGrant.Free;
Fun.Free;
Sys.Free;
User.Free;
ClearFile();
deletefile(PrintTicketShow.GetMainTicket.OpTicketFR3PathFile);
PrintTicketShow.Free;
Guid.Free;
Log.Free;
Local_Cache.Free;
//zsp 2006-8-2
end;

procedure TSysFrame.CommWndProc(var msg: tmessage);
begin
//IF MSG.WParam= HotKeyId then
SHOWMESSAGE('AAAAAAA');
if (msg.Msg = WM_KEYDOWN) and (msg.WParam = VK_F1) then
begin
ExecHelpFile;
exit;
end;

if (Msg.LparamLo = 0) and (Msg.LParamHi = VK_F1) then
begin
ExecHelpFile;
// &frac14;&Ugrave;&Eacute;è&Egrave;&Egrave;&frac14;ü&Icirc;&ordf;ALT+F1
exit;
end;
end;

procedure TSysFrame.ExecHelpFile;
var H: HWND;
begin

H := FINDWINDOW(nil, '&micro;÷&para;&Egrave;&sup2;&Ugrave;×÷&Ouml;&cedil;&Aacute;&icirc;&Iacute;&frac14;&ETH;&Icirc;&Iuml;&micro;&Iacute;&sup3;°&iuml;&Ouml;ú');
if H > 0 then
begin
SetWindowPos(h, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
FlashWindow(h, TRUE);
//FlashWindow(Application.handle, TRUE);
EXIT;
end;
shellExecute(Application.Handle, 'open', pchar(ExtractFilepath(paramstr(0))+'&micro;÷&para;&Egrave;&sup2;&Ugrave;×÷&Ouml;&cedil;&Aacute;&icirc;&Iacute;&frac14;&ETH;&Icirc;&Iuml;&micro;&Iacute;&sup3;°&iuml;&Ouml;ú.chm'), nil, nil, SW_SHOW);
end;

end.
 
代码写够1w行了再学框架吧。
 
框架是用来干什么的啊?
 
范围可大了。。。
.net
也是个框架
 
难 道改- 问 -题 了?
 
后退
顶部