PLEASE HELP!!!!! WinMessage 
Author Message
 PLEASE HELP!!!!! WinMessage

Hello!
For my application I use number of Command buttons and Label as a Action
Result Display.
According to the customer I have to give him a possibility to activate any
of the command button by press a Key. To do so I would like to use a
Windows message to simulate the button click event . My application looks
like this:

Option Explicit

Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_LBUTTONDOWN = &HCB
Const WM_LBUTTONUP = &HCB

Private Sub Command1_Click()
  Label1.Caption = "Key was Pressed"
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
  SendMessage Command1.hwnd, WM_LBUTTONDOWN, 0, 0
  SendMessage Command1.hwnd, WM_LBUTTONUP, 0, 0
End Sub

Private Sub Form_Load()
  Label1.Caption = ""
  Form1.KeyPreview = True
End Sub

But I can not achive the disered result.

PLEASE SOMEBODY HELP ME WITH THIS PROBLEM!!!!
I DO NOT THINK THAT IT IS DIFFICULT FOR SUCH A GURU

Regards,
Alex



Mon, 08 Jan 2001 03:00:00 GMT  
 PLEASE HELP!!!!! WinMessage
Alexander,

    I would think that you should be able to set the keypreview property of
the form to true and then any keypresses you could trap the keys in the form
keypress event and then fire the appropriate click event. I hope this helps, I
don't have the time to actually try it myself but I did do something similar
when trying to trap a form level keypress.

John Cantley
First Chair Technologies

Quote:

> Hello!
> For my application I use number of Command buttons and Label as a Action
> Result Display.
> According to the customer I have to give him a possibility to activate any
> of the command button by press a Key. To do so I would like to use a
> Windows message to simulate the button click event . My application looks
> like this:

> Option Explicit

> Private Declare Function SendMessage Lib "user32" _
> Alias "SendMessageA" (ByVal hwnd As Long, _
> ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

> Const WM_LBUTTONDOWN = &HCB
> Const WM_LBUTTONUP = &HCB

> Private Sub Command1_Click()
>   Label1.Caption = "Key was Pressed"
> End Sub

> Private Sub Form_KeyPress(KeyAscii As Integer)
>   SendMessage Command1.hwnd, WM_LBUTTONDOWN, 0, 0
>   SendMessage Command1.hwnd, WM_LBUTTONUP, 0, 0
> End Sub

> Private Sub Form_Load()
>   Label1.Caption = ""
>   Form1.KeyPreview = True
> End Sub

> But I can not achive the disered result.

> PLEASE SOMEBODY HELP ME WITH THIS PROBLEM!!!!
> I DO NOT THINK THAT IT IS DIFFICULT FOR SUCH A GURU

> Regards,
> Alex




Tue, 09 Jan 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. WinMessage PLEASE HELP !!!!

2. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

3. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

4. PLEASE HELP PLEASE HELP PLEASE HELP

5. Design Help PLEASE PLEASE PLEASE!

6. Please Please PLEASE HELP!!!!!

7. URGENT HELP PLEASE PLEASE PLEASE???

8. Please please please, help me :-)

9. Please, Please, Please I need help working with dates

10. Please, please, please help!!

11. Cloning problem -- please please please help

12. Please, please, please, help!

 

 
Powered by phpBB® Forum Software