Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Any way to generically detect a click anywhere?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-2008, 10:12 PM
Newbie
 
Join Date: Jun 2008
Posts: 3
Default Any way to generically detect a click anywhere?

I'm currently working on a form that will have a scrolling list of records but each record can have different types of information. I plan on creating panels on the fly, one panel per record; filling them with labels, which may even be multiline; then using the ControlsEx scrollbar to adjust the .top of each panel (as well as .height and .show/.hide) to simulate a scrolling list.

The problem I'm having is that I need to be able to click anywhere on these panels to select one record which will then go to another form for editing that record. My initial ideas were to create a button over each panel set to transparent so that the underlying labels would show, or to make the labels disabled and use the click event of the underlying panel to detect a click. Neither of these seem work. Lastly, I thought of trying to detect a generic click and comparing the x/y positions with the bounds of all the displayed panels but I can't find a way to do this either.

Failing these options, I could change every label into a button and hook the click event of every button and the underlying panel into the same function but this seems a bit of overkill for what I'm trying to do. Anyone have any other ideas?

This is for use on a PPC running WM6.

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 07-02-2008, 10:50 PM
Senior Member
 
Join Date: Apr 2007
Location: Copenhagen
Posts: 142
Default

I believe you can detect the x/y coordinates by using the door library (see e.g. this thread: get x,y when over control)

An alternative which I have used is to actually only employ a small number of labels with fixed positions, and just change the content of the labels instead of actually creating a large number of labels/panels.

all the best / Björn
Reply With Quote
  #3 (permalink)  
Old 07-03-2008, 12:20 AM
Newbie
 
Join Date: Jun 2008
Posts: 3
Default

Quote:
Originally Posted by BjornF View Post
I believe you can detect the x/y coordinates by using the door library (see e.g. this thread: http://www.basic4ppc.com/forum/questions-help-needed/2517-get-x-y-when-over-control.html)
I was hoping to avoid attaching an event to every object on my form, but if all else fails, this is what I'll have to go with.

Quote:
Originally Posted by BjornF View Post
An alternative which I have used is to actually only employ a small number of labels with fixed positions, and just change the content of the labels instead of actually creating a large number of labels/panels.
This is a good idea and I might use it in another part of my program but it won't work in this case. Here, some of my records contain only 1 label while others can have as many as 20 on multiple lines.
Reply With Quote
  #4 (permalink)  
Old 07-19-2008, 12:16 AM
Newbie
 
Join Date: Jun 2008
Posts: 3
Default

I had set this problem aside while I worked on some other things, but now that I've come back to it, I found a solution. So for anyone who needs something similar, here it is.

Using dzEventsMagic, I hooked event #512 (WM_MOUSEFIRST) then simply read off the lParam when the event is fired. lParam is a 4 byte value where the low 2 bytes are the X coord and the high 2 bytes are the Y coord. This will detect a "click through" of an enabled label on the form/panel that is hooked. (Note that the desktop version will detect a click through only if the label is DISABLED, while the device version will detect on ENABLED labels only)

Code:
' Create a form "form1" including a panel "panel1" and a label "label1"
' label1 should be parented to panel1 and placed inside panel1
Sub App_Start
	' dzem is a dzEventsMagic object
	dzem.New1("Panel1", true)
	dzem.Hook(512) 'WM_MOUSEFIRST
	Form1.Show
End Sub

Sub dzem_MagicEvent
	'yes i know this is ugly, should use bitwise functions
	label1.Text = Int(dzem.lParam/65536,0) & " x " & dzem.lParam-Int(dzem.lParam/65536,0)*65536
End Sub

Sub Form1_Show

End Sub

Sub Form1_Close
	dzem.Unhook(512)
End Sub

Clicking on the panel (or the label) will show the clicked coordinates within the panel. (Again, note that if on the desktop, the label must be DISABLED for this to work properly. On the device, the label must be ENABLED)

So back to my original problem. I can simply make a panel for each "row" of data, fill it with appropriate labels, and hook the entire panel to detect clicks on that panel. Then move/hide the panels as necessary based on the scrollbar and I now have a custom made scroll box.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
detect shift, alt and ctrl keys micro Questions & Help Needed 7 07-30-2008 09:05 AM
Detect ActiveSync connection Lasse Questions & Help Needed 2 07-27-2008 09:51 AM
How to detect which is PPC and PPC Phone? conf Questions & Help Needed 6 07-31-2007 07:09 PM
How to detect whether SIP is active / not? belotrei Questions & Help Needed 5 06-01-2007 05:22 PM
GPS Port Auto Detect derez Share Your Creations 0 05-12-2007 07:38 PM


All times are GMT. The time now is 02:01 PM.


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