2013年11月24日 星期日

Delphi Panel-Align

Delphi 版面配置有個訣竅就是利用Penal物件利用Penal-Align 控制各個Panel
Align 有幾種選擇
1. alBottom
2. alClient
3. alCustom(未知)
4. alLeft
5. alNone
6. alRight
7. alTop

上、下兩張圖是對應的

由圖示可知道上下左右的Align的特性
會依附在上下左右邊並且對應Form作大小縮放

通常都是先用Control Penal先控制版面
再從版面新增元件所以在















如右圖,在PnlMain裡面有pcDetail與pnlMaster
各pnl裡面還有相關元件










But如何在在一個Penal裡面再新增兩個畫面元件
並且讓他們跟隨著Form一起縮放呢?!
首先
必須先把綠框框的Align設定為alClient(隨畫面縮放)
再將A或B其一設定為alTop或alBottom
另外一個就設定為alClient即可

因為alClient會尋找附近元件的邊界並且黏附在上面
在DesignTime裡面就可以輕易看到
但是上下左右的對其方式卻是會固定Height 或Width

Ex:我設定上述範例的A為alTop但是我的Height必須為固定,然後B的alClient模式下Top數值會依循A的高度附著上去( 換句話說!你沒辦法設定它的Top值,他的值是由A來決定 )

那如過是alRight呢?反知須設定Width,依此類推





2013年10月15日 星期二

Android Development Environment building

There are two way to building development environment
Option 1. using Android Studio 
               But I don't use that way to running my program
so  ,Let's keep read on
Option 2. using Eclipse + Android SDK Bundle + JDK + Genymotion  1.3.0
there has the SDK intall detail that you need
you also need  Genymobile Plug-In. more detail...

Name: Genymobile
Location: http://plugins.genymotion.com/eclipse


























there is the List that we need
Tools
    SDK Tools
    SDK platform
    SDK Build-Tools(If you don't select it , that you'll missing file 'R.java' )
    Genymotion Plug-In
Android 4.3(Optional, Depend on what kind of version that you need )



Now I can coding , Have Fun




2013年10月14日 星期一

布林運算邏輯閘應用

Boolean operators
Operator Operation Operand types Result type Example
not       negation         Boolean Boolean not (C in MySet)
and         conjunction        Boolean Boolean Done and (Total > 0)
or       disjunction          Boolean Boolean A or B
xor exclusive disjunction Boolean Boolean A xor B  

(還有shrshl 的邏輯位移運用)
(引用於Borland Delphi 7內的F1說明,邏輯閘的說明)
可以用上述的方式來判斷True 或Flase 使用上性能表現比IF判斷值行好很多
例:
 cbFG_QT_CTL.Enabled := (State='Insert') or (State='Query');

上句敘述相同於

IF  (State='Insert') or (State='Query') Then
    cbFG_QT_CTL.Enabled:= True;
else
     cbFG_QT_CTL.Enable:= False;


2013年9月4日 星期三

IF then else組合式

Delphi {IF THEN ELSE的多行應用方法}
var
   定義式;
Begin
  if 條件式 then
    begin
     多行執行式;
     多行執行式;
    End   (這裡不需要分號)
 else
    begin
      多行執行式;
      多行執行式;
    End   

 end; (這裡必須為分號)

上述為IF多行執行式的用法
在 Delphi的範圍設定Begin 與 End的搭配,就像C的左右大掛號 { , }
選擇程式碼的適用範圍,如果執行式只有一行就可省略如下
var
   定義式;
Begin
  if 條件式 then 多行執行式;
  else 多行執行式;
end; (這裡必須為分號)


2013年8月29日 星期四

不同 爸爸 但是相同爺爺的繼承問題

不同Unit 但是相同Procedure(Function) 的Compile Error
當使用相同函式庫卻遇上相同物件繼承時
(廢話不多說先看圖)

當我在unit  dmW_C0578_GDMu;使用cbsEllipsis函數時
Uses 函式庫裡面的InfoCtrlsAdvDBGrids
均有使用cbsEllipsis 的 物件Object
但是此Object來自兩個函式庫,結果可能會與預期的不相同或者Compile Error
解決方法:
InfoCtrls.cbsEllipsis
或者
AdvDBGrids .cbsEllipsis

2013年8月26日 星期一

資料庫基本語法

相關物件
TColumn
TDBGrid
DataSource

type
  TForm1 = class(TForm)
    Button2: TButton;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    DataSource1: TDataSource;                        //資料庫來源語法
    ADOQuery1: TADOQuery;                        //Data查詢啟用語法
    DBGrid1: TDBGrid;                                    //資料表顯示語法



procedure TForm1.FormCreate(Sender: TObject);
begin
  ADOQuery1.Open;
end;                                                             *重要,必須開啟才能使用*    


下列為開啟資料表在Control Panel理動態新增分頁並且動態設定資料表讀取欄位與寬度設定
var
  Yoo: TTabSheet;
  i, j: integer;
  aDBGrid:TDBGrid;
  c: TColumn;
begin
 j:=3;
 for i:= 1 to 5 do
  begin
    Yoo :=TTabSheet.Create(Self);
    Yoo.PageControl :=PageControl1;
    Yoo.Caption := Yoo.ClassName+inttostr(j);
    aDBGrid:= TDBGrid.Create(Self);
    if Yoo.TabIndex =3 then
    Begin
     aDBGrid.Parent :=Yoo;
     aDBGrid.Align :=alClient;
     aDbGrid.DataSource := DataSource1;     //DATA Source導入語法

     c := aDBGrid.Columns.Add;
      c.FieldName:='ID_CUST';

     c := aDBGrid.Columns.Add;
      c.FieldName:='NM_C';
      c.Width:=335;                                        //第二欄寬定
    End;
    j :=j+1;
   end;
end;


2013年8月20日 星期二

Array 陣列

陣列可以不用一開始就宣告
如:

Var
  Test:Tstrings;
  Yoo:String;
begin
  Yoo:='0123456789abcdefghijklmnopqrstuvwxyz';
  ShowMessage(Yoo[1]);    //值為0
  ShowMessage(Yoo[2]);    //值為1








也可直接宣告長度SetLenth(等待加入)

以下為利用ArrayFOR迴圈去除Delphi讀取資料時去除斷行與空白(我要做字典檔)
Var
  i, x:integer;
  Name:TStrings;


begin
  Name:=TStringList.Create;
  Name.LoadFromFile('D:\xxx1.txt');
  for i := 0 to Name.Count-1 do   Name[i]:= StringReplace(Name[i], ' ', '',[rfReplaceAll]);
  for i := Name.Count-1  downto 1 do
   begin
    Name[i-1]:= NAme[i-1]+ NAme[i];
   Name.Delete(i);                                         //在此遞減比較好用
   end;
  ShowMessage(Name[Name.Count-1]);
  Name.SaveToFile('D:\\xxx.txt');
  Name.Free;

{
 遞增概念
{
for i := 0 to Name.Count-2 do
   Begin
      Name[i+1]:=  Name[i]+ Name[i+1];    //遞增的方式有點奇怪,Delete會Index錯誤
      Name[i]:='';                                         //不能用delete 會影響FOR迴圈內Count的計算
   End;
}