Cefglue opens a new tab in restored window state - cefglue

I am using Cefglue of below specification in my app. Whenever I click on a link, and if link opens in new tab it's window state is always in restored state.
How to open the tab always in maximized state?
My Current Setup :-
CEF_VERSION = "106.0.26+ge105400+chromium-106.0.5249.91";
CEF_Glue_VERSION : 106.0.26.0
IDE: Visual Studio/express 2019
Application Type : Windows Forms

To maximize the new tab that opened I have used OnBeforePopup handle which is a part of CefLifeSpanHandler and set the windowInfo.Style property to Maximize like so :
Protected Overrides Function OnBeforePopup(browser As Xilium.CefGlue.CefBrowser, frame As Xilium.CefGlue.CefFrame, targetUrl As String, targetFrameName As String, targetDisposition As Xilium.CefGlue.CefWindowOpenDisposition, userGesture As Boolean, popupFeatures As Xilium.CefGlue.CefPopupFeatures, windowInfo As Xilium.CefGlue.CefWindowInfo, ByRef client As Xilium.CefGlue.CefClient, settings As Xilium.CefGlue.CefBrowserSettings, ByRef noJavascriptAccess As Boolean) As Boolean
' If browser.IsPopup Then
Try
windowInfo.Style = windowInfo.Style Or WS_MAXIMIZE
Return MyBase.OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, client, settings, noJavascriptAccess)
Catch ex As Exception
MsgBox("Issue")
End Try
End Function

Related

Set screen location of external application child window?

Hi I have a program that I monitor an external application. I am able to set the screen location of the application but I want all child windows of that application to open in the same location.
Her is my code I am usion to set the location of the Parent window.
Public Function OpenApplication()
Dim ApplicationProcess = System.Diagnostics.Process.Start("C:\test.exe")
ApplicationProcess.WaitForInputIdle()
System.Threading.Thread.Sleep(1000)
Dim ApplicationHandle = ApplicationProcess.MainWindowHandle
SetWindowPos(ApplicationHandle, 0, 0, 0, 803, 460, 0)
ApplicationProcess.WaitForInputIdle()
Return (False)
End Function
Check out this site. I believe you can accomplish what you want from here. It is all about Obtaining External Window Handles and Window Captions, but it is too much to copy here.
Here is the link

Windows Store App Search Contract Blank Screen

I recently added the search contract to my app. It is working great! But, whenever I search in the app when it is not running, it only starts with a blank screen. I did the part to add search results even in OnSearchActivated method. But even if I remove the code that I added, the blank screen persists. I created a blank project and added the search contract to it. And it is working in it even when the app is not running. The issue seems to be with my app only. I cannot debug it because it is something that runs when the app is not even running. Tell me a solution.
Code in OnSearchActivated and OnLaunched
Protected Overrides Async Sub OnSearchActivated(args As Windows.ApplicationModel.Activation.SearchActivatedEventArgs)
Dim previousContent As UIElement = Window.Current.Content
Dim frame As Frame = TryCast(previousContent, Frame)
If frame Is Nothing Then
frame = New Frame
Common.SuspensionManager.RegisterFrame(frame, "AppFrame")
If args.PreviousExecutionState = ApplicationExecutionState.Terminated Then
Try
Await Common.SuspensionManager.RestoreAsync()
Catch ex As Common.SuspensionManagerException
End Try
End If
End If
frame.Navigate(GetType(SearchResultsPage1), args.QueryText)
Window.Current.Content = frame
Window.Current.Activate()
End Sub
Protected Overrides Async Sub OnLaunched(args As Windows.ApplicationModel.Activation.LaunchActivatedEventArgs)
AddHandler SearchPane.GetForCurrentView.SuggestionsRequested, AddressOf OnSearchPaneSuggestionsRequested
'Contains definition of arrays ExNam, ExAbbr, ExInst, etc. removed from here to shorten the code and focus on its logic
If rootFrame Is Nothing Then
rootFrame = New Frame()
Train_Thy_Brain.Common.SuspensionManager.RegisterFrame(rootFrame, "appFrame")
If args.PreviousExecutionState = ApplicationExecutionState.Terminated Then
Await Train_Thy_Brain.Common.SuspensionManager.RestoreAsync()
End If
Window.Current.Content = rootFrame
End If
If rootFrame.Content Is Nothing Then
If Not rootFrame.Navigate(GetType(Instructions), args.Arguments) Then
Throw New Exception("Failed to create initial page")
End If
End If
Window.Current.Activate()
End Sub
'Also the namespace definitions are done at the top so they are not the issues neither.
There is a solution to debug your app : in VS2012, Right-click on your project in the Solution Explorer, then go to the Debug tab and in the Start Action section, check "Do not launch, but debug my code when it starts".
Now you can start your app from the Search Contract even if it is not running yet and debug it!
Now for your problem, I would suggest you to check whether the data is loaded before you actually search for something.
You might be hitting the search activation with empty query string. Check your search activation handler, whether you are handling the blank query text case or not?
protected override void OnSearchActivated(SearchActivatedEventArgs args)
{
// your app initialization code here.
Frame frame = (Frame)Window.Current.Content;
if (!string.IsNullOrEmpty(args.QueryText))
{
frame.Navigate(typeof(SearchResultsPage), args.QueryText);
}
else
{
// navigate to your app home page if the query text is empty.
frame.Navigate(typeof(Home), null);
}
Window.Current.Activate();
}

How to set 5 second timing of a splash screen in VB.NET

I have used this code to set 5 second time of my vb.net's project's splash screen.
Imports System.Collections.ObjectModel
Namespace My
Partial Friend Class MyApplication
Protected Overrides Function OnInitialize(ByVal commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
Me.MinimumSplashScreenDisplayTime = 5000
Return MyBase.OnInitialize(commandLineArgs)
End Function
End Class
End Namespace
This code is fully working but as my project takes no time to load so as soon the splashscreen is getting loaded the 1st form is also getting loaded, and it is hiding the splash screen.
I want that the 1st form will load after the splash screen gets closed. Can any one help me out in this?
You could try setting your application to use a 'Sub Main' as its startup object rather then either form. In the 'Sub Main' you can show your splash screen as a modaless form while you do your initialization, then hide it when you you are ready to show your main form. Something like:
Sub Main
Dim slash as new SpashScreenForm
slash.Show()
<do the initialization for several seconds>
slash.Hide()
Dim mainForm as new TheMainForm
mainForm.ShowDialow()
End Sub
You may need to throw in a few Application.DoEvents() calls to get the splash screen to refresh.

Keep Popup Window in WebBrowser control instead of a new window

When using the WebBrowser control, is it possible to cause popup windows to
appear within the WebBrowser control itself instead of a new window?
I can't figure out how to get the popup to appear in the same browser window. please help me :)
PS : The language I use is VB
If you have multiple tabs with WebBrowsers, use this under the "New Window" Event:
((WebBrowser)TabControl1.SelectedTab.Controls[0]).Navigate(((WebBrowser)
TabControl1.SelectedTab.Controls[0]).StatusText)
'next input <cancel[IE]>
e.Cancel = True
If just a plain browser put this under the New Window Event:
webBrowser1.Navigate(webBrowser1.StatusText)
e.Cancel = True

Showing Login form before main form in vb.net

I'm sure I'm doing my login process for my app in a not so perfect way, but as with lots of things, it works. The issue is to make it work I have to use the very unpopular DoEvents thing.
I would like my application to show a login screen before loading my main form. Currently I have a login dialog box with a FormOpen boolean property and an authenticated boolean property. If a user logs in successfully, I hide the login form, set formopen to false, and authenticated to true. If they cancel out, then I do the same and just set the authenticated property to false. If authenticated=false then I end the app, else I show the main form via application.run(MainForm)
Shared Sub Main()
Using frmLogin1 As New LoginForm
frmLogin1.Show()
Do While frmLogin1.FormOpen = True
Application.DoEvents()
Loop
If frmLogin1.Authenticated = False Then End
End Using
ModuleRegistration.Register()
Application.Run(MainForm)
End Sub
Is there a more preferred way of doing this?
You could just set the startup form to the login form. Then when the user hits "OK" and is verified, you just load the main form and close the login form.
Alternatively you can use the "ShowDialog" method to show the form modally. In your login form code, you can set DialogResult when closing the form, which becomes the return value from the ShowDialog method. That way you can detect that, say, "Cancel" was pressed and quit.
UPDATE: Perhaps if you change your Sub Main to just:
Application.Run(YourLoginForm)
Along with whatever other startup code your require. Then handle showing the main form in your login form (if I remember correctly, your application will not exit until the last form closes... You can use that to your advantage).
I think your approach is fine, except for one thing: the loop. Instead, display the login form using ShowDialog.
Shared Sub Main()
Dim authenticated As Boolean
Using frmLogin1 As New LoginForm
frmLogin1.ShowDialog()
authenticated = frmLogin1.Authenticated
End Using
If authenticated Then
ModuleRegistration.Register()
Application.Run(MainForm)
End If
End Sub
Or instead of waiting for your login form to close, raise an event in the login form.
You'll need to declare your login form withevents.
Then when the login form's new event fires, check the value of the authenticated property.