win_equip.cpp

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <genstub.c>

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{

   switch (uMsg)
   {
         case WM_COMMAND:
               switch ( LOWORD( wParam ) )
               {
                     case IDM_TEST:
                     {
                           SYSTEM_INFO si;
                           char        szBuffer[128];
                           HDC         hDC = GetDC( hWnd );

                           GetSystemInfo( &si );
                           // Report system info.
                           wsprintf( szBuffer, "OEM Id: %X, Addr Range %lX-%lX",
                                     si.dwOemId, si.lpMinimumApplicationAddress,
                                     si.lpMaximumApplicationAddress);
                           TextOut( hDC, 0, 0, szBuffer, lstrlen(szBuffer ) );
                           wsprintf( szBuffer, "Page Size: %lX, Allocation: %lX",
                                     si.dwPageSize, si.dwAllocationGranularity );
                           TextOut( hDC, 0, 20, szBuffer, lstrlen(szBuffer ) );
                           // Just test for Intel x86 chips. Windows 95 does not run
                           // on the RISC-based architectures.
                           wsprintf( szBuffer, "Type of Processor: %s",
                                   ( si.dwProcessorType == PROCESSOR_INTEL_386 ) ?
                                   "386" :
                                   ( ( si.dwProcessorType == PROCESSOR_INTEL_486 ) ?
                                   "486" : "PENTIUM" ) );
                           TextOut( hDC, 0, 40, szBuffer, lstrlen(szBuffer ) );
                           ReleaseDC( hWnd, hDC );
                           return 0;
                     }
                     break;
                     case IDM_EXIT:
                           DestroyWindow( hWnd );
                           break;
               }
               break;
               case WM_DESTROY:
                     PostQuitMessage( 0 );
               break;
         default:
               return (DefWindowProc(hWnd, uMsg, wParam, lParam));
   }
   return (NULL);
}

``` Public Class FormInOut Dim TempStr As String ' 一時文字列 Private Sub FormInOut_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim SerPort As Integer = Spec(30) Barcode_Comm.BaudRate = 9600 'Barcode_Comm.Parity = IO.Ports.Parity.Even Barcode_Comm.Parity = IO.Ports.Parity.None Barcode_Comm.DataBits = 7 Barcode_Comm.StopBits = IO.Ports.StopBits.One Barcode_Comm.PortName = "COM" & SerPort Barcode_Comm.Handshake = IO.Ports.Handshake.RequestToSend If Barcode_Comm.IsOpen = True Then Barcode_Comm.Close() ElseIf Barcode_Comm.IsOpen = False Then Barcode_Comm.Open() End If End Sub Delegate Sub RecvDataDelegate(ByVal RecvStr As String) Private Sub RecvData(ByVal RecvStr As String) LaRecv.Text = RecvStr BarCodePub = RecvStr BarCodeFlag = 1 End Sub Private Sub Barcode_Comm_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Barcode_Comm.DataReceived Dim Recv As New RecvDataDelegate(AddressOf RecvData) Dim strReceived As String Try ' 受信データ読込 strReceived = Barcode_Comm.ReadExisting() ' 受信文字列結合 TempStr = TempStr + strReceived ' CR受信(受信完了) If strReceived(strReceived.Length - 1) = vbCr Then ' CR削除 TempStr = TempStr.Remove(TempStr.Length - 1, 1) ' TextBox1からInvoke Invoke(Recv, TempStr) ' 一時文字列初期化 TempStr = "" End If Catch ex As Exception MessageBox.Show(ex.Message, "受信エラー", _ MessageBoxButtons.OK, _ MessageBoxIcon.Error, _ MessageBoxDefaultButton.Button3) End Try End Sub End Class```VB.NET 编写,将在窗体Equipment下重新设置Barcode_comm类和参数设置并打开端口,在FormInout窗体处理事件数据接收和TEXTBOX1显示
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值