Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips > Additional Libraries
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.


dzEventsMagic


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-28-2007, 07:36 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default dzEventsMagic

Did you ever miss a B4PPC control event? This is the answer.

This library allows you to add more (missed) events to B4PPC controls.

Based on excellent code of the ".NET Compact Framework Team" found here http://blogs.msdn.com/netcfteam/arch...20/420551.aspx

Needs .NET 2.0 (don't forget MyApp.EXE.config file)

DLLs for desktop and device among with sample project (source and exe) are attached.

Windows Events list can be found here http://wiki.winehq.org/List_Of_Windows_Messages and here http://www.autohotkey.com/docs/misc/SendMessageList.htm

A useful windows spy application (Winspector) can be downloaded here http://www.windows-spy.com/

Sample code used to move a label on a form while pressing arrow keys
Code:
Sub Globals
 
End Sub
 
Sub App_Start
  'Add dzEventsMagic object and name it dzem
  dzem.New1("Form1", true)
 
  'Hook WM_KEYDOWN message
  dzem.Hook(256)
 
  Form1.Show
End Sub
 
Sub Form1_Close
  dzem.UnHook(256)
End Sub
 
Sub dzem_MagicEvent
  'Left Arrow
  If dzem.wParam = 37 Then
    label1.Text = "LEFT"
    If label1.Left > 0 Then
      label1.Left = label1.Left - 1
    End If
  End If
 
  'Up Arrow
  If dzem.wParam = 38 Then
    label1.Text = "UP"
    If label1.Top > 0 Then
      label1.Top = label1.Top - 1
    End If
  End If
 
  'Right Arrow
  If dzem.wParam = 39 Then
    label1.Text = "RIGHT"
    If label1.left < Form1.Width - label1.Width Then
      label1.Left = label1.Left + 1
    End If
  End If
 
  'Down Arrow
  If dzem.wParam = 40 Then
    label1.Text = "DOWN"
    If label1.Top < Form1.Height - label1.Height Then
      label1.Top = label1.Top + 1
    End If
  End If
End Sub
Attached Files
File Type: zip dzEVentsMagic.zip (60.6 KB, 248 views)
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #2 (permalink)  
Old 08-28-2007, 07:39 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,321
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

From what I could see, with this lib we can now raise an event upon a key stroke, correct?
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 08-28-2007, 07:46 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,700
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Great work dzt - I love it.
Reply With Quote
  #4 (permalink)  
Old 08-28-2007, 08:40 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,143
Default

Very nice job
Reply With Quote
  #5 (permalink)  
Old 08-29-2007, 01:57 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

One more sample. A completely locked TextBox

Code:
Sub Globals
 
End Sub
 
Sub App_Start
  'Add dzEventsMagic object and name it dzem
  'Set by default ReturnHandled parameter to true
  'just not to let message to reach the Hooked control
  dzem.New1("TextBox1", true)
 
  'Hook WM_KEYDOWN message
  dzem.Hook(256)
 
  'WM_CHAR
  dzem.Hook(258)
 
  'WM_PASTE
  dzem.Hook(770)
 
  'WM_CLEAR
  dzem.Hook(771)
 
  'WM_CUT
  dzem.Hook(768)
 
  Form1.Show
End Sub
 
Sub Form1_Close
  dzem.UnHook(256)
  dzem.UnHook(258)
  dzem.UnHook(770)
  dzem.UnHook(771)
  dzem.UnHook(768)
End Sub
 
Sub dzem_MagicEvent
  dzem.ReturnHandled = True
 
  'Allow Arrow Keys only
  'if dzem.msg = WM_KEYDOWN
  If dzem.msg = 256Then
    'if the key is an arrow key
    If dzem.wParam = 37 OR dzem.wParam = 38 OR dzem.wParam = 39 OR dzem.wParam = 40 Then
      'Let the TextBox1 control to handle these keys
      dzem.ReturnHandled = False
   End If
  End If
End Sub
Attached Files
File Type: sbp test4.sbp (1.4 KB, 61 views)
__________________
Dimitris Zacharakis
http://www.terracom.gr

Last edited by dzt : 08-29-2007 at 02:00 PM. Reason: add attachment
Reply With Quote
  #6 (permalink)  
Old 08-29-2007, 03:45 PM
Junior Member
 
Join Date: May 2007
Posts: 43
Default

Very useful .
As I make to know the values of wParam and lParam controlling.

magi6162
Reply With Quote
  #7 (permalink)  
Old 08-30-2007, 10:51 AM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Search using Google for every message of your interest (See message lists in my first post). Usually the first hit is an MSDN article describing the message.

Or/And download and install Winspector (see also my first post). Run it, and drag (while pressing CTRL key) the red circle with a cross to a control or window to see it's messsges. Detailed instructions here http://www.windows-spy.com/features/findwindow.shtml
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #8 (permalink)  
Old 09-01-2007, 07:47 AM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

And... one more sample. A clickable label showing how to add mouse events to controls using dzEventsMagic.

Code:
Sub Globals
  Dim Label1Clicked
End Sub
 
Sub App_Start
  'Add dzEventsMagic object and name it dzem
  'Set by default ReturnHandled parameter to false
  'so the message can be farther processed 
  dzem.New1("Label1", false)
 
 
  'Hook WM_LBUTTONDOWN
  dzem.Hook(513)
 
  'WM_LBUTTONUP
  dzem.Hook(514)
 
  Label1Clicked = false
 
 
  Form1.Show
End Sub
 
Sub Form1_Close
  dzem.UnHook(513)
  dzem.UnHook(514)
End Sub
 
Sub dzem_MagicEvent
  'WM_LBUTTONDOWN
  If dzem.msg = 513 Then
    label1.Color = 0,128,0
    label1.FontSize = 12
    Label1Clicked = true
  End If
 
 
  'WM_LBUTTONUP
  'This message fires for the Label only in PC
  If dzem.msg = 514 Then
    label1.Color = 0,255,0
    label1.FontSize = 9
  End If
 
End Sub
 
'Tip. In PPC WM_LBUTTONUP is received by the form, not the label
'So we catch Form MouseUp event to release label
Sub Form1_MouseUp (x,y)
  If Label1Clicked Then
    Label1Clicked = false
    label1.Color = 0,255,0
    label1.FontSize = 9
  End If
End Sub
Attached Files
File Type: sbp test4.sbp (1.4 KB, 48 views)
__________________
Dimitris Zacharakis
http://www.terracom.gr

Last edited by dzt : 09-01-2007 at 07:51 AM.
Reply With Quote
  #9 (permalink)  
Old 09-11-2007, 07:35 AM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hello Dimitris
Perhaps you are already aware of it, the label move demo works only under the condition that no input controls (numerical UpDn, Textbox, Image button) are on that form. MagicEvent does not fire in presence of input controls.
Cheers
Robert
Reply With Quote
  #10 (permalink)  
Old 09-11-2007, 09:12 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,700
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by alfcen View Post
MagicEvent does not fire in presence of input controls.
I am afraid that this isn't something that dzt can do anything about. Once a control that can receive the focus is placed on a form it gets the focus and the form ceases to see key presses.
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:19 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0