OnResizeStart event

Add-in Express™ Support Service
That's what is more important than anything else

OnResizeStart event
The OnResizeStart and OnResizeEnd events don't fire? 
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
Hello,

I need to run some code to close my autocomplete dropdowns when the browser is re-sized or moved.
Starting with the Re-sizing, I tried OnResizeStart and OnResizeEnd thinking these would fire when you start or finish dragging the edge of the browser window, however they do not.
I do have an instance of AdxiehtmlDocEvents in my iemodule designer, and I configured supportedEvents set to "Window"

The OnResize function does fire but it fires many times during the re-size causing my code to fire off way more than it needs to.

As for detecting when the browser is moved, I haven't found anything related to that. If it is possible, please share your ideas.
Posted 18 Nov, 2015 16:39:01 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Kyle,

Are you able to detect if the autocomplete dropdown is opened?
Posted 19 Nov, 2015 04:53:15 Top
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
Yes i'm using a function to check each telerik dropdown to see if it has an open dropdown and autocomplete dropdown as shown:
Public Sub closeDropdowns()
        
        If dropModel.DropDownListElement.IsPopupVisible Then
            dropModel.CloseDropDown()
            Debug.WriteLine("close dropdown")
        End If
        If dropModel.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Visible Then
            DropdownHasText(dropModel)
            Debug.WriteLine("close dropdownac")
        End If

        If dropTransfer.DropDownListElement.IsPopupVisible Then
            dropTransfer.CloseDropDown()
        End If
        If dropTransfer.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Visible Then
            DropdownHasText(dropTransfer)
        End If

        If dropRecTransfer.DropDownListElement.IsPopupVisible Then
            dropRecTransfer.CloseDropDown()
        End If
        If dropRecTransfer.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Visible Then
            DropdownHasText(dropRecTransfer)
        End If

        If dropPreviousContact.DropDownListElement.IsPopupVisible Then
            dropPreviousContact.CloseDropDown()
        End If
        If dropPreviousContact.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Visible Then
            DropdownHasText(dropPreviousContact)
        End If
    End Sub

However as the dropdowns have fade animation, their visible property doesn't change to false right away, so the close command is still getting fired at least 4 times.
I suppose I could turn off the animations, but it doesn't look as nice.
It would be better to call the close function only once when browser starts the re-size.
Posted 19 Nov, 2015 09:27:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Kyle,

Add-in Express doesn't provide such a feature. But you can implement it yourself. E.g. you can use the OnBrowserResized event of the iemodule and set a local variable to 'true' when the browser is resized. Also you will start a timer in this event (interval = 500ms). Then you will reset the local variable in the Tick event of the timer. This way you can implement the OnStartResize and OnEndResize events in your code.

e.g.


bool resizeMode = false;
        System.Windows.Forms.Timer resizeTimer = new System.Windows.Forms.Timer();

        private void IEModule_OnBrowserResized(int width, int height)
        {
            if (!resizeMode)
            {
                resizeMode = true;

                resizeTimer.Interval = 500;
                resizeTimer.Tick += ResizeTimer_Tick;
                // Here you can close the autocomplete dropdown

                Debug.WriteLine("Close dropdown...");
            }
            else
            {
                if (resizeTimer.Enabled)
                    resizeTimer.Stop();
                resizeTimer.Start();
            }
        }

        private void ResizeTimer_Tick(object sender, EventArgs e)
        {
            resizeTimer.Enabled = false;
            resizeMode = false;
        }


As for detecting when the browser is moved, I haven't found anything related to that. If it is possible, please share your ideas.

Please try to use OnUpdateUI event of the iemodule. To enable the event you need to set the 'HandleDocumentUICommands' property to true.
Posted 19 Nov, 2015 12:00:39 Top
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
Thank you for that suggestion,

I've got a working solution now for everything except detecting when a user moves their browser by clicking the title bar and dragging it.

I tried the OnUpdateUI event as you suggested, but it doesn't fire when the browser is clicked and dragged.
Private Sub IEModule_OnUpdateUI(sender As Object, e As EventArgs) Handles Me.OnUpdateUI
        System.Diagnostics.Debug.WriteLine("OnupdateUI: " + sender.ToString)
        If Not (AdxieAdvancedBarItem1.BarObj Is Nothing) Then
            Dim bar As FancyPantsBar = AdxieAdvancedBarItem1.BarObj
            bar.closeDropdowns()

        End If
    End Sub

It fires when something on the page changes, such as if i have a rotating image frame on a webpage, it will fire every 2 seconds when the image changes.
Posted 20 Nov, 2015 08:04:57 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Kyle,

I am afraid that I don't have any solution for this issue now. Perhaps you need to use a timer to check the IE frame position via Win API and close the dropdown when IE is moved.
Posted 23 Nov, 2015 05:06:50 Top
Kyle Bohannon




Posts: 12
Joined: 2015-11-06
I had never done anything with the windows api before, but that worked out perfectly, I was able to keep track of the window position and close the dropdowns whenever it is moved.

Fantastic support!
Posted 24 Nov, 2015 11:23:09 Top