Results 1 to 11 of 11

Thread: [RESOLVED] Windowless User Control

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Resolved [RESOLVED] Windowless User Control

    Hello all

    Doing a step back from c++ for a cool desktop app that will take over my current program browser app.

    I have a question regarding user controls.
    I have made a custom "key manager" class, which has global keydown, keyup, keypress events. It uses a thread in combination with a windows API to handle global key changes. This is the structure:
    Code:
    Public Class KeyManager
        Public Event KeyDown(ByRef s As KeyManager, ByVal key As Windows.Forms.Keys)
        Public Event KeyUp(ByRef s As KeyManager, ByVal key As Windows.Forms.Keys)
        Public Event KeyPress(ByRef s As KeyManager, ByVal key As Windows.Forms.Keys)
        Public ReadOnly Property GetKeyDown(ByVal key As Windows.Forms.Keys) As Boolean
        Public ReadOnly Property Control() As Boolean
        Public ReadOnly Property Shift() As Boolean
        Private c As Control
        Private sd As Integer = 0
        Private t As Threading.Thread
        Public Sub New(ByRef owner As Control, ByVal Checkdelay As Integer)
        Public Sub Dispose()
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal Key As Windows.Forms.Keys) As Boolean
        Private states(255) As Boolean
        Private special(2) As Boolean
        Private lastkeydown As Integer = -2
        Private Sub CheckLoop()
        Private Sub HandleKey(ByVal key As Windows.Forms.Keys)
        Private Delegate Sub dinvoke(ByVal type As KeyEvent, ByVal k As Windows.Forms.Keys)
        Private Sub invoke(ByVal type As KeyEvent, ByVal k As Windows.Forms.Keys)
        Private Enum KeyEvent
    End Class
    In the new sub the values are applied to c and sd and the thread (t) is started. Inside the checkloop it checks all 0 - 255 key chars and the 3 special key chars (alt, shift, control). These values are applied to the states(255) and special(2) arrays. if the value differs, it raises an event. This event is handled by a delegated sub so you won't get thread access errors in the receiving end.
    I can add the class as variable in my class, but I want to make it just like the timer, Errorprovider, Backgroundworker etc. standard windows usercontrols. In short, I want to have an user control that shows up in the bottom of the screen and which has no window.

    I guess I would have to inherit something, but it all causes crashes till now, as soon I drag/dropped the control into the field. (designer error)

    So, how can I make such an user control that has no window, just some events and properties?
    Last edited by bergerkiller; Jan 15th, 2011 at 04:22 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width