2015年11月2日 星期一

兩個 機械 結構 教學 教育 網站

http://www.robives.com/mechs
兒童 機械 結構 教學 教育 網站,robives

https://www.youtube.com/user/robives
robives  youtube頻道

這是些底圖
http://www.robives.com/patterns

你可以在這裡找到一些下載的 紙模型
http://www.robives.com/blogshop
https://www.patreon.com/robives?ty=h

某些內容是需要會員付費的




木工教學網站,還有需多 機械 與 木工工具DIY 教學
http://woodgears.ca/index.html


http://woodgears.ca/gear/wear.html相當詳細的教學內文










裡面有一個 藍芽 相片印表機跟一個 arduino ,連接USB去電腦,Processing.javascript 會去查詢 Instagram , 當你選擇 地點後 按列印 ( apple script ) 他會輸出一個 相片 圖

http://www.andrewhaskin.com/Arduino-Processing-Globalgram-Prototype

Andrew Haskin

Globalgram
Programming for Interaction, Fall 2011

Here is my final project for my Programming class. It’s a prototype of my original concept, which you can read about here. To operate, you would select a nature-inspired theme via the selector dial on the right, and then push the ‘Print’ button to print the latest post to Instagram based on your selection.
這是我為我的編程類決賽的項目。這是我原來的概念,你可以這裡讀的原型。操作時,你會選擇通過右側的選擇旋鈕一個自然靈感的主題,然後按「打印「按鈕,打印最新的崗位Instagram的根據您的選擇。

Inside, you’ll find an Arduino, a rotary switch, a button, and wireless Polaroid ZINK printer. The Arduino is powered by the USB cable that connects to it, and feeds the signal of the button and switch to a computer. The computer then uses Processing to query Instagram for a search based on with you selected using the dial. When someone pushes the ‘Print’ button, Processing saves the image to a folder, which uses an Apple script (thanks Brendan Dawes) to send the file wirelessly via Bluetooth to the printer, and that’s it!

裡面有一個 藍芽 相片印表機跟一個 arduino  ,連接USB去電腦,Processing.javascript 會去查詢 Instagram , 當你選擇 地點後 按列印 ( apple script ) 他會輸出一個 相片 圖

The concept was inspired by Instaprint.


delphi 日文網站

http://mrxray.on.coocan.jp/index.htm

http://www2.big.or.jp/~osamu/Delphi/Tips/key.cgi?key=25

http://d.hatena.ne.jp/nomnel/20111125/1322183069

http://www.geocities.jp/asumaroyuumaro/program/tips/gdiplus.html

http://dobon.net/vb/dotnet/graphics/transform.html

delphi 請問Timer如果不用拉元件產生的,該如何寫

type
  TDBThread = class(TThread)
  protected
    procedure PrintMsg;
    procedure Execute; override;
  end;
procedure TDBThread.Execute;
begin
  while Not Terminated do
  begin
    Synchronize(PrintMsg);
    Sleep(1500);
  end;
end;
procedure TDBThread.PrintMsg;
begin
  Form1.Memo1.Lines.Add(TimeToStr(Time) + ': Threading');
end;
procedure TForm1.FormShow(Sender: TObject);
begin
  DBThread := TDBThread.Create(False);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DBThread.Terminate;
  DBThread.WaitFor;
  DBThread.Free;
end;
攪個直執行緒Sleep(1500);就是你要它多久做一次(準一點 )

delphi runtime 取得panel下的可視元件 savetofile

delphi runtime 取得panel下的可視元件

procedure TForm1.AddToTreeView(ATreeNode: TTreeNode; APanel: TPanel);
var
  i: integer;
  TmpTreeNode: TTreeNode;
begin
  for i := 0 to APanel.ControlCount - 1 do
  begin
    TmpTreeNode := TreeView1.Items.AddChild(ATreeNode, APanel.Controls[i].Name);
    if APanel.Controls[i] is TPanel then
     AddToTreeView(TmpTreeNode, TPanel(APanel.Controls[i]))
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  tn, TmpTreeNode: TTreeNode;
begin
  tn := TreeView1.Items.Add(nil, Panel1.Caption);
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    TmpTreeNode := TreeView1.Items.AddChild(tn, Panel1.Controls[i].Name);
    if Panel1.Controls[i] is TPanel then
    begin
     AddToTreeView(TmpTreeNode, TPanel(Panel1.Controls[i]))
    end;
  end;
end; 











function MethodPropToStr: string;
  var
    Value: TMethod;
    Root: TComponent;
  begin
    Value := GetMethodProp(Instance, PropInfo);
    if Value.Code <> nil then
    begin
     if Instance is TForm then
     Root := TComponent(Instance)
     else
     Root := TComponent(Instance).Owner;
     Result := Root.MethodName(Value.Code);
    end else begin
     Result := '';
    end;
  end;

begin
  begin
    PropType := PropInfo^.PropType^;
    case PropType^.Kind of
     tkInteger, tkChar, tkEnumeration, tkSet:
     Result := OrdPropToStr;
     tkFloat:
     Result := FloatPropToStr;
     tkString,tkLString:
     Result := StrPropToStr;
     tkClass:
     Result := ClassPropToStr;
     tkMethod:
     Result := MethodPropToStr;
     else
     Result := 'Unknown';
    end;
  end;
end;

{TObjInfo}
constructor TObjInfo.Create(Instance: TObject);
begin
  HaveInstance:= False;
  if Assigned(Instance) then
  begin
    FInstance:= Instance;
    FName:= Instance.ClassName;
    ListUpProps(Instance);
  end;
end;

destructor TObjInfo.Destroy;
begin
  if HaveInstance then
    FreeMem(FPropList, PropCount * SizeOf(Pointer));

  inherited Destroy;
end;

function TObjInfo.GetItems(Index:Integer):TMyPropInfo;
var
  PropInfo: PPropInfo;
  PropType: PTypeInfo;
  PropName, PropValue: string;
begin
  PropInfo := FPropList^[Index];
  if PropInfo = nil then
  begin
    Raise Exception.Create('Invalid Index');
    Exit;
  end;
  PropName := PropInfo^.Name;
  Result.Name:= PropName;
  PropValue := PropValueToStr(TPersistent(FInstance),PropInfo);
  Result.Value:= PropValue;
  PropType := PropInfo^.PropType^;
  Result.Kind:= PropType^.Kind;
end;

function TObjInfo.IndexOfProp(const S:String):Integer;
var
  i:integer;
  St:TStringList;
begin
  St:=TStringList.Create;
  for i:= 0 to FCount -1 do
    St.Add(Self[i].Name);

  Result:= St.IndexOf(S);
  St.Free;
end;

procedure TObjInfo.ListUpProps(Instance:TObject);
begin
  FCount := GetTypeData(Instance.ClassInfo)^.PropCount;
  if FCount > 0 then
  begin
    GetMem(FPropList, FCount * SizeOf(Pointer));
    HaveInstance:= True;
    try
     GetPropInfos(Instance.ClassInfo, FPropList);
    except
    end;
  end;
end;

end.

unit DsnInfo;

// Runtime Design System Version 2.x June/08/1998
// Copyright(c) 1998 Kazuhiro Sasaki.

interface

uses
  Windows, Messages, SysUtils, Classes, Forms, Controls, Dialogs,
  TypInfo;

type

  TMyPropInfo = record
    Name:String;
    Value:String;
    Kind: TTypeKind;
  end;

  TObjInfo = class
  private
    FInstance:TObject;
    FName: String;
    FCount:Integer;
    FPropList: PPropList;
    HaveInstance:Boolean;
    procedure ListUpProps(Instance:TObject);
    function GetItems(Index:Integer):TMyPropInfo;
  public
    constructor Create(Instance: TObject);
    destructor Destroy; override;
    function IndexOfProp(const S:String):Integer;
    property Name:String read FName;
    property Items[Index:Integer]: TMyPropInfo read GetItems; default;
    property PropCount: Integer read FCount;
  end;

  function PropValueToStr(Instance: TPersistent;
     PropInfo: PPropInfo):string;

implementation

type
  TIntegerSet = set of 0..SizeOf(Integer) * 8 - 1;

function PropValueToStr(Instance: TPersistent;
     PropInfo: PPropInfo):string;
var
  PropType: PTypeInfo;

  function SetPropToStr(Value: Cardinal):string;
  var
    I: Integer;
    BaseType: PTypeInfo;
  begin
    BaseType := GetTypeData(PropType)^.CompType^;
    Result := '[';
    for I := 0 to 15 do
     if I in TIntegerSet(Value) then begin
     if Result <> '[' then
     Result := Result + ',';
     Result := Result + GetEnumName(BaseType, I);
     end;
    Result := Result + ']';
  end;

  function OrdPropToStr:string;
  var
    Value: Longint;
  begin
    Value := GetOrdProp(Instance, PropInfo);
    case PropType^.Kind of
     tkInteger:
     Result := IntToStr(Value);
     tkChar:
     Result := Chr(Value);
     tkSet:
     Result := SetPropToStr(Value);
     tkEnumeration:
     Result := GetEnumName(PropType, Value);
    end;
  end;

  function FloatPropToStr:string;
  var
    Value: Extended;
  begin
    Value := GetFloatProp(Instance, PropInfo);
    Result := FloatToStr(Value);
  end;

  function StrPropToStr:string;
  begin
    Result := GetStrProp(Instance, PropInfo);
  end;

  function ClassPropToStr:string;
  var
    Component: TComponent;
  begin
    if GetTypeData(PropInfo^.PropType^)^.ClassType.InheritsFrom(TComponent)
    then begin
     Component := TComponent(GetOrdProp(Instance, PropInfo));
     if Component = nil then
     Result := ''
     else
     Result := Component.Name;
    end else begin
     FmtStr(Result, '(%s)', [PropInfo^.PropType^.Name]);
    end;
  end;



必須引用一個別人寫的物件
只有以下是我寫的
//******************************************************************************
procedure TForm1.Button2Click(Sender: TObject);
//*********************************************
function objins(Sender: TObject):TStringList;
const
KindTYPE : array [0..17] of string =('Unknown','Integer', 'Char', 'Enumeration',
    'Float', 'String' , 'Set', 'Class', 'Method', 'WChar', 'LString', 'WString',
    'Variant','Array', 'Record', 'Interface', 'Int64', 'DynArray');
var
 AObjInfo : TObjInfo;
 i :Integer;
 S :String;
 STR :TStringList;
begin
AObjInfo := TObjInfo.Create(sender);
  STR:= TStringList.Create;
  //STR.Add('Object'+' '+AObjInfo.Name);
  //STR.Add(' '+'begin');
  for i := 0 to AObjInfo.PropCount-1 do begin
    S:=' ';
    if AObjInfo.Items[i].Value <> '' then begin //如果是空資料就不顯示
     S:=S+''+ AObjInfo.Items[0].Value;
     S:=S+'_'+ KindTYPE[Ord(AObjInfo.Items[i].Kind)];
     S:=S+'_'+ AObjInfo.Items[i].Name +' = '+ AObjInfo.Items[i].Value;
     S:=S+';';
     //+' , '+ IntToStr(Ord(AObjInfo.Items[i].Kind))
     STR.Add(S);
    end;
  end;
  //STR.Add(' '+'end');
  Result := STR ;
end;
//*********************************************
begin
  Memo1.Lines.Text :=objins(Sender).Text;
end;
//******************************************************************************

procedure TForm1.Button1Click(Sender: TObject);
//*********************************************
procedure AddToTreeView(ATreeNode : TTreeNode ; APanel: TPanel);
var
  i: integer;
  TmpTreeNode: TTreeNode;
begin
  for i := 0 to APanel.ControlCount - 1 do
  begin
    TmpTreeNode := TreeView1.Items.AddChildObject(ATreeNode, APanel.Controls[i].Name,APanel.Controls[i]);
    //TmpTreeNode := TreeView1.Items.AddChild(ATreeNode, APanel.Controls[i].Name);
    if APanel.Controls[i] is TCustomControl then
     AddToTreeView(TmpTreeNode, TPanel(APanel.Controls[i]))
  end;
end;
//*********************************************
var
  i: integer;
  tn, TmpTreeNode: TTreeNode;
begin
  tn := TreeView1.Items.Add(nil, Panel1.Caption);
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    TmpTreeNode := TreeView1.Items.AddChildObject(tn, Panel1.Controls[i].Name ,Panel1.Controls[i]);
    if Panel1.Controls[i] is TPanel then
    begin
     AddToTreeView(TmpTreeNode, TPanel(Panel1.Controls[i]))
    end;
  end;
end;
//******************************************************************************
procedure TForm1.TreeView1DblClick(Sender: TObject);
begin
  Button2Click(TObject(TreeView1.Selected.Data));
end;

Resizing Controls at run time

delphi runtime design library
delphi runtime library

MFC
CRectTracker
Resizing Controls at run time
http://www.codeproject.com/Articles/7771/Limit-CRectTracker-handles
http://www.codeproject.com/Articles/856/Resizing-Controls-at-run-time


TStretchHandle
http://www.torry.net/quicksearchd.php?String=tstretchhandle&Title=Yes
http://delphimaster.net/view/4-1125138258/all

http://neftali.clubdelphi.com/?p=269

The Runtime Design System Suite By Kazuhiro Sasaki.
Runtime Design System v.2.2 FWS 1051 Kb 27 May 1999
By Kazuhiro Sasaki. At runtime, your application users can do Moving Controls, Resizeing Controls, Deleting Controls, Creating Controls, Changing Property in the Object Inspector, Saving Controls and Loading Controls if you use the Runtime Design System. Moreover, you hardly need to do programming.
Fully functional
Source: Included
Exe-demo included
Download: D3 D4


Runtime Designer Component. called TSelectOnRuntime of Neftali (ClubDelphi.com) works on Lazarus


Using Delphi and Python together
Talk for the Australian Delphi User Group (ADUG), July and August 2001
-Andy Bulka
abulka@netspace.net.au

A simple Python evaluator:

Create a new Form
Drop a TMemo (or a TRichEdit)
Drop a TPythonGUIInputOutput 
for displaying Python's messages
Drop a TMemo for the source code
Drop a TPythonEngine
Connect the attribute IO of the 
TPythonEngine to the 
TPythonGUIInputOutput.
Connect the attribute Output of 
TPythonGUIInputOutput to 
the TRichEdit.
Drop a TButton and 
call it "Execute script"
Double-click on the button and add:

delphi 如何實現動態物件

delphi 如何實現動態物件  


有什方法可以在不知到物件數目的情況下
在執行時期動態產生物件
就像是ValArray一樣可以變大變小

1.宣告動態陣列, 例: edt: array of TEdit; 
2.設定動態陣列的長度, 例: SetLength(edt, 10);
3.動態 create 元件, 例:
var
  i: integer;
  
begin
  for i := 0 to 9 do
  begin
    edt[i] := TEdit.Create;
    edt[i].Parent := Form1;
    edt[i].Left := ...;
    edt[i].Top := ...;
  end;
end;
  
SetLength(edt, 10); 

它適合""非物件""的動態ㄝ
我看它的原始碼是利用記憶體抓取的方法
我有查到有一種物件TObjectList不知到這個行不行
或是更上層的Tlist也市不錯用的
  
 
我想會出現記憶體錯誤的情形在於重設陣列大小之前
還必須手動將不要用的 TEdit Free 掉
  
TObjectList 也是個很好的選擇!
  
就是要如何釋放掉ㄋ
用TEdit[i].free OR TEdit[i].Destroy
OR SetLength(TEdit,0) OR freeMem(@TEdit) OR......
前三種都是過嚕會出現"無效指標"

edt[i].Free;
edt[i] := nil;

FreeAndNil(edt[i]);

delphi 由滑鼠座標取得所在座標的字元位置

delphi 由滑鼠座標取得所在座標的字元位置 
1)
richedit 
由滑鼠座標取得所在座標的字元位置
(為了讓richedit在被dorpdrag時達到拖曳到插入貼上)

2)
richedit 不行輸入TAB怎辦

>1)
>richedit 
>由滑鼠座標取得所在座標的字元位置
>(為了讓richedit在被dorpdrag時達到拖曳到插入貼上)
 
 TRichEdit.GetCaretPos 函式可達到
 
>2)
>richedit 不行輸入TAB怎辦
 

 RichEdit1.WantTab := True;

delphi 取得不定物件的所有屬性 執行時期 如何取得 物件有哪一些 物件的屬性跟事件

delphi 
取得不定物件的所有屬性  

執行時期
如何取得
物件有哪一些

物件的屬性跟事件



Microsoft fax implementation


要怎樣呼叫The Microsoft fax client COM implementation interfaces
或者有人可以告訴我FAX程式 或是有Component 或是..... 

用 TurboPower 套件 , 內有 Fax 相關元件
網址: http://sourceforge.net/projects/tpapro/  

 tpapro_4_06.zip 解壓後有個 examples 目錄
http://sourceforge.net/projects/tpapro/
TurboPower Async Professional ~~~~ Brought to you by: tpsfadmin

examples 目錄下的 delphi 目錄有個 FaxServer.dpr


Microsoft send fax PowerShell Windows Fax server

http://www.codeproject.com/Articles/120638/G-Modem-Internet-



Windows 2000/XP offers two possibilities to send faxes programmatically, either by a COM-Object (faxcom.dll) or by an API (winfax.dll). The COM object also can be used in script languages like JScript, however, it isn't so flexible as the API. Through the API on the other hand you receive control over the sending process during sending. To be able to send faxes by a web page, I have written an ISAPI extension using the Fax-API.

To use the fax API you must use the corresponding header files and libraries from the Microsoft Platform SDK. You can download the Platform SDK under http://msdn.microsoft.com/download free of charge.

After it, you copy the ISAPI-Extension (FaxISAPI.DLL) and the necessary ASP files (default.asp, progress.asp and ready.asp) into the web folder. Now start the browser and enter the address to the web folder (e.g. "http://localhost/fax") and send a fax through the web page. 
The code of the FaxISAPI.DLL consists of three .cpp files. The file extension.cpp contains the functions for the ISAPI-Extension, upload.cpp contains the C++ class for the Upload, fax.cpp contains the C++ class for initializing the fax server and for sending faxes.
To inform the client about status information of the Upload and fax process, the ISAPI-DLL writes into a status file (this status file will be created in "c:\ winnt\temp" and the name of it corresponds to the Session ID + ".log"). 
The ASP file progress.asp is refreshed by the browser every second and the progress.asp reads the Status on the server from the status file.

The default.asp contains the HTML form to get the fax number from the user. The fax number then is passed to choosefile.asp. The file choosefile.asp contains the HTML form for the choice of the faxing file and calls the FaxISAPI.DLL at a "Submit" and opens simultaneously a new browser window by Javascript with the progress.asp. 

The CUpload class contains the methods for the Upload of exactly one file to a web server. The class writes the number of bytes written to the status file and also the length of the file. This status information is used by progress.asp to show a progress bar. The uploaded file is stored intermediately in the folder "c:\winnt\temp".
Faxing the uploaded file

CFax contains the methods for the Initializing/Deinitialising (Init, DeInit) of the fax service and the method for sending Fax documents (send). The method Init of the ISAPI.DLL is called when loading the DLL the first time, DeInit when unloading the DLL. The real sending process of the fax document is implemented in CFax::Send. The ISAPI-DLL finish its work and sends a Redirect to ready.asp to the browser after the fax was sent. Ready.asp then gives the user information about whether the fax could be successfully sent.
Conclusion
Through the fax API you can access all essential events of the fax service.


3G Modem Internet Dialer

Code Design
I have tried to keep everything as object oriented as possible so the code can be reusable and easy to maintain, because not all manufacturers use the same set of commands. I used factory design pattern to select the correct class to load dynamically depending on the installed modem. An instance of CDummyModem is first created, then the modem model is identified and the appropriate class is constructed for that modem.

Dialing
For dialing, there are two ways: either opening the "Huawei Connect - 3G Modem" port and issue a dial command, or letting RAS do the job for you. I took the easy way and used RAS to handle the dialing.

There are a lot of articles that talk about RAS functions in details, so I will not go deep in this. Also there are a lot of ready made classes that make using RAS functions easier but I thought of making my own.

To use CMyRas class, you will need to create an instance of CMyRas:

Hide   Copy Code
CMyRAS m_RAS;
Then you have to call the Initialize function passing a pointer to CWnd that will be receiving the events from the RAS callback function.

Hide   Copy Code
if(!m_RAS.Initialize(m_pEventWnd))
{
    //Error
    return FALSE;
}
Calling the Initialize function also retrieves a list of address book entries and their count. You can use GetEntriesCount to know the number of Address book entries and you can get entries by index by using GetEntry function.

Now you are ready to Dial using the function Dial, by passing the entry name that you want to dial, the user name, and the password.

To hang up a connection, just call HangUp.

Note: You need the modem to have the correct APN set or else the server will disconnect you.

Communicating with the Modem
Sending and reserving messages from the modem is straight forward, all you have to do is open the port for "HUAWEI Mobile Connect - 3G PC UI" and send your commands. If you open the modem port, you won't be able to use RAS for dialing.

I have added my own serial port class CSerial. All I needed is simply read/writing to the serial port. The CSerial Class has two threads; one for reading and one for writing. To use the class, make an instance of the class and call Initialize, which takes a pointer of CModem class to forward the received data from the port. Now you will need to open the port by calling Open function, Open function will also start reading and writing threads.

When you're done, call ShutDown to close the port and to end the threads.

Modem Events
Modem Traffic Status

Usually HUAWEI 3G modems, send their status to the "HUAWEI Mobile Connect - 3G PC UI". The DSFLOWRPT message informs us about connection status every two seconds. The received text on the serial port looks something like this:

Hide   Copy Code
^DSFLOWRPT:0000240E,00000000,00000000,00000000000AD023,00000000002FA192,0003E800,0003E800 
This is an explanation for what the numbers represent:

Hide   Copy Code
^DSFLOWRPT: N1, N2, N3, N4, N5, N6, N7 
        N1: Connection duration in seconds 
        N2: measured upload speed 
        N3: measured download speed 
        N4: number of sent data 
        N5: number of received data  
        N6: connection, supported by the maximum upload speed
        N7: connection, supported by a maximum download speed 
Using the information that is supplied from the DSFLOWRPT event, you can draw a graph showing your connection status (upload/download over time).

Note: This event is only sent when you are connected.

Signal Quality

Once there has been a signal level change, your modem will send a RSSI event. The RSSI event shows the current signal quality level. Usually it is between 0 to 31.

This table maps the RSSI value with the signal Quality:

Wording Blocks Percentages RSSI Decibels
Excellent [][][][][] 100 31 >-51
97 30 -53
94 29 -55
90 28 -57
87 27 -59
84 26 -61
Good [][][][] 81 25 -63
77 24 -65
74 23 -67
71 22 -69
68 21 -71
65 20 -73
Fair [][][] 61 19 -75
58 18 -77
55 17 -79
52 16 -81
48 15 -83
45 14 -85
Poor [][] 42 13 -87
39 12 -89
35 11 -91
32 10 -93
29 9 -95
26 8 -97
Very Poor [] 23 7 -99
19 6 -101
16 5 -103
13 4 -105
10 3 -107
6 2 -109
No Signal 3 1 -111
0 0 <-113 p="">
Some modems don’t send status events or signal quality events, the workaround would be creating a thread that would periodically query the modem for its status.

List of Common 3G Commands
Some commands can be used for querying or setting. To Query, you will need to append a “?”. To set, you will need to append a “=”. For example, to query for a modem for current APN, use the following command:

Hide   Copy Code
AT+CGDCONT?
To set the APN:

Hide   Copy Code
AT+CGDCONT=1,”IP”,”apn name”
AT Command Description
AT Get the modem's attention
ATI Get manufacturer information
AT+CGMI Get manufacturer information
AT+CIMI Get SIM IMSI number
AT+CGSN Get modem IMEI
AT^HWVER Get hardware version
AT^SYSINFO Get System information
AT+CSQ Get signal strength
AT+CGMR Print firmware version of the modem
ATZ Reset the modem back to default factory settings
AT+CFUN Get/Set operating mode
AT+CPIN Get/Set PIN
AT+CGDCONT Get/Set APN
AT^SYSCFG Get/Set System configuration
AT+CUSD Sending USSD Commands

Serial Programming/Modems and AT Commands
< Serial Programming
Serial Programming: Introduction and OSI Network Model -- RS-232 Wiring and Connections -- Typical RS232 Hardware Configuration -- 8250 UART -- DOS -- MAX232 Driver/Receiver Family -- TAPI Communications In Windows -- Linux and Unix -- Java -- Hayes-compatible Modems and AT Commands -- Universal Serial Bus (USB) -- Forming Data Packets -- Error Correction Methods -- Two Way Communication -- Packet Recovery Methods -- Serial Data Networks -- Practical Application Development -- IP Over Serial Connections


有關delphi輸入法 與系統 快速鍵 把Ctrl+SPACE關掉

[HKEY_USERS\.DEFAULT\Control Panel\Input Method]
"Show Status"="1"

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys]

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000010]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000011]
"Key Modifiers"=hex:04,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000012]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:be,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000070]
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000071]
"Key Modifiers"=hex:04,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:20,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000072]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:bc,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000200]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:47,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000201]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:4b,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000202]
"Key Modifiers"=hex:03,c0,00,00
"Target IME"=hex:00,00,00,00
"Virtual Key"=hex:4c,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000203]
"Virtual Key"=hex:56,00,00,00
"Key Modifiers"=hex:03,c0,00,00

"Target IME"=hex:00,00,00,00

如何抓取中斷 com port被中斷 Delphi + MSComm control serial port transceiver procedures communication

如何抓取中斷  com port被中斷


直接用 API 的話, 
可以參考范逸之、陳立元編著的<>一書
元件的話有微軟附的 MSComm(這個要 Import ActiveX)、SPComm 等
小弟則是用 TurboPower 的 TApdComport 元件


/ / Delphi + MSComm control serial port transceiver procedures 
/ / HotPower@126.com. 

to procedure TForm1.FormCreate (Sender: TObject); 
begin 
if MSComm1.PortOpen then MSComm1.PortOpen: = false ;/ / close the port 
MSComm1.CommPort: = 2 ;/ / set port 2 
Receive buffer MSComm1.InBufferSize: = 256 ;/ / set to 256 bytes 
MSComm1.OutBufferSize: = 256 ;/ / set the transmit buffer is 256 bytes 
MSComm1.Settings: = '9600, n, 8,1 ';/ / 9600 baud rate, no parity, 8 data bits, 1 stop bit 
MSComm1.InputLen: = 0 ;/ / read the entire contents of the buffer (32 bytes) 
MSComm1.InBufferCount: = 0 ;/ / clear the receive buffer 
MSComm1.OutBufferCount: = 0 ;/ / clear to send buffer 
MSComm1.RThreshold: = 32 ;/ / set to receive 32 bytes produce OnComm events 
/ / MSComm1.InputMode: = comInputModeText ;/ / text 
MSComm1.InputMode: = comInputModeBinary ;/ / binary mode 
MSComm1.PortOpen: = true ;/ / open ports 
end; 

procedure TForm1.FormCloseQuery (Sender: TObject; var CanClose: Boolean); 
begin 
if MSComm1.PortOpen then MSComm1.PortOpen: = false; ;/ / close the port 
end; 

to procedure TForm1.MSComm1Comm (Sender: TObject); 
var 
buffer: Olevariant ;/ / MSComm1.InputMode = comInputModeBinary 
str: string ;/ / MSComm1.InputMode = comInputModeText 
i: integer; 
begin 
case MSComm1.CommEvent of 
comEvReceive: / / serial receive event handler 
begin 
the if MSComm1.InputMode = comInputModeText read then / / character mode 
str: = MSComm1.Input / / read out automatically clear the receive buffer, str [1] ~ str [32] 
else / / binary mode to read 
buffer: = MSComm1.Input ;/ / read out automatically clear the receive buffer, buffer [0] to buffer [31] 
Edit3.Text: =''; 
for i: = 0 to MSComm1.RThreshold - 1 do / / 32 bytes Hex conversion 
begin 
if MSComm1.InputMode = comInputModeText then / / one-line character conversion 
Edit3.Text: = Edit3.Text + inttohex (byte (str [i + 1]), 2) + '' 
else / / single-line binary data conversion 
Edit3.Text: = Edit3.Text + inttohex (buffer [i], 2) + ''; 
end; 
Memo2.Lines.Add (Edit3.Text) ;/ / add a line display 
end; 
end; 
end; 

to procedure TForm1.BitBtn1Click (Sender: TObject); 
var 
i: integer; 
begin 
Edit4.Text: =''; 
for i: = 0 to 31 do 
begin 
MSComm1.Output: = char (i) ;/ / send a character 
Edit4.Text: = Edit4.Text + inttohex (i, 2) ;/ / displayed in hexadecimal characters 
end; 
Memo1.Lines.Add (Edit4.Text) ;/ / add a line display 

end;



[Html]
Add -> COM components -> the Mircrosoft Communications Control, version 6.0
The drag mscomm drag the dialog box,
Add variable m_comm
Add an event OnComm
  
void CtestDlg :: InitMsComm (void)
{
m_comm.put_CommPort (1); / / select COM1
m_comm.put_InBufferSize (1024); / / specify the receive buffer size
m_comm.put_OutBufferSize (1024) ;/ / specify the send buffer size
m_comm.put_InputLen (0); / / set the current reception area data length is 0, which means that all read
m_comm.put_InputMode (1); / / read and write data in binary mode
m_comm.put_Settings (L "9600, N, 8,1"); / / 9600 baud no parity bit, 8 data bits, 1 stop bit
the m_comm.put_RThreshold (1); / / receive buffer 1 and one or more characters, will lead to receive data OnComm event
try
{
m_comm.put_PortOpen (TRUE);
}
catch (...)
{
AfxMessageBox (L "serial port 1 open failed");
return;
}
m_comm.get_Input (); / / first read-ahead buffer to remove residual data
}
  
void CtestDlg :: OnCommMscomm1 ()
{
/ / =============== Serial data reception process ===================
the if (m_comm.get_CommEvent () == 2)
{
COleSafeArray SafeArray = m_comm. Get_Input (); / / first step
int iLen = SafeArray. GetOneDimSize (); / / The second step
The BYTE revBuf [1024];
for (long i = 0; i <   ILEN; i + +)
{
SafeArray.GetElement (& i, revBuf + i);
}
  
/ / RevBuf the processing
  
}
}
  
/ / ================ Send =================
  
void CtestDlg :: SendCommBuf (BYTE * pSendBuf, int count)
{
CByteArray m_Array;
m_Array.SetSize (count);
for (int i = 0; i <   count; i + +)
{
m_Array.SetAt (i, pSendBuf [i]);
}
m_comm.put_Output (COleVariant (m_Array));
}
  
void CtestDlg :: OnBnClickedButton1 () / / send sample
{
BYTE buf [3] = {0x11, 0x12, 0x13};
The SendCommBuf (buf);
}