dcsimg
Results 1 to 21 of 21

Thread: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Resolved [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    Hello
    Yesterday I made a bad discovery.
    Basically I downloaded photomodularfx on a friend's PC with Windows 10.
    It crashes every time you click on one of the three "DropDownList"
    Just one click and it crashes.
    This does not happen on XP Vista and win7. the only problem is that at the first click nothing happens (the list does not appear). Only on the second click appears the list from which to choose the option.

    This "Dropdownlist" is part of the widgets.
    I have only changed the appearance, not the functionality.
    So I attach the code used.

    Now I do not have the possibility to test it on Windows10

    I hope someone can help me !
    (PS: Who wants to test the complete program (without source) can download it here )
    Attached Files Attached Files

  2. #2
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,064

    Re: [vbRichClient][vbWidgets] DropDownList Problem

    I tested your code on win10 and also tested the exe file compiled from the test code. In both cases, "Dropdownlist" works fine.

    In addition, I tested your PhotoModularFx and I found 3 problems:

    1. The start of the program is relatively slow

    2. After the program started, the main window was displayed first, but the main window could not be clicked. Later, I discovered that the "What's New" window was hidden by the main window. When I click on the "What's New" window from the taskbar and then press the "OK" button to close the "What's New" window, the main window could be clicked.

    This problem I had previously found in my own program, but there has been no time to in-depth testing. That is, the main window is hidden to the task bar when the mode-window (for example, the message prompt window) is displayed, or the main window hides the mode-window. This problem only appears on Win10, there is no such problem on XP.

    3. Click any "Dropdown list" on the PhotoModularFx main window and the program will crash.
    Last edited by dreammanor; Jun 4th, 2018 at 05:53 AM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [vbRichClient][vbWidgets] DropDownList Problem

    Thank you very much for testing...
    Very strange that this code works but not the full exe program , since the code used is the same... This make me think that maybe it is a problem related to my vbwidget.dll
    About startup Itime, I saw it was very slow on win10. Instead in win Vista and win7 is very fast.

  4. #4
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [vbRichClient][vbWidgets] DropDownList Problem

    I've just tried the TestDropDown application in the IDE and compiled on Windows 10 Version 1709. In both cases it started fast and I have no problems clicking the drop down and selecting items.

    Maybe make sure sure have the latest RC5 library and vbWidgets.dll?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [vbRichClient][vbWidgets] DropDownList Problem

    maybe I got it:

    Since (full application) is portable it uses regfree approach to create widgets

    So cwMyDropDown uses a widget:
    Code:
    Private WithEvents fPopUp As cfPopUp    'this PopupForm-HelperClass is hosted here in the vbWidgets.dll-Project
    so maybe is this line of code that causes the crash:


    Code:
    Private Sub Btn_Click()
            .....
            .....
            Set fPopUp = New cfPopUp
            .....
            .....
    End Sub
    Maybe it should be done this way:
    Code:
    Public Function New_W(ClassName As String) As Object
    
        If APP.LogMode Then    'we run compiled
            Set New_W = New_c.RegFree.GetInstanceEx(APP.Path & "\vbRC5BaseDlls\vbWidgets.dll", ClassName)
        Else    'we run in the IDE, so we create the instance from the registered version
            Set New_W = CreateObject("vbWidgets." & ClassName)
        End If
    
    End Function

    Code:
       If fPopUp Is Nothing Then Set fPopUp = New_W("cfPopUp")
    .... this is just a hypothesis that has just occurred to me. Maybe only Olaf can help.
    Last edited by reexre; Jun 4th, 2018 at 10:40 AM.

  6. #6
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [vbRichClient][vbWidgets] DropDownList Problem

    Yes you should never use the standard New keyword instantiation of non intrinsic objects when using the DirectCOM.dll/RC5 regfree approach. Also, if you trap the errors in your events the program won't crash completely when errors like this occur, giving you a chance to more easily figure out what's going wrong.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [vbRichClient][vbWidgets] DropDownList Problem

    I resolved using New_W (Post #5)
    (Complete program Zip updated)

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    dreammanor
    Thanks again for testing.
    Those interested in using and testing the complete (portable) program. (without source code) can do it at this address. (dedicated thread)
    In general, I received not much feedback, but, for example, one like that of dreammanor was very useful.

  9. #9
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,064

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    Hi reexre, I tested the latest version of your software, "Dropdown list" is OK. But the boot speed of the software is still a bit slow and the "What's New" window is still hidden behind the main window.

  10. #10
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    I've just tried the latest version, and it starts up quickly and the "What's New" window comes in front as expected, so I'm not seeing the same issues as dreammanor. I'm on Windows 10 Build 1709.

    One thing I did notice: I have a fairly high DPI monitor and the fonts are very small at startup. I see I can use Pinch & Zoom to change the size (and PMFX remembers the size so that's great), but it might be better if you check the DPI on first start and do an initial zoom for users - I imagine things would be microscopically small on 4K monitors on first start otherwise.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    Quote Originally Posted by jpbro View Post
    I've just tried the latest version, and it starts up quickly and the "What's New" window comes in front as expected, so I'm not seeing the same issues as dreammanor. I'm on Windows 10 Build 1709.

    One thing I did notice: I have a fairly high DPI monitor and the fonts are very small at startup. I see I can use Pinch & Zoom to change the size (and PMFX remembers the size so that's great), but it might be better if you check the DPI on first start and do an initial zoom for users - I imagine things would be microscopically small on 4K monitors on first start otherwise.
    I thought to resolve it changing "CurrZoom" after the INI-Settings reading.

    This way
    Code:
    'ADAPT ZOOM to DPI
    fMain.CurrZoom = fMain.CurrZoom * ((1440 / Screen.TwipsPerPixelX) / 96)
    where
    1440 / Screen.TwipsPerPixelX
    should return current screen DPI.

    or this way:
    Code:
    fMain.CurrZoom = fMain.CurrZoom * ((Screen.Height / Screen.TwipsPerPixelY) / 768)
    I'm not sure which one is better to use

    PS:
    dreammanor jpbro
    I'd be glad to give you full version. If you are interested, click "A" button and send email with ProductKey, so I'll reply with ActivationKey.

  12. #12
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    @reexre - here's some code I have for getting the DPI, though I can't say with certainty that it's the best method so it's probably worth having a look around for other examples.

    Code:
    Public Function Dpi(ByVal p_Hwnd As Long, ByVal pVertical As Boolean) As Long
       Dim l_Monitor As Long
       Dim l_Hdc As Long
       Dim l_DpiX As Long
       Dim l_DpiY As Long
       
       If New_c.IsWin8Plus Then
          l_Monitor = MonitorFromWindow(p_Hwnd, MONITOR_DEFAULTTOPRIMARY)
          
          If l_Monitor = 0 Then
             Err.Raise vbObjectError, , "Could not get monitor. Last DLL Error: " & Err.LastDllError
             
          Else
             If GetDpiForMonitor(l_Monitor, MDT_EFFECTIVE_DPI, l_DpiX, l_DpiY) <> 0 Then
                Err.Raise vbObjectError, , "Could not get DPI for monitor. Last DLL Error: " & Err.LastDllError
             
             Else
                If pVertical Then
                   Dpi = l_DpiY
                Else
                   Dpi = l_DpiX
                End If
             End If
          End If
       End If
    
       If Dpi = 0 Then
          ' Not Win8+
          If p_Hwnd = 0 Then
             ' Get desktop
             p_Hwnd = GetDesktopWindow
          End If
          
          On Error GoTo CleanupDc
       
          l_Hdc = GetDC(p_Hwnd)
          
          Dpi = GetDeviceCaps(l_Hdc, IIf(pVertical, LOGPIXELSY, LOGPIXELSX))
       End If
    
    CleanupDc:
       If l_Hdc <> 0 Then ReleaseDC p_Hwnd, l_Hdc
    End Function
    PS: Thanks for the offering the full version, that's very generous of you! I'll send my request

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    I think that going into DPI is too complicated.
    Maybe it's better to get the height of the screen in pixels, and multiply the zoom for a certain ratio (ScreenHeight / 800)

    After INI read:
    Code:
    Set fMain = New cfMain
    ....
            in fmain Class_Initialize:
            Form.CenterOn New_c.Displays(1)
            Form.WindowState = vbMaximized
            Set Canvas = Form.Widgets.Add(New cwCanvas, "Canvas", 0, 0, Form.ScaleWidth, Form.ScaleHeight)
    
    ....
    ScreenHeight = fMain.Form.ScaleHeight
    fMain.CurrZoom = fMain.CurrZoom * (ScreenHeight / 800)
    Before INI write:
    Code:
    INI.Value = Me.CurrZoom / (ScreenHeight / 800)

    (I'm using CAIRO.SetDPIAwareness .. even if I did not well understand what it's for)

  14. #14
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    The way I use the DPI is to calculate a multiplier for the UI. e.g. Zoom = Dpi(Form.Hwnd, False) / 96. On my computer this would result in a multiplier of 1.5. I wonder if calling CurrZoom * (Dpi(Form.hWnd, False) / 96) would work? Or better, in your CurrZoom method, take your final number and multiply it by (Dpi(Form.hWnd, False) / 96) before returning the result? Or since you control the Zoom level yourself maybe adding DPI awareness to the manifest would do the trick?

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    My CurrZoom is multiplied since it is customizable, if not customizable CurrZoom = Dpi(Form.Hwnd, False) / 96 should be ok.

    When changing CurrZoom ( in Form )
    Code:
    Friend Property Let CurrZoom(V As Double)
        m_CurrZOOM = V
        ReAdjustZOOM
    End Property
    a sub ReAdjustZOOM is called, that basically :
    Code:
        Form.WidgetRoot.Zoom = m_CurrZOOM
    + Move Widgets to new CurrZoom based positions
    for the rest approach used for zooming is taken from :
    http://www.vbforums.com/showthread.p...Widgets-based)

  16. #16
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    I think what would work the best is to use the DPI multiplier the first time the program is started to set the initial zoom. So, right now the program starts at 1x, but on a 192DPI monitor, everything would be very tiny (half the size). On my 144DPI monitor things are quite tiny but still readable.

    If on first startup you initialize the zoom level to DPI(Form.Hwnd, False) / 96 instead of 1 I think it would work well for all DPIs. From there, users can pinch/zoom as they like, but at least they get a readable zoom level initially.

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    I agree

    One of my doubts is whether to use DPI or fMain.Form.ScaleHeight.
    (Window height in pixels calculated when the window is maximized)
    Ratio = DPI (Form.Hwnd, False) / 96
    or
    Ratio = fMain.Form.ScaleHeight / ExpectedScreenHeight
    where ExpectedScreenHeight = EG 800px.
    The mechanism is the same. But the second one seems easier to me, starting from the assumption that ScaleHeight is in Pixels.

    about zoom management:
    - Initially, the zoom is 1 (read from the ini file).
    - it is immediately modified by multiplying it by one of the two aforementioned ratios
    -Then, when the program is closed, instead of saving the current Zoom value, we save the current Zoom divided by the ratio.
    EG:
    INIzoom = 1
    Ratio = 2
    CurrZoom = INIZoom * Ratio = 1 * 2 = 2
    At program exit
    INIzoom (to save) = CurrZoom / Ratio = 2/2 = 1
    So when restarting we get the same font size we had when we left, and it works even when the Zoom is customized.
    This is because when users pinch / zoom as they like the changing value is CurrZoom.

    However, if I decide to use your DPI function (# 12)
    I would like to know where I can find it complete (with constant statement etc) and if it works with all versions of windows (XP-Vista-7 ..... 10)

    Thanks

  18. #18
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    Sorry I cut & pasted from the wrong source (without constants & declares). Here's the full version:

    Code:
    Option Explicit
    
    Private Declare Function MonitorFromWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal dwFlags As Long) As Long
    Private Declare Function GetDpiForMonitor Lib "shcore.dll" (ByVal hMonitor As Long, ByVal DpiType As Long, p_DpiX As Long, p_DpiY As Long) As Long
    Private Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32.dll" () As Long
    Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Const MONITOR_DEFAULTTOPRIMARY As Long = &H1
    Private Const MDT_EFFECTIVE_DPI As Long = &H0
    Private Const LOGPIXELSX As Long = 88
    Private Const LOGPIXELSY As Long = 90
    
    Public Function Dpi(ByVal p_Hwnd As Long, Optional ByVal p_Vertical As Boolean) As Long
       Dim l_Monitor As Long
       Dim l_Hdc As Long
       Dim l_DpiX As Long
       Dim l_DpiY As Long
       
       If New_c.IsWin8Plus Then
          l_Monitor = MonitorFromWindow(p_Hwnd, MONITOR_DEFAULTTOPRIMARY)
          
          If l_Monitor = 0 Then
             Debug.Assert False
             
          Else
             On Error Resume Next
             GetDpiForMonitor l_Monitor, MDT_EFFECTIVE_DPI, l_DpiX, l_DpiY
             On Error GoTo 0
    
             If p_Vertical Then
                Dpi = l_DpiY
             Else
                Dpi = l_DpiX
             End If
          End If
       End If
    
       If Dpi = 0 Then
          ' Couldn't get using GetDpiForMonitor
          If p_Hwnd = 0 Then
             ' Assume desktop
             p_Hwnd = GetDesktopWindow
          End If
          
          On Error GoTo Cleanup
          
          l_Hdc = GetDC(p_Hwnd)
          
          Dpi = GetDeviceCaps(l_Hdc, IIf(p_Vertical, LOGPIXELSY, LOGPIXELSX))
       End If
    
    Cleanup:
       If l_Hdc <> 0 Then ReleaseDC p_Hwnd, l_Hdc
    End Function
    It should work on any version of Windows (trying first using the GetDpiForMonitor method on newer versions of Windows, but if that fails (or on an older version of Windows), then it falls back to GetDeviceCaps which should be available anywhere.

  19. #19
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,093

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    To me the DPI is the way to go because the user sets that based on what they want to see zoom-wise. They may have a smaller monitor (800px) but if they have bad eyesight they may set the DPI higher in order to get larger fonts and the like. I'm not an expert in this area so others may want to chime in.

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    Quote Originally Posted by jpbro View Post
    To me the DPI is the way to go because the user sets that based on what they want to see zoom-wise. They may have a smaller monitor (800px) but if they have bad eyesight they may set the DPI higher in order to get larger fonts and the like. I'm not an expert in this area so others may want to chime in.
    I didn't think about that. Thank you.
    I'll use your DPI function ... and will update soon.
    Last edited by reexre; Jun 20th, 2018 at 04:57 AM.

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    333

    Re: [RESOLVED] [vbRichClient][vbWidgets] DropDownList Problem

    PhotoModularFX New update
    Better to continue in this thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width