Page 2 of 6 FirstFirst 123456 LastLast
Results 16 to 30 of 79
  1. #16
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Hello,



    The thread has developed quite extensively and I should take some time to digest what is being offered.

    In regards to the actual use case of my problem:

    I am writing a function to set a "drop down" search on any given textbox object. Go to the top of your browser and begin searching in your chrome browser (or any browser created in the last 20 years) you'll see what I am trying to develop - a recent search type of dropdown that is "queried" on change. Because Access offers no native solution to make this even remotely easy, I must use a listbox and do some code magic.

    To answer your question in your head at the current time: No a combobox wont work - Because the arrow is disgusting and there is no clean way to remove it. Nonetheless, its just inferior to a listbox in this problem.

    Getting the listbox to drop on the textbox object right below it is the easy part. The difficult part is selecting the items in the listbox as the cursor "hovers" over this. The only solution to my knowledge at the current time is to manually input AT LEAST ONE XY cordinate for the textbox and in conjuction use the XY cordinate grabber on a mousemove event. The rest of the items can be calculated easily based on textsize.

    Suppose I am desiring to implement this code on many textbox objects throughout my project, I'd prefer not to waste my time with having to hard-code the XY cordinates of the listbox, as that is cumbersome



    I slapped this together and works OK with some glitches but works by passing one XY arg:

    Code:
    
    
    Private Sub lbTest_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call listboxSelector(lbTest, GetYCursorPos, 314)
    End Sub
    
    
    ---------------------
    
    
    Private Sub listboxSelector(lbox As ListBox, YCursorPos As Long, yTop As Long)
    Dim txtSizePixConst       As Long
    Dim i                            As Integer
    Dim ArrPos()                 As Variant
    
    
    txtSizePixConst = 15
    
    
    If lbox.ListCount = 0 Then Exit Sub
    
    
    ReDim ArrPos(1 To lbox.ListCount)
    For i = 1 To lbox.ListCount
        ArrPos(i) = (i * txtSizePixConst) + yTop
    Next
    
    
    For i = 1 To lbox.ListCount
    
    
            Select Case i
                Case 1
                    If YCursorPos >= yTop Then
                        lbox.Selected(i) = True
                    End If
                Case 2 To lbox.ListCount
                    If YCursorPos >= ArrPos(i - 1) And YCursorPos <= ArrPos(i) Then
                        lbox.Selected(i) = True
                    End If
            
            End Select
    Next

    I looked at isladogs code and saw no reference to any XY API, so I dismissed it as just .TOP / .LEFT properties being used for whatever his application served as.

    I did not take into account the purpose of the database so I will revisit it with a more thorough check and see if I can make it work for my needs. Will report back.

    Thank you all.

  2. #17
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Because the arrow is disgusting and there is no clean way to remove it.
    How about a "dirty" way?
    Click image for larger version. 

Name:	cmbHappyFace.jpg 
Views:	39 
Size:	4.7 KB 
ID:	37357 Click image for larger version. 

Name:	cmbHappyFace2.jpg 
Views:	39 
Size:	4.7 KB 
ID:	37358
    Before you jump to convulsions, that's not really just a combo.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #18
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Hi Micron,

    Does the smiley cover the arrow? ...PS that smiley is ugly! My smileys are better! (just kidding)... I considered the option of covering the arrow with a blank rect but I felt it would be cumbersome. Welcoming your thoughts. When you say not really just a combo... is a text + combo?

    But....

    I return with some good news. I dismissed isladogs code far too quickly. And because of that, I do apologize to the man!

    You will find an attached database. This compares very easily with labels - isladogs code vs mouse API code. (By the way - you can do some absolutely awesome stuff with this mouse move api - like color labels ) The Y locations are correct. The X locations are strangely off. I haven't quite figured out why. Which is the reason I posted a stripped version of the exact form. Perhaps you will consider glancing at it... For my problem though, I only need Y cords, which is excellent news!

    So, we credit Isladogs for his ability to calculate the XY cordinates of the top of any control. That is very cool because no sources reference this solution (that i found, anyway).
    Attached Files Attached Files

  4. #19
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    From what you are describing, you display a listbox and as the mouse moves over the different rows further choices are displayed in another listbox offset to the left or right with the top level with the top of the row being hovered over. If this is the case, use a subform, not a listbox. You can configure the (continuous) subform to look like a listbox. it makes it easy to determine the top position for any row, you can use the mouse over event and some code developed by Stephen Lebans many years ago to determine which row you are hovering over. Pretty sure it is this link http://www.lebans.com/SelectRow.htm. You will need to adapt it for your needs.

    Other benefits of using a subform is that they are always on top, whereas a listbox can be behind other controls - and, perhaps not relevant to your needs, once developed can then be in a separate window which will work with continuous forms

  5. #20
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Hi Ajax!

    That is not my intent, although I never thought of that style of control! Clever indeed.

    No, my actual intent is a recent search option pop-up below the text. Just as you use when you type into google or any modern web search field.

  6. #21
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    If you don't mind, I should let others weigh in on the viability of your db approach as I've not dabbled in this coordinate stuff much at all. As for the face, it's just what I grabbed from the built in images in Access. It's a text, combo and command button.

  7. #22
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I've had a quick look at your example and will study it properly later
    Just for clarification, look at the two screengrabs below from the continuous form part of my original example.
    The popup 'zoom' form moves immediately below the control & record that was double clicked

    Click image for larger version. 

Name:	MoveForm2_Continuous.PNG 
Views:	39 
Size:	16.7 KB 
ID:	37360Click image for larger version. 

Name:	MoveForm2_Continuous2.PNG 
Views:	39 
Size:	15.1 KB 
ID:	37361

    Now if that idea was instead used with the selected record in a listbox, wouldn't that be what you are trying to do?

    BTW the approach I took tried to account for every part of a form and whether or not it was visible.
    I added more checks in a later version than that I uploaded and attempted to account for every combination of :
    • form position WITHIN the application window
    • form header height, form footer height, title bar height (depending on which are in use)
    • navigation control height (if used)
    • record selector width (if used)
    • vertical scrollbar width (if used and visible)
    • horizontal scrollbar height (if used and visible)
    • border style used (thin, none, sizable, dialog)


    I had problems determining in code whether the scrollbar(s) were actually visible and put the project to one side.
    Perhaps it would be easier if I had just used X, Y coordinates with reference to the screen as you are doing

    As for the discrepancies in the values by your/my methods:
    My code just checks relative position within the application window, it ignores nav pane width, ribbon height, application title bar & Access app position on screen ..as not relevant.
    Try removing both scrollbars, shrinking the navigation pane (or remove it), shrink (or remove) the ribbon, change to overlapping windows (instead of tabbed documents) and change your form header height to zero (or remove it ...and that part of my code).
    The values become very similar.

    I've done that on your example and the x values now coincide perfectly.
    However my y value corresponds to a point lower down the listbox than your code.
    I haven't looked into that discrepancy as yet.

    Hope that helps explain at least part of what's happening
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #23
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    isladogs,

    Thanks for your reply.

    The clearest I can be on my goal: If you type into your browser search, you will get a suggested search dropdown. When you hover over any single item in the list, it highlights. Doing that is not hard. And is not the reason i started this topic.
    Doing that dynamically for any textbox in space is.

    My final code will take take a textbox and listbox argument. it will create what I am trying to create regardless of where the textbox or listbox are on the screen.

    With that said, it is critical that I can relate the data in the Mouse Move API to the listbox position on the screen - i.e. the reason I bluntly claimed "I need the XY cordinates of a control".

    Your solution got me darn close but I am having trouble with it and its very difficult to understand. Changing the form size (minimize Access App) makes the values change. You could perhaps use a Form_Resize event to recapture these properties. My solution will be, if the form size is not maximized then the code will simply not run.

    Its amazing how there is no relatively easy solution for relating the position of one's mouse to the position of a control - accurately and dynamically.

    Thank you for looking at my sample...

    However, the numbers do not align when I run the file. They are close but off by 5 on X and 20 on Y

    So, i think we are both scratching our heads... I'm not entirely sure I can use the solution you've graciously provided just because I can't get it to be reliable.

    Best regards,


    EDIT: See attached. Added some more code for you to look at to understand the problem. Likely will not work because our screens have differences.
    Attached Files Attached Files

  9. #24
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Hi

    I've had a very quick look at your new version but TBH I wasn't clear what I was meant to be looking at

    The clearest I can be on my goal: If you type into your browser search, you will get a suggested search dropdown. When you hover over any single item in the list, it highlights. Doing that is not hard. And is not the reason i started this topic.
    Doing that dynamically for any textbox in space is.

    My final code will take take a textbox and listbox argument. it will create what I am trying to create regardless of where the textbox or listbox are on the screen.
    I believe I understand what you want to do. Not quite clear what the drop down is meant to contain however.
    Whether its possible (or worth the time needed to achieve it) using mouse move is another matter

    In fact, I'm very doubtful that its possible to highlight a listbox item without selecting it.
    Similarly I don't see how you can identify the contents of a listbox item unless you select it.
    If you know how to do either of these, I would very much like to hear how its done.


    Anyway, before reading your latest reply, I spent an hour or so playing around on an updated version of my example.
    I've added a form 4 with a listbox and its own popup form
    Clicking any record on the listbox opens the popup to the selected record on the right
    (I know that's pointless but it would work equally well with e.g listbox of names & a popup form with full details for that person)
    Optionally, mouse down event moves the popup form ...BUT doesn't update the record UNLESS its then selected

    Click image for larger version. 

Name:	MoveForm4-Listbox1.PNG 
Views:	39 
Size:	17.4 KB 
ID:	37365Click image for larger version. 

Name:	MoveForm4-Listbox2.PNG 
Views:	39 
Size:	17.8 KB 
ID:	37366

    I've no idea whether that's the slightest help to you ....
    The code needs tidying up as there's a fair bit of irrelevant bumf still included
    I do realise my code to get the dimensions of each part of the form is complicated

    In fact this version is far more complex as its includes items I added in v4 to handle scrollbars that were enabled but not visible ...etc
    You can probably understand why I put this project to one side myself.

    You also hit the nail on the head about differences in the screens & our Access settings
    You use tabbed documents which means all forms are maximised - I use overlapping windows
    I minimise the nav pane & ribbon (and sometimes remove both of them) - I'm guessing you don't do so.
    Attached Files Attached Files
    Last edited by isladogs; 02-09-2019 at 11:34 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  10. #25
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Very interesting thread as it progresses. I've seen examples where, when the position of the mouse is within the bounds of a form's column heading, a mouse down/click will invoke a sort, and a second click with reverse the sort. In theory it could do more.
    I'm just wondering what other possibilities might exist for this mouse pointer is over XXX so we can now do a, b c....

    I have not used mouse events much and can see how the related techniques here may "modernize" the UI. As Colin mentioned --benefits at what cost???

  11. #26
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    FWIW - see my answer to another post about mouse move events in this thread: https://www.access-programmers.co.uk...d.php?t=303740
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #27
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    isladogs,

    Thanks for your reply.

    I believe I understand what you want to do. Not quite clear what the drop down is meant to contain however.
    Glad we are on the same page for the most part. if you must know I will provide the option to pass SQL strings to the listbox. The SQL string would be a query of recent searches...

    Whether its possible (or worth the time needed to achieve it) using mouse move is another matter
    In fact, I'm very doubtful that its possible to highlight a listbox item without selecting it.
    A listbox item can be selected via code, exemplified in my routine listboxSelector. It highlights each item as the mouse hovers it. You are not experiencing this because the Y coordinates are not being referenced correctly with the code you kindly offered. If you would like to see this work, its simply a matter of replacing the "Top" variable in the listboxSelector routine as follows...

    Code:
    Top = GetObjectXY(lBox, "Y") + 50   >>>>>>  Top = [actual top of the control - Y position]
    P.S. I have to add 50 to the Top value, which means something is being missed in the calculation for GetObjectXY. This is not that big of a deal because it seems to be consistent with this particular form. I can move the object anywhere on the form and all is well.

    However, until I can dynamically acquire the Y cords of a control anywhere on a form, on ANY form, my routines will require manual input of that value, obtained with the mouse-move XY api (original purpose for my OP). The code you offered is reliable to an extent but I cannot be comfortable implementing it across my application if I find that when its released to a different client, the screen size throws the numbers off. It is literally the only missing element and I we are so close to making this something very cool!

    All of this XY cordinate obtaining would be eliminated with using a combobox which already does this by its nature. But as I said previously, the combobox does not meet the aesthetic requirements of my task. Perhaps I need to play with it more for removing the arrow. But... there has to be a way to obtain XY cords of a control consistently. Maybe not...

    I saw your sample. Actually pretty cool how the form moves in conjunction with the cursor. But i am struggling to see how I can use it to achieve this. Hmmm....



    Best regards!


    Click image for larger version. 

Name:	animate.gif 
Views:	37 
Size:	48.8 KB 
ID:	37370

  13. #28
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Quote Originally Posted by orange View Post

    I have not used mouse events much and can see how the related techniques here may "modernize" the UI. As Colin mentioned --benefits at what cost???
    Orange, thanks for contributing to the discussion.

    My personal stance is that developing something that improves user experience, efficiency, or productivity is worth the up-front development time--so long that the implementation is not compromising the integrity of the system. Personally, I do not do this for a living, so my perspective is far different.

    Regards

  14. #29
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    OK this is going to be a lengthy answer

    if you must know I will provide the option to pass SQL strings to the listbox. The SQL string would be a query of recent searches...
    From the start, you have seemed VERY reluctant to pass on full details of your intentions! It would be much more useful if you gave a clear statement of intent
    Recent searches in the Access app or recent browser searches? Or something else entirely?
    Either way, rather than me reinvent the wheel, it would indeed make sense for you to provide code you've already done

    I agree that the listbox item can be highlighted using mouse move (it was in my example as well)
    What I'm unsure about is how to select that item just using mouse move
    Is that covered in listboxselector? Otherwise if I've missed it and your code does that, please can you tell me where it is


    I have to add 50 to the Top value, which means something is being missed in the calculation for GetObjectXY. This is not that big of a deal because it seems to be consistent with this particular form. I can move the object anywhere on the form and all is well.
    Yes I noticed you were doing that but not applying that value consistently as far as I can see.
    There are several reasons for that discrepancy as I will account for below

    You say you want the position to be accurate but your twips to pixel conversion is only approximate
    You are using a multiplying factor of 0.0666667

    There are 1440 twips per inch and converting should give the Windows dpi (96dpi in standard Windows display at 100%)
    1440 * 0.0666667 = 96.000048
    Close but no cigar

    Instead use the ConvertToPixelX , ConvertToPixelY functions from my modMetrics module (included in the attached)
    ConvertToPixelY)1440)=96 EXACTLY

    Taking it one stage further, lets say the user chooses to enlarge the display to 125% = 120 dpi
    Your calculation will still be 96.000048 - completely wrong
    ConvertToPixelY(1440) will now give 120 EXACTLY

    Anyway I've done some tweaking of your form & made the values of the top left corner tally by both methods (on my primary monitor)
    To show that, I've done the following changes each of which removes items causing disparity in the calculation:
    a) changed to overlapping windows (removes the tab height)
    b) removed the ribbon
    c) removed the nav pane
    d) maximized the application window so its top left position is 0,0
    e) changed form border to none (removes the form title bar height & the width of the form border)
    f) reduced the form header height to zero - I could have removed it and just adjusted my code

    I've also changed my Y value to intTop = position of top of listbox instead of intBase which was the bottom position

    Doing all that means the X values coincide perfectly on my primary monitor but there is still a discrepancy of approx 24 in the Y values (on my monitor)
    My assumption is that is the application window title bar.
    I can remove the application window to give a form 'floating on the desktop' but then all my calculations will need to be amended.
    So instead I've deducted 24 & the values coincide close enough for me to be happy!
    I can't show the cursor position in the screenshot but hopefully the values will still coincide on your display
    If not adjust the -24 in GetYCursorPos & possibly in listboxselector

    Click image for larger version. 

Name:	TopLeftCorner.jpg 
Views:	38 
Size:	58.2 KB 
ID:	37374

    NOTE:
    1. Moving the Access window to my secondary monitor on the left alters the X coord using my method but not the Y coord (but that's not a problem for you AFAIK)
    2. If the ribbon, nav pane, border, form header etc are restored, your mouse coordinates & my values will not coincide
    Similarly if the app window isn't maximised the values will again be different
    BUT that doesn't matter one iota as my calculated position is still correct within the form itself and that is what matters
    3. Having got this far, I'm going to explore going further with this on my own example app and will get back to you if & when I get anywhere
    Any further help / information you can provide would be much appreciated!
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  15. #30
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Isladogs, ironfelix717

    I am posting a link to a video by PDTech. I remembered a post he made re adjusting form control widths/heights via code including a class. He has made the underlying code available without charge and he has made this video describing the technique with examples.
    Now, it may not be relevant to the X,Y coordinate discussion per se, but you may find some pieces or ideas helpful. Since you both are working at the detail level and I am the observer, it may make more sense to you than me. To me it was the concept of resizing that struck a note with the X,Y posts.

    I also agree that user experience, productivity, performance and for the sake of learning are excellent reasons for undertaking such exercises. Lots (perhaps most) of new approaches are discovered by someone with a inquisitive bent who wants an answer to "what if?"

    Hope it is helpful.

Page 2 of 6 FirstFirst 123456 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 07-13-2018, 02:18 PM
  2. Replies: 3
    Last Post: 11-30-2016, 07:18 PM
  3. Replies: 4
    Last Post: 02-18-2016, 12:06 PM
  4. Replies: 8
    Last Post: 06-19-2015, 02:19 AM
  5. Tab Control in Access
    By Rosy6 in forum Forms
    Replies: 2
    Last Post: 04-25-2010, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums