Article View: be.comp.programming
Article #6310VB6 Probleempje!!! (Het wilt mij maar niet lukken)
From: Kelly Smith
Date: Sun, 29 Dec 2002 05:57
Date: Sun, 29 Dec 2002 05:57
156 lines
6254 bytes
6254 bytes
Hoi Vakmensen,
Ik heb in VB6 een VIRTUEEL TOETSENBORD geprogrammeerd, waarmee tekst
geschreven kan worden met de muis.
Ik heb een probleem met de toetsen als ik met de muis klik in een vakje waar
ik wil schrijven met deze visuele toetsenbord.
De toetsenbord is OnTopMost. Ik klik dus met de cursor het vakje waar ik
tekst geschreven wil hebben, bijvoorbeeld het
adresbox in Internet Explorer. De cursor begint te knipperen en ik kan
schrijven denk ik, maar als ik begin te toetsen op de letters op de
virtuele toetsenbord stuurt hij geen tekst naar de adresbox. Nee, in
tegendeel, de toetsenbord wordt actief, en wordt meteen de voorste
window, en de knipperende cursor op adresbalk verdwijnt, dus wordt
de internetexplorer inactief window (op de achtergrond). Wat ik wil
bereiken is dat ik waar dan ook op klik (adresbalk) om wat letters in te
tikken, dat ik de hele tekst in een keer kan schrijven en niet steeds weer
moet klikken op de adresbalk om vervolgens mijn tweede letter toe te
voegen (overigens de eerste letter/cijfer wordt ook niet gestuurd naar de
previous window).
Kan iemand mij advies geven of het stukje code schrijven (toesturen) die ik
moet gebruiken om de toetsenbord te laten werken. Ik weet dat dit
verschrikkelijk MOEiLijK en VEEL WERK is, maar kom er echt
niet meer uit. Please, any Angel!!! Ik heb een stukje geprobeerd om te
schrijven, maar het wilt niet werken. Wat zou er mis kunnen zijn? Als het
met
��n Letter H lukt, lukt mij de rest ook.
Ik dank u hartelijk...
Ik heb in een Form, ��n Command Button gebruikt (Command1) en dit stuje
erin gedaan (ik heb ook een teksbestandje opgestuurd met daarin de Code,
KeyBoard.txt, wegens slordige tekst hier en voor de makkelijkheid):
Const VK_H = 72
Const KEYEVENTF_KEYUP = &H2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_TOPMOST = -1
Const INPUT_KEYBOARD = 1
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type KEYBDINPUT
wVk As Integer
wScan As Integer
dwFlags As Long
time As Long
dwExtraInfo As Long
End Type
Private Type GENERALINPUT
dwType As Long
xi(0 To 23) As Byte
End Type
Private Declare Function SendInput Lib "user32" (ByVal nInputs As Long, _
pInputs As GENERALINPUT, ByVal cbSize
As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As
Any, _
pSrc As Any, ByVal ByteLen As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan
As Byte, _
ByVal dwFlags As Long, ByVal
dwExtraInfo As Long)
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal
X As Long, _
ByVal Y As Long, ByVal cx As Long,
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal
lpWindowName _
As String) As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As
Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As
Long) As Long
Dim Pt As POINTAPI
Private Sub SendKey(bKey As Byte)
Dim GInput(0 To 1) As GENERALINPUT
Dim KInput As KEYBDINPUT
KInput.wVk = bKey
KInput.dwFlags = 0
GInput(0).dwType = INPUT_KEYBOARD
CopyMemory GInput(0).xi(0), KInput, Len(KInput)
KInput.wVk = bKey
KInput.dwFlags = KEYEVENTF_KEYUP
GInput(1).dwType = INPUT_KEYBOARD
CopyMemory GInput(1).xi(0), KInput, Len(KInput)
Call SendInput(2, GInput(0), Len(GInput(0)))
End Sub
Private Sub Command1_Click()
SendKey VK_H
End Sub
Private Sub Form_Activate()
Dim Ret As Long
Do
Ret = GetForegroundWindow()
DoEvents
Loop
End Sub
Private Sub Form_Load()
Dim lHandle As Long
lHandle = FindWindow("ThunderRT5Form", Me.Caption)
lHandle = SetForegroundWindow(lHandle)
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or
SWP_NOMOVE)
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
GetCursorPos Pt
Me.CurrentX = 0
Me.CurrentY = 0
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y
As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
HARTSTIKKE BEDANKT!!!!!!!!!!!!!!!!!!!!!!
Technical Details
Message-ID:
<19wP9.186418$4B2.21698845@amsnews03.chello.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!amsnews01.chello.com!amsnews03.chello.com.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII X-Google-Thread: fcea4,d5a3173933d3550e,start X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2002-12-28 21:57:41 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!amsnews01.chello.com!amsnews03.chello.com.POSTED!not-for-mail Reply-To: "Kelly Smith" <power@cable.a2000.nl> From: "Kelly Smith" <power@cable.a2000.nl> Newsgroups: be.comp.programming Subject: VB6 Probleempje!!! (Het wilt mij maar niet lukken) Lines: 158 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <19wP9.186418$4B2.21698845@amsnews03.chello.com> Date: Sun, 29 Dec 2002 05:57:17 GMT NNTP-Posting-Host: 62.108.15.164 X-Complaints-To: abuse@chello.com X-Trace: amsnews03.chello.com 1041141437 62.108.15.164 (Sun, 29 Dec 2002 06:57:17 MET) NNTP-Posting-Date: Sun, 29 Dec 2002 06:57:17 MET Organization: chello broadband