CWMFoundation – Message

CWMFoundation

CWMFoundation 意为 Charlie.Wang Foundation Mini(迷你版)

是作者工作中为方便代码编写,逐渐整理归档的一些代码集。

在原有CWFoundation的基础上,去除了大量窗体上的控件,只留下一个Delphi Pas文件的轻量级类。

Message类是用来输出不同类型输出文字的,比如直接输出Int类、直接输出到剪贴板等。

[图]

//***********************************
//***** CWMFoundation Message   ******
//***********************************
{$REGION ' CWMFoundation Message Implementation '}
procedure TCWMessage.IM(title: string; content: string);
begin
  Application.MessageBox(PChar(content),PChar(title),MB_OK+MB_ICONASTERISK);
end;
 
procedure TCWMessage.AM(title: string; content: string);
begin
  Application.MessageBox(PChar(content),PChar(title),MB_OK+MB_ICONWARNING);
end;
 
procedure TCWMessage.EM(title: string; content: string);
begin
  Application.MessageBox(PChar(content),PChar(title),MB_OK+MB_ICONERROR);
end;
 
procedure TCWMessage.HM(title: string; content: string);
begin
  Application.MessageBox(PChar(content),PChar(title),MB_HELP);
end;
 
procedure TCWMessage.QM(title: string; content: string);
begin
  Application.MessageBox(PChar(content),PChar(title),MB_OK+MB_ICONQUESTION);
end;
 
procedure TCWMessage.M(content: string);
begin
  ShowMessage(content);
end;
 
procedure TCWMessage.MC(content: string);
begin
  Clipboard.Clear;
  Clipboard.AsText := content;
  M(content);
end;
 
procedure TCWMessage.MI(content: Integer);
begin
  CWMsg.M(IntToStr(content));
end;
 
procedure TCWMessage.MD(content: Double);
begin
  CWMsg.M(FloatToStr(content));
end;
 
procedure TCWMessage.M_INT(content: Integer);
begin
  MI(content);  // same as MI
end;
 
procedure TCWMessage.MB(content: Boolean);
begin
  ShowMessage(BoolToStr(content,True));
end;
 
function TCWMessage.YESNO(title: string; content: string):Boolean;
begin
  if Application.Messagebox(PChar(content),PChar(title),MB_YESNO+MB_IconQuestion) = IDYES then Result := True else Result := False;
end;
 
function TCWMessage.OKCANCEL(title: string; content: string):Boolean;
begin
  if Application.Messagebox(PChar(content),PChar(title),MB_OKCANCEL+MB_IconQuestion) = IDOK then Result := True else Result := False;
end;
{$ENDREGION}

代码还在不断添加和优化中……