🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #6330

VB6 Probleempske!!!

#6330
From: Kelly Smith
Date: Wed, 01 Jan 2003 06:53
155 lines
6401 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, via adviezen van "Pieter Philippaerts". 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:



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, _
                                       ByVallpWindowName 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: <BfwQ9.11526$O24.780357@amsnews02.chello.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.wirehub.nl!amsnews01.chello.com!amsnews02.chello.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII
X-Google-Thread: fcea4,ca6fbb4a96e25439,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2002-12-31 22:53:28 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.wirehub.nl!amsnews01.chello.com!amsnews02.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 Probleempske!!!
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: <BfwQ9.11526$O24.780357@amsnews02.chello.com>
Date: Wed, 01 Jan 2003 06:53:21 GMT
NNTP-Posting-Host: 62.108.15.164
X-Complaints-To: abuse@chello.com
X-Trace: amsnews02.chello.com 1041404001 62.108.15.164 (Wed, 01 Jan 2003 07:53:21 MET)
NNTP-Posting-Date: Wed, 01 Jan 2003 07:53:21 MET
Organization: chello broadband