CnPack Forum


 
Subject: 关于TCnRS232的建议(其实是spcomm的问题)
toysun
新警察
Rank: 1



UID 41468
Digest Posts 0
Credits 10
Posts 3
点点分 10
Reading Access 10
Registered 2008-12-15
Status Offline
Post at 2008-12-15 11:00  Profile | Blog | P.M. 
关于TCnRS232的建议(其实是spcomm的问题)

其实是spcomm的问题
1.StartComm方法中
hNewCommFile := CreateFile(PChar(CommName), GENERIC_READ or GENERIC_WRITE,
    0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0);
修改为
hNewCommFile := CreateFile(PChar('\\.\' + CommName), GENERIC_READ or GENERIC_WRITE,
    0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0);
{解决串口号大于10无法识别的问题}

2.CommWndProc中加上默认消息处理
procedure TCnRS232.CommWndProc(var Msg: TMessage);
begin
  case Msg.Msg of
    PWM_GOTCOMMDATA:
      begin
        ReceiveData(PChar(Msg.LPARAM), Msg.WPARAM);
        LocalFree(Msg.LPARAM)
      end;
    PWM_RECEIVEERROR: ReceiveError(Msg.LPARAM);
    PWM_MODEMSTATECHANGE: ModemStateChange(Msg.LPARAM);
    PWM_REQUESTHANGUP: RequestHangup;
    PWM_SENDDATAEMPTY: _SendDataEmpty;
    else
      with msg do //默认消息处理,解决win98无法正常退出问题
                        //(WM_QUERYENDSESSION和WM_ENDSESSION)
         Result := DefWindowProc(FHWnd, Msg, WParam, LParam);
  end;
end;
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2008-12-17 08:53  Profile | Blog | P.M. 
感谢楼主的报告。此建议已采纳,改动已并入最新的CVS代码。您可从CVS上获取最新代码来试一试。
Top
Redbreast
灌水科科长
Rank: 3Rank: 3



UID 679
Digest Posts 0
Credits 151
Posts 58
点点分 151
Reading Access 10
Registered 2005-2-2
Status Offline
Post at 2008-12-17 20:52  Profile | Blog | P.M. 
的确是一个老问题了,一直在打开串口的时候修改,呵呵,如果直接修改了,看来我还得修改我滴源码了:)
Top
 




All times are GMT++8, the time now is 2024-11-22 13:01

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007385 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP