Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > RegisterHotKey (no form)


Reply
 
Thread Tools Display Modes
  #1  
Old 04-03-2004, 06:14 PM
darkforcesjedi's Avatar
darkforcesjedi darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default RegisterHotKey (no form)


registerhotkey wants an hWnd, but I don't have a form. How do I get an hWnd for my program if it doesn't have a form?
Reply With Quote
  #2  
Old 04-03-2004, 06:21 PM
toni_chgo toni_chgo is offline
Newcomer
 
Join Date: Mar 2004
Posts: 17
Default

ret = RegisterHotKey(Me.hWnd, &HBFFF&, MOD_CONTROL, vbKeyT)

if you don't have a handle you may get it with:
handle = GetForegroundWindow 'Get Active Window handle
ret = RegisterHotKey(handle, &HBFFF&, MOD_CONTROL, vbKeyT)
Reply With Quote
  #3  
Old 04-03-2004, 06:22 PM
darkforcesjedi's Avatar
darkforcesjedi darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

...my form has NO windows...does that matter?

Edit: I mean program, not form...i have no form

Last edited by darkforcesjedi; 04-03-2004 at 06:28 PM.
Reply With Quote
  #4  
Old 04-03-2004, 06:55 PM
toni_chgo toni_chgo is offline
Newcomer
 
Join Date: Mar 2004
Posts: 17
Default

it's doesn't matter
A window have to be active, that's the handle the function'll trap
Reply With Quote
  #5  
Old 04-03-2004, 11:02 PM
darkforcesjedi's Avatar
darkforcesjedi darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

I tried it with GetForegroundWindow, GetActiveWindow, and GetDesktopWindow. None of them worked.
Reply With Quote
  #6  
Old 04-04-2004, 03:23 AM
wakjah's Avatar
wakjah wakjah is offline
Senior Contributor
 
Join Date: Jan 2004
Location: Home
Posts: 1,170
Default

you have to declare the getforegroundwindow function:
Code:
Private Declare Function GetForegroundWindow Lib "user32" () As Long
__________________
wakjah

<wittySentence/>
Reply With Quote
  #7  
Old 04-05-2004, 08:39 PM
darkforcesjedi's Avatar
darkforcesjedi darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

I know how to use APIs. It didn't work.
Reply With Quote
  #8  
Old 04-06-2004, 04:47 PM
Merrion's Avatar
Merrion Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default

Create a hidden static window with CreateWindow and use that.
Reply With Quote
  #9  
Old 04-06-2004, 10:23 PM
Gilad_r's Avatar
Gilad_r Gilad_r is offline
Senior Contributor
 
Join Date: Mar 2004
Posts: 851
Default

@ Merrion
how can he create a static window without a form to put it there?
don't you have to specify a parent window

@ darkforcesjedi
my advise: just place an extra form in your app...
if you're really keen on not creating anything you can use GetDesktopWindow to get a handle and subclass it to check for the hotkey...
Reply With Quote
  #10  
Old 04-07-2004, 02:11 AM
Merrion's Avatar
Merrion Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default

Use CreateWindowEx as per how it was done in this article
Reply With Quote
  #11  
Old 04-07-2004, 01:24 PM
darkforcesjedi's Avatar
darkforcesjedi darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

Quote:
Originally Posted by Gilad_r
@ Merrion
how can he create a static window without a form to put it there?
don't you have to specify a parent window

@ darkforcesjedi
my advise: just place an extra form in your app...
if you're really keen on not creating anything you can use GetDesktopWindow to get a handle and subclass it to check for the hotkey...
I was trying to avoid using a form because I wanted to reduce the amount of memory the program uses. I just looked and saw it doesn't make much of a difference either way.
Reply With Quote
  #12  
Old 04-08-2004, 02:59 AM
Merrion's Avatar
Merrion Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default

Quote:
how can he create a static window without a form to put it there?
With the CreateWindowEx API call.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a main form using MDI form and Child form shevagol Interface and Graphics 5 09-21-2003 01:30 PM
Form navigation/position preservation MrCreosote Excel 2 09-10-2003 08:27 AM
Flexgrid form result based on login form Gigabyte Database and Reporting 4 12-14-2002 09:21 AM
Refresh A Pop-Up Form davencharleston Database and Reporting 0 12-11-2002 07:51 AM
Dynamic Form Events vbtester Interface and Graphics 13 07-19-2002 03:54 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->