Results 1 to 15 of 15

Thread: how can i use ctrl+esc in vb6?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    how can i use ctrl+esc in vb6?

    can i ask a question?
    how can i use ctrl+esc in vb6?
    in my form i have image,label,and buttons.
    do have any solutions

    tnx!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: how can i use ctrl+esc in vb6?

    Moved from CodeBank forum (which is for code examples, not questions)

  3. #3
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: how can i use ctrl+esc in vb6?

    basti42,

    Welcome to the forum.

    Feel free to ask any question that you want.

    We're all here to help, but I think we need a little more information.

    What are you trying to do. Check for ctrl+esc or send the keys ? Pressing ctrl+esc normally brings up the start menu.
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Arrow Re: how can i use ctrl+esc in vb6?

    tnx to you Keith_VB6,
    what i mean is i'm doing a project mini windows
    that's why i'm asking how to code the ctrl+esc
    pls. reply tnx.

  5. #5
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: how can i use ctrl+esc in vb6?

    I'm still not sure what you mean. Please explain in more details. What do you mean by "code the ctrl+esc" ?

    If you want to send CTRL-Escape then this code does that. Just add a command button.
    VB Code:
    1. 'API declaration
    2. Private Declare Sub keybd_event Lib "user32" _
    3.    (ByVal bVk As Byte, _
    4.     ByVal bScan As Byte, _
    5.     ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    6.  
    7. 'constants
    8. Const VK_ESCAPE = &H1B
    9. Const VK_CONTROL = &H11
    10. Const VK_KeyDown = 1
    11. Const VK_KeyUp = 3
    12.  
    13. Private Sub Command1_Click()
    14. 'Simulate Key Press
    15.     keybd_event VK_CONTROL, 0, VK_KeyDown, 0
    16.     keybd_event VK_ESCAPE,0, VK_KeyDown, 0
    17.  
    18. 'Simulate Key Release
    19.     keybd_event VK_ESCAPE, 0, VK_KeyUp, 0
    20.     keybd_event VK_CONTROL,0, VK_KeyUp, 0
    21. End Sub
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: how can i use ctrl+esc in vb6?

    tnx for your prompt reply
    i have a project its a mini-windows
    if i press ctrl+esc it will show the form.

  7. #7
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: how can i use ctrl+esc in vb6?

    i have a project its a mini-windows
    if i press ctrl+esc it will show the form.
    I still don't understand. What do you need help doing ? Do you want the from to be displayed when you press CTRL-Escape ?

    If that's what you want then do then do a search for "sethotkey". It involves sub-classing, which I have problems with. I usually crash the IDE. I use a sub-classing control that I got sooo long ago that I don't know where it came from.

    A non-subclassing way would be to add a timer, interval set to a second or less. Check for the key and then show the form. And here's some sample code.
    VB Code:
    1. Option Explicit
    2. Const VK_ESCAPE = &H1B
    3. Const VK_SHIFT = &H10
    4.  
    5. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    6.  
    7.  
    8. Private Sub Form_Load()
    9.     Me.Visible = False
    10. End Sub
    11.  
    12.  
    13. Private Sub Timer1_Timer()
    14.     If (GetAsyncKeyState(VK_SHIFT) = -32768) Then
    15.         If (GetAsyncKeyState(VK_ESCAPE) = -32768) Then
    16.             Me.Visible = True
    17.         End If
    18.     End If
    19. End Sub

    This code checks for shift+escape, because it doesn't trap the key like a hotkey, so if it was ctrl-escape the start menu would popup at the same time.

    The hotkey would be a better approach, maybe someone else could post some code and then we would both learn. I know it takes RegisterHotKey(), UnRegisterHotkey(), CallWindowProc() and SetWindowLong(). But as I said earlier, sub-classing crashes for me.
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how can i use ctrl+esc in vb6?

    Urgh. Yes, subclassing is a lot better.

    We do have a servicable Search facility in these forums.

    RegisterHotkey example

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: how can i use ctrl+esc in vb6?

    hello penagate!
    the code is good, but could you give me an example that
    instead of pressing ctr+shift+F10 replace it with ctrl+esc,
    i tried but the start button of windows appears not
    my application.
    tnx!

  10. #10
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: how can i use ctrl+esc in vb6?

    Quote Originally Posted by basti42
    hello penagate!
    the code is good, but could you give me an example that
    instead of pressing ctr+shift+F10 replace it with ctrl+esc,
    i tried but the start button of windows appears not
    my application.
    tnx!
    Ctrl + Esc like ATl + Tab and CTR+ALT + Del is reserved for use by Operating System. It won't be a good idea to use Ctrl + Esc in your applications. Use some other key combination.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how can i use ctrl+esc in vb6?

    If Windows Explorer is not set as the desktop shell application then you should be able to use Ctrl+Esc. The only issue is that it is already registered by Explorer. Same with Alt+Tab. Ctrl+Alt+Del however is a low-level hotkey combination which is handled by the kernel, not the shell.

  12. #12
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Lightbulb Re: how can i use ctrl+esc in vb6?

    Basti42, the code in Post#5 answers your question.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: how can i use ctrl+esc in vb6?

    i already tried rory...
    but still the start button of windows appears
    tnx

  14. #14
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: how can i use ctrl+esc in vb6?

    Quote Originally Posted by basti42
    i already tried rory...
    but still the start button of windows appears
    tnx
    it will as stated by others .. it is reserved for that while in the Explorer.exe shell ..

  15. #15
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: how can i use ctrl+esc in vb6?

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

    If that value is "explorer.exe", you cannot use Ctrl+Esc. If it is not, you can, but you lose the desktop, taskbar, and task switcher.

    Capeesh?

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