如何在Web浏览器上绘制矩形

时间:2014-03-06 00:21:22

标签: vb.net

我正在尝试绘制一个Web浏览器对象,但它没有显示。它显示在表单上,​​但拒绝显示在浏览器上。这是我的代码:

Public Class Form1
    Dim x As Integer
    Dim y As Integer
    Dim frameWidth As Integer = Me.Size.Width
    Dim frameHeight As Integer = Me.Size.Height
    Dim pen As New Pen(Color.Blue)
    Dim graphics As Graphics = Me.CreateGraphics
    Dim WithEvents htmldoc As HtmlDocument

Private Sub htmldoc_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles htmldoc.MouseMove
    x = e.MousePosition.X
    y = e.MousePosition.Y
    Dim rectangleOne As Rectangle = New Rectangle(10, 10, 100, 100)
    graphics.DrawRectangle(pen, rectangleOne)
End Sub

Private Sub webBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles webBrowser.DocumentCompleted
    htmldoc = webBrowser.Document
End Sub
End Class

感谢您的所有帮助伙伴!

1 个答案:

答案 0 :(得分:0)

很遗憾,图形不能在html文档和Web浏览器上写。 您可以使用外部html文件创建该文件,但不使用图形。 将此代码添加到您的项目中:

$token = "";
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://discordapp.com/api//channels/662616705377370133/invites",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_SSL_VERIFYPEER => 0,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer ".$token,
        "Cookie: __cfduid=d5328aab82fd65695e578067eaca635c21585584811; locale=en-US; __cfruid=6568c89bbddf7c987536ec8941a6c5d65ec40c30-1585587067"
    ),
));

$response = curl_exec($curl);
if(curl_error($curl)){
    echo "Error" . curl_error($curl);
}
curl_close($curl);
echo $response;

在可执行文件目录中创建一个名为“ index.html”的html文件,并将其写入:

{"message": "401: Unauthorized", "code": 0}

希望对您有帮助