Page 5 of 6 FirstFirst 123456 LastLast
Results 61 to 75 of 79
  1. #61
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Glad you've found a solution you're happy with ... don't forget to post your solution here as an example app as you promised back at the start of this thread

    The first thing I did was removed the API conversion function, as its just an unnecessary risk (and code) and replaced it with the following (which only supports select fonts of my choice):
    1. How is using an API an 'unnecessary risk'?
    2. I could have also limited my example to e.g. Calibri to avoid issue with other standard fonts of varying heights of e.g. Verdana/Comic Sans compared to Calibri.
    I deliberately included them so you could see potential issues


    3. I notice you've omitted point sizes 9 & 12 where the points to pixels conversion is exact - presumably because you couldn't get those to work!
    FWIW point size 12 works with tw = 240 + 50 using Calibri ...but not in e.g. Comic Sans

    I'm sure you could find a value for 9pt as well if you want
    However if you are going to restrict the font names, you may as well fix the point size as well

    4. If you haven't done so, suggest you test your code on varying screen sizes and resolutions.
    Those arbitrary numbers you added to make it work MAY not be transferable to all situations
    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

  2. #62
    daolix is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2019
    Posts
    5
    Here is another method to determine the font twips and the resulting row height of the list box.

    Code:
    WizHook.Key = 51488399
        Dim lx As Long
        Dim ly As Long
        With Me.lstContacts
            If WizHook.TwipsFromFont(.FontName, .FontSize, .FontWeight, .FontItalic, .FontUnderline, 0, "ABCghj", 0, lx, ly) = True Then
                LBRH = (ly And Not &HFFFF0000) + 30 - 15
            End If
        End With
    In the Mousemove event, the position can still be calculated with
    Code:
    lstPos = Y \ LBRH

  3. #63
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Ah. I forgot the Wizhook function as its unsupported and so poorly documented.
    Where did you find that code ?

    Thanks I'll try that out later and see how it compares

    If it can really cope with different font names and styles, that would be amazing.
    Have you tried it yourself with my example app?
    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

  4. #64
    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
    Found this link to wizhook, don't know if you have something more reliable.

  5. #65
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Thanks Orange
    That link didn't open for me

    I looked into Wizhook a couple of years ago but only rarely use it

    The best information source online that I am aware of is:
    http://www.mvp-access.es/juanmafan/wizhook/wizhook.htm (in Spanish but it translates)

    The attached PDF is also excellent & includes an outline of how it grabs TwipsFromFont

    Also attached is an example database illustrating some of its many features

    Wizhook is great - its been around for over 20 years but as I said before almost undocumented.
    Its a hidden function in the VBE and to use it requires the Wizhook key given in the previous post by daolix

    I'm going to try this out later
    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

  6. #66
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    A listbox is the premier tool for listing items. How will you add and remove items?
    Same way you would for a listbox - if the listbox is a value list, then use a disconnected ado recordset

    What controls will represent the rows?
    typically a texbox,
    I
    think you would find its cumbersome and not well adaptable/expandable. - Especially if you have to query the row data.
    I've been using it for donkeys year. just requires one line of code to assign an event to the appropriate control

    In regards to a subform solution, be my guest
    I really don't want to spend the time, happy to point you in the right direction (which I have already done) but not develop a complete solution for you

  7. #67
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    @daolix
    Thank you so much.
    I've tried the code on a variety of font names, tried bold/italic/underline & all sizes from 1pt to 72pt (although most of those sizes are obviously ridiculous for a listbox)
    It works brilliantly!

    Only italic makes any difference to font height so my form 5 now has the choice of
    a) 13 standard Windows fonts
    b) point sizes 7 to 14 pt
    c) italic - yes/no

    One part of the Wizhook code doesn't make sense to me:
    Code:
     LBRH = (ly And Not &HFFFF0000) + 30 - 15
    I believe that's a colour hex value so why is it there?
    I tested the results with & without it - they were identical - so i've removed it

    So I've simplified the code to:

    Code:
    WizHook.Key = 51488399    
        Dim lx As Long 'width of font caption tested
        Dim ly As Long 'height of font caption tested
        'caption tested = "W" - height only needed for testing
        With Me.lstImages
            If WizHook.TwipsFromFont(.FontName, .FontSize, .FontWeight, .FontItalic, .FontUnderline, 0, "W", 0, lx, ly) = True Then
                LBRH = ly + 15 'height + 15 twips (1px) as 1 px left between each listbox row
            End If
        End With
    I would very much like to know where you heard about Wizhook & whether it has other examples of its use beyond those in the links I provided earlier
    Last edited by isladogs; 02-18-2019 at 05:38 PM.
    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. #68
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Ironfelix
    Again following on from Ajax's comment, can I also remind you that I also suggested a continuous form early on in this thread.
    In post #32 I also showed a screenshot of a continuous form side by side with a listbox and formatted so these looked identical.
    You ignored the suggestion.

    As my last answer makes clear I now have an answer using Wizhook that seems to work absolutely perfectly
    The previous correction I made was very close. This is perfect.
    I've now reviewing the first 3 forms in my utility adding additional functionality to those (unrelated to the listbox code)
    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

  9. #69
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Quote Originally Posted by isladogs View Post
    Ironfelix
    Again following on from Ajax's comment, can I also remind you that I also suggested a continuous form early on in this thread.
    In post #32 I also showed a screenshot of a continuous form side by side with a listbox and formatted so these looked identical.
    You ignored the suggestion.
    A subform can be the last restort. At this point, were making enough progress that the native listbox control could work. Which is worth the effort in my opinion.


    As my last answer makes clear I now have an answer using Wizhook that seems to work absolutely perfectly
    The previous correction I made was very close. This is perfect.
    I've now reviewing the first 3 forms in my utility adding additional functionality to those (unrelated to the listbox code)
    [/QUOTE]

    Wizhook has provided a nice way to retrieve the value of a font size based on a number of conditions. Surely that makes the code more versatile, but does it solve the problem with non-factors of 72? You will also want to test on various screens.

  10. #70
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by ironfelix717 View Post
    Wizhook has provided a nice way to retrieve the value of a font size based on a number of conditions. Surely that makes the code more versatile, but does it solve the problem with non-factors of 72? You will also want to test on various screens.
    As I said in post #67, I've successfully tested this on a wide range of font names and sizes from 1pt all the way to 72pt though most of the sizes would never be used in a listbox. I tested bold, italic and underline. Everything worked fine
    Before I posted, I had also tested on different screen sizes and resolutions. Also fine as I anticipated

    The only time I got an issue was where I needed to scroll down the listbox when using very large fonts but that was an unrealistic setup anyway
    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

  11. #71
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Great, I will also try this Wizhooks method.

    I still don't understand how it negates the theory of non-factors of 72 as you described ten or some posts ago.

  12. #72
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by ironfelix717 View Post
    Great, I will also try this Wizhooks method.

    I still don't understand how it negates the theory of non-factors of 72 as you described ten or some posts ago.
    When determining the listbox row height, we need to allow for the font size, space left between each row and the fact that you can't have part pixels.
    So a calculated value of e.g. 13.33330px actually takes up 14px.

    There are three main ways of doing this:


    1. Use values with arbitrary corrections (based on trial and error) like +95/+72 etc as you did in post #60.
    This will occasionally work for a few fonts but is likely to go wrong very often.
    If you stick with the same conditions used for your tests it might be adequate


    2. Use values calculated by a direct points/pixels to twips conversion as I did based on Stephen Lebans functions.
    This will usually work (with the correction I made in post #59) but it has issues with the inexact conversion between 72 points and 96 pixels per inch.
    It tries to allow for that with a 'jump' every 3 points
    It also makes no allowance for certain fonts e.g. Comic Sans being taller than the normal value for that point size.


    3. Using Wizhook which actually measures the height and width of a character string based on the font name, font style normal, italic etc.
    This should always work no matter what the situation and my tests confirmed that to be so.
    The issue with wizhook is that it is a hidden function and not documented by MS.
    In theory it could be removed in a future release but as it is used in some built in wizards, I believe that to be highly unlikely
    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

  13. #73
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    All finally done and I'm happy with the outcomes.

    Attached is version 7.3 which I will also be uploading to my website tomorrow
    This includes
    a) improvements to forms 1-3 used to open a popup zoom box in a precise location
    b) revised code using the Wizhook function to highlight & 'select' a listbox record using mouse move event code
    c) a form to display the screen co-ordinates of a textbox and nudge it up/down/left/right
    d) a new form to display the sizes of all component parts of a form so these values can be used to accurately position objects

    Click image for larger version. 

Name:	FormInfo.PNG 
Views:	46 
Size:	100.6 KB 
ID:	37532

    e) A PDF explaining what the form does together with some of the main code used in the various forms

    Various options are available in each form for modifying the application & form settings
    • border style - none/thin/sizable/dialog
    • scrollbar - none/horiz only / vet only / both
    • record selectors - on/off
    • navigation button bar - on/off


    This app has also been tested successfully with
    i) 32-bit/64-bit Access
    ii) different screen sizes and resolutions
    iii) magnified display from 100% default to 125%

    What have I forgotten .... nothing I hope!
    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

  14. #74
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    Congratulations Colin - heavy task which I sure users will find useful.

  15. #75
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Hi Ajax
    Many thanks for your support on this re: screen flicker and at other times
    Now its back to some of my other projects that I've been neglecting!
    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

Page 5 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