Page 13 of 13 FirstFirst ... 310111213
Results 481 to 484 of 484

Thread: VB6 WebView2-Binding (Edge-Chromium)

  1. #481
    New Member
    Join Date
    Dec 2021
    Posts
    4

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Hello Olaf.
    I am using this excellent option of using webview2 with vb6, I have managed to make functions to interact with the elements of some websites, but I found a problem that I have been struggling with for days, this is when simulating the click() event in an Input of type File, it simply does not open the file chooser dialog, when opening devtools the following alert can be displayed "File chooser dialog can only be shown with a user activation", I understand that this is a security block, but I want to know if There is the option to bypass that restriction.

    Here I show the return message in the DevTools
    Attachment 191017

    Best regards.
    Last edited by JoseLiza; Apr 3rd, 2024 at 12:29 AM.

  2. #482

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,253

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by JoseLiza View Post
    I have managed to make functions to interact with the elements of some websites, but I found a problem that I have been struggling with for days, this is when simulating the click() event in an Input of type File, it simply does not open the file chooser dialog, when opening devtools the following alert can be displayed "File chooser dialog can only be shown with a user activation"

    I understand that this is a security block...
    Then don't fight it (within the Browser-Control)...

    The nice thing about these "Dual-Apps" is, that you can always choose the side more suited for the task -
    so why not show a modal FileOpen-Dialog via VB6-code?

    Olaf

  3. #483
    New Member
    Join Date
    Dec 2021
    Posts
    4

    Re: VB6 WebView2-Binding (Edge-Chromium)

    Quote Originally Posted by Schmidt View Post
    Then don't fight it (within the Browser-Control)...

    The nice thing about these "Dual-Apps" is, that you can always choose the side more suited for the task -
    so why not show a modal FileOpen-Dialog via VB6-code?

    Olaf
    Using the vb6 FileOpen-Dialog would not allow assigning the path of the selected file in the file type input, since I am trying to upload a file to a website.
    If I'm wrong, I would appreciate if you could guide me on it.

  4. #484
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,624

    Re: VB6 WebView2-Binding (Edge-Chromium)

    The way I handle resizing is to set the form font to the control font and then use TextWidth with the text to determine the width and then size the control to whatever number it gives me back plus a little buffer.

    It only works on one-liners though - like labels and single-line textboxes. I've never tried it with multiline textboxes.

    I use it for all controls (that are one-lines) that I want to resize at run-time such as labels, check and optionboxes and single-line text boxes.



    Code:
    Private Function ResizeCheckBox(ByRef Check As Control, ByRef Form As Form, Optional ByRef Padding As Long = 0) As Long
    Dim nWidth As Long
    
    ' Returns CheckBox width.
    On Error GoTo errHandler
    
    CopyFontFromControl Check, Form
    
    nWidth = Form.TextWidth(Check.Caption)
    
    nWidth = nWidth + CHECKBOX_PADDING + Padding
    
    Check.Width = nWidth
    
    ResizeCheckBox = nWidth
    
    Exit Function
    
    errHandler:
    Dim nErrorNumber As Long
    Dim nErrorHandlerResult As Long
    Dim sError As String
    Dim nErr As Long
    Dim Parameters(1) As String
    
    sError = Error
    nErrorNumber = Err
    
    Parameters(0) = "Check.Name = " & Check.NAME
    Parameters(1) = "Check.Parent.Name = " & Check.Parent.NAME
    
    nErrorHandlerResult = ErrorHandler(sError, nErrorNumber, ParameterString(Parameters), NAME & ".ResizeCheckBox(Private Function)")
    
    Resume CleanUp
    
    End Function
    
    
    Public Function CopyFontFromControl(ByRef FromControl As Object, ByRef ToControl As Object) As Long
    
    ' Returns Error Code.
    On Error GoTo errHandler
    
    With ToControl.Font
    
      .Bold = FromControl.Font.Bold
      .Charset = FromControl.Font.Charset
      .Italic = FromControl.Font.Italic
      .NAME = FromControl.Font.NAME
      .Size = FromControl.Font.Size
      .Strikethrough = FromControl.Font.Strikethrough
      .Underline = FromControl.Font.Underline
      .Weight = FromControl.Font.Weight
    
    End With
    
    Exit Function
    
    errHandler:
    Dim nErrorNumber As Long
    Dim nErrorHandlerResult As Long
    Dim sError As String
    Dim Parameters(1) As String
    
    CopyFontFromControl = Err
    
    nErrorNumber = Err
    sError = Error
    
    Parameters(0) = "FromControl.Name = " & FromControl.NAME
    Parameters(1) = "ToControl.Name = " & ToControl.NAME
    
    nErrorHandlerResult = ErrorHandler(sError, nErrorNumber, ParameterString(Parameters), NAME & ".CopyFontFromControl(Public Function)")
    
    End Function

Page 13 of 13 FirstFirst ... 310111213

Posting Permissions

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



Click Here to Expand Forum to Full Width