13. marts 2002 - 00:21Der er
22 kommentarer og 1 løsning
OnScreen display text
Davs i hytten,
Jeg har nu i over en time forgæves forsøgt at finde en VB kode der kan generere noget tekst på skærmen via kode. Det skal vises sådan at hvis man f.eks. spiller et 3d spil bliver teksten vist ovenpå dette, ligesom ved de volume display der kommer frem når man har genvejstaster på keyboard'et.
Kan du hjælpe? Et søgeord, en sourcekode, et link... hvad som helst vil være en fin hjælp.
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Any, ByVal bErase As Long) As Long
Private Sub Form_Load() Timer1.Interval = 10 End Sub
Private Sub Form_Unload(Cancel As Integer) InvalidateRect 0, ByVal 0, 0 End Sub
Private Sub Timer1_Timer() Dim strString As String strString = "Cool, www.eksperten.dk" TextOut GetWindowDC(0), 10, 10, strString, Len(strString) End Sub
...har du et link, jeg vil da gerne se det. Men det gør heller ikke noget, for så har man svært ved at læse hvad der står... det kan iøvrigt godt være man kan vælge en baggrundsfarve der er transperant... men ved ikke lige how :)
Synes godt om
Slettet bruger
15. marts 2002 - 18:40#11
Det er sindsygt svært at læse, men her får du lige hele programmet...
Option Explicit
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, _ ByVal X As Long, ByVal Y As Long, _ ByVal lpString As String, _ ByVal nCount As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function GetRgnBox Lib "gdi32" (ByVal hRgn As Long, lpRect As RECT) _ As Long
Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) As Long Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, _ ByVal hSrcRgn1 As Long, _ ByVal hSrcRgn2 As Long, _ ByVal nCombineMode As Long) As Long
Private Const RGN_AND = 1 Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SetWindowRgn Lib "user32" _ (ByVal hwnd As Long, ByVal hRgn As Long, _ ByVal bRedraw As Boolean) As Long
Private Function GetTextRgn() As Long Dim hRgn1 As Long, hRgn2 As Long Dim rct As RECT
'Create a path for the window's shape BeginPath hdc TextOut hdc, 0, 0, "You've got mail", Len("You've got mail") EndPath hdc
'... Convert the path to a region... hRgn1 = PathToRegion(hdc) GetRgnBox hRgn1, rct hRgn2 = CreateRectRgnIndirect(rct) CombineRgn hRgn2, hRgn2, hRgn1, RGN_AND 'Return the region handle DeleteObject hRgn1 GetTextRgn = hRgn2 End Function
Private Sub Form_DblClick() 'Need to be able to close the form Unload Me End Sub
Private Sub Form_Load() Dim hRgn As Long Me.Font.Name = "Tahoma" Me.Font.Size = 24 Me.FontBold = True
hRgn = GetTextRgn() SetWindowRgn hwnd, hRgn, 1 End Sub
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Når du kører scriptet... bruger programmet så ikke mere og mere ram? Hos mig der stiger den hele tiden for tilsidst næsten at "crashe" maskinen. (lukker dog bare med Ctrl+alt+del)
Hmm, det fungerer ellers fint her, bortset fra at det blinker når spil kører med høj framerate, og så suger den ca. 1 mb ram hvert 10 sekund... :) det kan jeg ikke bruge til noget
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.