Electron win.setMaximizable(true) not working - electron

I am working on an electron where i allow user to enable or disable window full screen. I am using
win.setMaximizable(boolean)
but it throws this error popup
win.setMaximizable is not a function.
I have no idea why this error is coming although win object is defined. Or is there any way to set window property from a render process. Help is required.

Related

Electron load failed when set uiAccess true

I want to use electron to develop an app to show above lock screen. I need to set my window alwaysOnTop and set the uiAccess of the exe as true.
The exe can load index.html successfully without uiAccess change, but when I change the uiAccess to true, the exe can only create a window but the window is blank, sometimes it's white while sometimes it's black.
I tried to log some event and found that the crashed event was triggered if I open the exe with non-Administrator. If I open the exe with administrator, the 'did-finish-load' was triggered but the window is black, didn't show my index.html. How can I fix this?
I found that the cause is the parameter of setAlwaysOnTop. The type for windows should be "normal". After change to mainWindow.setAlwaysOnTop(true, 'normal');, it works well.

Can you use AddEventListener with CEF4Delphi?

I am using Delphi XE2 and Chromium CEF4Delphi. I am trying to use a web page via the TChromiumWindow component and would like to detect when an element is selected / clicked.
I saw this post..
Delphi Chromium - launch a command in Delphi application when button in web page is clicked by user
Unfortunately, I cant find the function AddEventListenerProc in the CEF4Delphi library. Neither can I find an alternative way to monitor a button / element click.
I would like to use the TChromiumWindow component to act as a "fron-end" to my app and would like to monitor user button clicks etc.
Can anyone help please ? I did try the developer forum but I dont see much activity there and was unable to register.
Many thanks..
The DCEF3 project has a group here : https://groups.google.com/forum/#!forum/delphichromiumembedded
But the CEF4Delphi and OldCEF4Delphi projects have a developers forum here :
https://www.briskbard.com/forum/
That forum has new posts almost every day and I try to answer them as soon as I can, usually in less than 24 hours.
If you have problems creating an account just send me a message and I'll activate your account manually.
The link you posted is very old and many things have changed in CEF since 2012.
There are several ways to detect when a HTML element has been selected, clicked, etc.
You can use a JavaScript event like "onclick" that calls a custom JavaScript extension. That extension would send a process message to the browser process to notify that the user clicked that element.
You can also use the GlobalCEFApp.OnFocusedNodeChanged that is triggered when an HTML element has been focused. This event is executed in the "render" process so you will also need to send a process message to the main browser process that the focused element has changed.
Use the JSRTTIExtension or the JSExtension demos as a template for your app.
They show you how to set a "mouseover" event that calls the "myextension.mouseover" function defined in a custom JS extension. The myextension.mouseover function executes Delphi code and sends a process message to the main browser process with some HTML information that is shown in the status bar.
They also have an example for a "MutationObserver" that calls a generic "myextension.sendresulttobrowser" function in the JS extension that sends the "value" attribute to the browser process.
Build the demo and right-click on the web page when it's fully loaded. Then select the "Set mouseover event" or "Add mutation observer" options to test what I described.

Is there a way to bypass Chrome geolocation dialog in Protractor tests?

I faced this problem, when automating an application with protractor.
Once I open a home page I get geolocation dialog with Block/Allow buttons, which didn't let proceed without selection either option
It turned out, that this dialog is not an instance of alert, that's why browser.switchTo().alert().confirm() didn't work
Passing '--disable-notifications' argument to Chrome also didn't solve the problem
Research online didn't give any positive results. How to solve it?
The solution to the problem is to pass "prefs": {'profile.default_content_setting_values.geolocation': 2} to capabilities object in your protractor.config.js
Below is another option that does pretty much the same thing.
So chrome may take an argument --user-data-dir=/tmp/chrome which specifies profile to open chrome with. If profile doesn’t exist at specified directory it creates default one.
Then if you open /tmp/chrome/Default/Preferences you’ll see an object with preferences. You needed to set default_content_setting_values.geolocation to 2 (not 1 or 0) to make it NOT prompt that dialog

What's the outcome of setting node-integration to false when creating a new browser window in Electron?

In order to get jQuery to load and function correctly in a HTML page I was opening in Electron (formerly Atom Shell), I had to disable Node integration when creating the BrowserWindow in my main.js file.
Can someone please tell me what setting node-integration: false will keep me from being able to do that I would normally be able to do had I not disabled it?
Setting node-integration to false will disable node.js in the renderer process - i.e. your app can only do what a web browser will do. Instead of doing this, use Zepto.js which is compatible with Electron and has the same API.

Why is a dialog box being displayed behind the main form?

Earlier today I went to open a file in a Delphi app I wrote. For some reason the connection to the file's network was down--reasons unimportant--and Windows created a dialog box alerting me to the problem. My app's main form, however, was on top of the newly created dialog (i.e., there was a form for my app, for the File Open dialog, and for the warning dialog box). The warning dialog was modal, and hidden behind the main form. Obviously, I had a problem.
Any idea what's going on, or how I can remedy the issue? The main form's position property is set to poDesigned, and I save/load the form's position on close/startup, I'm too much of a newbie to even know what info would help you diagnose the problem. To be clear, though, the issue was not the File Open dialog--that was displayed where it was supposed to be displayed--the issue was the warning dialog.
Thanks, as always --
I don't understand why is Windows creating a dialog in your app. Which API call resulted in that happening? Normal file operations don't show UI.
Most likely you were using an API function that can show UI, perhaps from the shell API. Any function that can show a modal dialog will request an owner HWND.
For example consider MessageBox(), a function that you know will show a modal dialog in your app. Its first parameter is called hWnd and is documented
A handle to the owner window of the
message box to be created. If this
parameter is NULL, the message box has
no owner window.
Raymond Chen has a whole series of articles on modality which explain why setting this is important.
I have a hunch that you are calling some Win32 API function that shows modal UI, and are not setting the owner HWND correctly. Of course, I could be completely wrong, but there's not more information to go on.
You can stop this by using SetErrorMode before trying to open the file on the network share:
var
OldErrorMode: Integer;
begin
OldErrorMode := SetErrorMode(SEM_NOOPENFILEERRORBOX);
try
if OpenDialog1.Execute then
begin
// ....
end;
finally
SetErrorMode(OldErrorMode);
end;
end;
Later versions of Delphi (IIRC, D2007 and higher) added an overloaded version of TOpenDialog.Execute that accepts a window handle as a parameter; this sets the TOpenDialog's parent and prevents the OpenDialog (and any error window it generates) from appearing behind the main window.
NOTE: You can get to the background dialog (from Windows) using Alt+Tab to cycle through until your application comes back up; this usually brings the hidden dialog forwaard on top of your form.

Resources