[.NET] 呼叫Windows API的問題

看板Visual_Basic作者 (Makoto)時間17年前 (2009/04/17 03:05), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
請輸入專案類型(網站專案或者應用程式專案):應用程式專案 我想在螢幕的左上角顯示時間 而且不會被全螢幕遊戲蓋過去 目前找到的方法是要先getDC在用drawtext等API對該DC寫字 可是我寫下去不是沒反應 要不然就是說是保護的記憶體,寫不進去 請問有哪位高手可以解決這個問題0.0 以下是我的程式碼 'API宣告 Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, ByVal lpRect As RECT, ByVal wFormat As Long) As Long '宣告部份 Private Structure RECT Dim Left As Long Dim Top As Long Dim Right As Long Dim Bottom As Long End Structure Private Const DT_CENTER = &H1 Private Const DT_WORDBREAK = &H10 '主程式碼部分 dc = GetDC(Me.Handle) Label1.Text = dc.ToString Dim lSuccess As Long Dim sPrintText As String Dim MyRect As RECT MyRect.Left = 0 MyRect.Right = 240 MyRect.Top = 180 MyRect.Bottom = 480 sPrintText = "Print this text" lSuccess = DrawText(dc, sPrintText, Len(sPrintText), MyRect, DT_CENTER Or DT_WORDBREAK) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.213.157
文章代碼(AID): #19vu6GSm (Visual_Basic)