10929.html

来自「VB技巧问答10000例,是一个教程」· HTML 代码 · 共 42 行

HTML
42
字号
<html>
  <head>
    <title>**====== 拜托拜托! 传图问题, 希望大家帮我看一下程式 =======**</title>
  </head>
  <body bgcolor="#FFFFFF" vlink="#808080">
    <center>
      <h1>**====== 拜托拜托! 传图问题, 希望大家帮我看一下程式 =======**</h1>
    </center>
<hr size=7 width=75%>

<hr size=7 width=75%><p>
Posted by CK on March 14, 1999 at 03:13:10:<p>
我是想要把主机端的图送到使用者端后秀出, 当使用者开起程式并自动连上和接档后<br>按下 Commnd1 来把图秀出, 不过图都不正确, 有有人能帮我找出问题呢?<p>我想请大家帮我看一下....<br>因为每次使用者的一端接到的图都不正确<br>我应该怎样修正呢???<p>'------------------------------------------------------------------------------------------<br>'下面是主机端的程式<p>Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long<br>Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long<p><br>Private Type BITMAP<br>        bmType As Long<br>        bmWidth As Long<br>        bmHeight As Long<br>        bmWidthBytes As Long<br>        bmHeightBytes As Long<br>        bmPlanes As Integer<br>        bmBitsPixel As Integer<br>        bmBits As Long<br>End Type<p>Dim byteAry() As Byte<br>Dim byteAry1() As Byte<br>Dim byteAry2() As Byte<br>Dim totbyte As Long, totbyte1 As Long, totbyte2 As Long, I As Long, J As Long<p>Private Sub Form_Load()<br>      <br>      Winsock1(0).LocalPort = 5607<br>      Winsock1(0).Listen<br>      Load Winsock1(1)<p>End Sub<p>Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)<p> Dim hBitmap As Long<br> Dim res As Long<br> Dim bmp As BITMAP<br> Dim totbyte As Long, I As Long<br> hBitmap = Picture1.Image<p> Winsock1(Index + 1).Accept requestID<p> res = GetObject(hBitmap, Len(bmp), bmp)<p> totbyte = bmp.bmWidthBytes * bmp.bmHeight<p> ReDim byteAry(totbyte - 1)<br> res = GetBitmapBits(hBitmap, totbyte, byteAry(0))<p> Winsock1(1).SendData byteAry<br> DoEvents<p>End Sub<p>'------------------------------------------------------------------------------------------<br>'下面是使用者端的程式<p>Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long<br>Dim totbyte As Long<br>Dim byteAry1() As Byte<p><br>Private Sub Form_Load()<br>      <br>      Winsock1(0).RemoteHost = "207.171.241.146"<br>      Winsock1(0).RemotePort = 5607<br>      Winsock1(0).Connect<br>      totbyte = 0<p>End Sub<p>Private Sub Command1_Click()<p>  Dim Rval As Long<br>  Rval = SetBitmapBits(Picture2.Image, totbyte, byteAry1(0))<br>  Picture2.Refresh<p>End Sub<p>Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)<p>  ReDim Preserve byteAry1(totbyte)<br>  Winsock1(Index).GetData byteAry1(totbyte), vbArray + vbByte<br>  DoEvents<p>  totbyte = Winsock1(Index).BytesReceived<p>End Sub
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 10929-->
<!--top: 10960--><li><a href="10960.html">你只传Bitmap的Data过去,没有传Bitmap的Header(无内文)</a> <b>cww</b> <i>13:57:18 3/15/99</i>
(<!--responses: 10960-->3)
<ul><!--insert: 10960-->
<!--top: 10964--><li><a href="10964.html">Re: 那我该怎么做呢?(无内文)</a> <b>CK</b> <i>16:00:50 3/15/99</i>
(<!--responses: 10964-->2)
<ul><!--insert: 10964-->
<!--top: 10991--><li><a href="10991.html">存成.Bmp档案后再传出</a> <b>cww</b> <i>08:15:57 3/16/99</i>
(<!--responses: 10991-->1)
<ul><!--insert: 10991-->
<!--top: 11047--><li><a href="11047.html">Re: 存成.Bmp档案后再传出</a> <b>CK</b> <i>10:36:47 3/17/99</i>
(<!--responses: 11047-->0)
<ul><!--insert: 11047-->
</ul><!--end: 11047-->
</ul><!--end: 10991-->
</ul><!--end: 10964-->
</ul><!--end: 10960-->
<!--top: 10930--><li><a href="10930.html">Re: **====== 拜托拜托! 传图问题, 希望大家帮我看一下程式 =======**</a> <b>CK</b> <i>03:15:26 3/14/99</i>
(<!--responses: 10930-->0)
<ul><!--insert: 10930-->
</ul><!--end: 10930-->
</ul><!--end: 10929-->
<br><hr size=7 width=75%><p>

</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?