Loading A Window Without Showing It

Is it possible to load the contents of a Window without actually showing it until the code in the Window.Open event completes?

I have code that will detect if a user has a default setting to maximize a window or keep it in the default window size. The code is listed below:

//Sets Window Size To Settings Value If frmContents.txtWindowSize.Text="Maximum" Then frmCalls.Maximize else frmCalls.Restore End If

The problem is that when you run under Windows, the window itself flickers. It does not flicker on the Mac (of course) but the flicker is bad under Windows.
It does not look too great.

I was wondering if I could load the code of that open event before the window is painted. That way the flicker would not be seen.

I thought it I loaded the window using just the code :

frmCalls.Hide

it would load the window without showing it, but that does not work. Does anyone know how to load a window without displaying it or know how the above code can be executed without flicker on Windows?

Any help would be greatly appreciated.

in the ide, make the windows far out of the visible screen
when you call new it is created outside the view of the user
then you can call hide if you want
and then you can change the size of the window the way you want

Have you tried by setting the Visible property of the window in the IDE to False?

easier than my solution and I tried it is seems to work … :wink:

[quote=176370:@jean-yves pochez]in the ide, make the windows far out of the visible screen
when you call new it is created outside the view of the user
then you can call hide if you want
and then you can change the size of the window the way you want[/quote]

Under Windows it may not always work. Better make it invisible as default.

Thanks Michel, jean-aves and Eli. Eli’s method works, but I still have all this stuff happening in the window that it still flickers. Very frustrating. When run on Mac, everything looks great. When run in Windows the flicker looks terrible when the window loads. I wish Xojo would fix this flickering problem. I never had flickering when I used to use VB, so I don’t know why Xojo has this constant problem.

What do you mean ? How can it flicker if it is invisible ? Make it invisible in the IDE, and turn it Visible = True only after you are finished loading.

Xojo has more flickering than VB because it is not using .NET. But a lot of flickering can be avoided if you refrain from stacking controls.

Have a look at Reduce flickering in Windows. Old, but still valid.

Hi Eli,

Yes I have seen that post, but the canvas is not the problem at least this time. I’m using Elastic Window, which is suppose to reshape any window to the user’s screen resolution, but in doing so it creates flicker in Windows.

The problem is, that I developed my app in a screen resolution of 1280 x 800. The customer is using a Toughbook that has a screen resolution of 1024 x 768, so when the customer loads the window, its cut off. The Elastic Window, which is no longer supported, is suppose to help that, when it sizes the window it flickers on Windows machines. (Not on Mac) I guess the developer had a falling-out with the folks at Xojo and he is no longer working with Xojo or Elastic Window.

I don’t know of any other tool out there that resizes windows to fit the default screen resolution. I don’t know how other users write their apps so the content of their windows will fit on a 1024 x 768 screen when developed in a higher resolution. I can’t lay out my windows that way, so I have to resort to this Elastic Window control. Its getting frustrating.

I wish Xojo would add this feature to their software. I know there is some talk about Auto layout, but who knows when that will be available. I can’t believe that there would not be a demand for such a control since Windows runs on all sorts of screen sizes from tiny tablets to high resolution monitors. A tool that seamlessly reshapes windows and controls at runtime I would think would be something other developers would want.

[quote=176470:@James Redway]Hi Eli,

Yes I have seen that post, but the canvas is not the problem at least this time. I’m using Elastic Window, which is suppose to reshape any window to the user’s screen resolution, but in doing so it creates flicker in Windows.

The problem is, that I developed my app in a screen resolution of 1280 x 800. The customer is using a Toughbook that has a screen resolution of 1024 x 768, so when the customer loads the window, its cut off. The Elastic Window, which is no longer supported, is suppose to help that, when it sizes the window it flickers on Windows machines. (Not on Mac) I guess the developer had a falling-out with the folks at Xojo and he is no longer working with Xojo or Elastic Window.

I don’t know of any other tool out there that resizes windows to fit the default screen resolution. I don’t know how other users write their apps so the content of their windows will fit on a 1024 x 768 screen when developed in a higher resolution. I can’t lay out my windows that way, so I have to resort to this Elastic Window control. Its getting frustrating.

I wish Xojo would add this feature to their software. I know there is some talk about Auto layout, but who knows when that will be available. I can’t believe that there would not be a demand for such a control since Windows runs on all sorts of screen sizes from tiny tablets to high resolution monitors. A tool that seamlessly reshapes windows and controls at runtime I would think would be something other developers would want.[/quote]

I do not use Elastic Windows but have developed a while ago a similar product for my own use. It may even be a bit more evolved, as it manage font sizes, which is a necessity when you have screen sizes as diverse as 1024x768 up to 2550x1600. I have no plans at this stage to commercialize it, but it may change if the needs arises. Which may very well become the case betwen tablets on one end and hi dpi screens on the other. I am also working on a fully touch enabled interface.

My class works perfectly on Mac in the Resizing event, but I use it only in the Resized event on Windows to prevent flicker. Besides, it is way faster that way.

From what I know of iOS Auto Layout, it is more flexible in certain aspects, as it allows moving controls and making them relative to each other instead of to the window size, but it is also somewhat more limited, as it does not manage font size. No idea when it will arrive for desktop as well.

I am at this moment working on a Windows product and dealing with flicker issues as well. With some precautions, it can be tamed, I think. Fact is I have worked with the new API VB as well, and flicker is present there too. The main trick Metro apps use is full screen display, which allevaites all the window resizing and moving issues.

Hi Michel,

Thanks so much for your message. I know you have no plans to commercialize it, but I was wondering if I can pay you to use your Class in my apps. I write study software for Firefighters, EMTs and Paramedics… you can probably guess that by the fire helmet :slight_smile: The software I write helps firefighters all over the country. I firmly believe that the better we train firefighters, the more lives we can save, both theirs and yours.

I have been spending a lot of time trying to figure out how to get rid of this darn flicker. I would be glad to pay for a solution that could allow me to resize the controls smoothly to a window of any size. I don’t care if it’s perfect. I just need something that is better than what I have. I have been working with professional firefighters for almost 19 years helping them. I want to be able to deliver the best product I can muster up. Getting rid of the flicker in my Windows apps would greatly improve the product.

Let me know if you would be interested in letting me use the Class.

Thanks again.

[quote=176484:@James Redway]Hi Michel,

Thanks so much for your message. I know you have no plans to commercialize it, but I was wondering if I can pay you to use your Class in my apps. I write study software for Firefighters, EMTs and Paramedics… you can probably guess that by the fire helmet :slight_smile: The software I write helps firefighters all over the country. I firmly believe that the better we train firefighters, the more lives we can save, both theirs and yours.

I have been spending a lot of time trying to figure out how to get rid of this darn flicker. I would be glad to pay for a solution that could allow me to resize the controls smoothly to a window of any size. I don’t care if it’s perfect. I just need something that is better than what I have. I have been working with professional firefighters for almost 19 years helping them. I want to be able to deliver the best product I can muster up. Getting rid of the flicker in my Windows apps would greatly improve the product.

Let me know if you would be interested in letting me use the Class. [/quote]

But I thought you already had Elastic Window ? I never got my hands on it, but it must be very complete, as a commercial product.

My class has two methods, Init upon the window Open, and SizAll you call when you need the controls to resize relative to the new window size. If SizAll is called in Resized, it resizes controls during resize, which on Mac is very smooth, but flickers on PC. So I simply call it in Resized. The effect is less spectacular, but since it works only once, the flicker is minimal.

Is it not possible with Elastic Window to do the same ?

Of course edit fails. I meant to write : If SizAll is called in Resizing it resizes controls during resize [which flickers]

Cant say I’ve used elastic window but I know the developer from long ago

Have you tried

  1. set the window in the IDE to NOT be visible
  2. the VERY last line of the windows open event make the window visible

OS X you don’t see this as it has nice double buffering built in.
Win32 doesn’t - and VB did something custom to avoid it as far as I understand.

You might peek into the Windows Functionality Suite and its FreezeUpdates / UnfreezeUpdates methods
From what I know that stops the UI from being redrawn while changes are made then blast them out all at once

I, too, have built a mechanism to size the window and all its controls. The key is to size everything before you make the window visible.

I’m having this flicker problem primarily while resizing of a window.

At one point I decided to do the same as what I saw Microsoft did with a previous version of Outlook: It will only show the resizing frame of the app, no matter how the performance options are set by the user. It won’t show full window while resizing.

One can deactivate and reactivate this behavior, just for one’s own app, and like that you have a workaround for the ugliest flicker situation.

Now some will say that one should never tamper with the user’s settings, but the heck: no one ever complained about me doing this - but they DO complain about the flicker.

I have a module which you can drag from the sample project into your own. Comes with a HowTo readme file.

See thread and download link here:
https://forum.xojo.com/4769-windows-flicker-switch-off-performance-options/p1#p33189

Do you have momentarily overlapping controls when you do the resizing in the Resizing event? That could explain the bad flicker you are seeing. Pay attention to the order in which you move and resize the controls.

[quote=176492:@Norman Palardy]You might peek into the Windows Functionality Suite and its FreezeUpdates / UnfreezeUpdates methods
From what I know that stops the UI from being redrawn while changes are made then blast them out all at once[/quote]

I knew I had read something like that but could not locate it anymore. Thank you Norman.

That should enable a much nicer update when I resize all controls.

[quote=176504:@Oliver Osswald]I have a module which you can drag from the sample project into your own. Comes with a HowTo readme file.
See thread and download link here:
https://forum.xojo.com/4769-windows-flicker-switch-off-performance-options/p1#p33189 [/quote]

Thank you Oliver. Another asset in the Windows bag of tricks :slight_smile:

OK. I just tried Oliver’s WIN module. It is just perfect. Before, when I resized a window, because I could not update the controls size real time, it did not look very good. Now the user sees the future size or position of the window and the update appears instantly.

On the referred thread there is a valid objection : what if the app crashes and does not restore the defaults ? So I added PerformanceOptions_RESTORE in unhandled exception and App.Close as an added precaution.

I also have added FreezeUpdateWFS and UnfreezeUpdateWFS. The result is splendid. Before I had a slight flicker when all controls were resized. Now the window is much more solid.

All that is superb. Thank you, Norman and Oliver, you made my day :slight_smile:

Thank you all for trying to help me. I clumped all my answers into one post.

Michel,

But I thought you already had Elastic Window ? I never got my hands on it, but it must be very complete, as a commercial product.

I do have Elastic Window. I bought it from Christian. It worked great with builds using Carbon. But with Cocoa it does not size the native buttons and it does not size other controls correctly anymore. I guess Christian did not want to work on it anymore so he was trying to sell it. I made my own buttons with Canvases so they would resize with Elastic Window.

Norman:

[quote]Have you tried

  1. set the window in the IDE to NOT be visible
  2. the VERY last line of the windows open event make the window visible[/quote]

Yes, but how do you call the window? The window is not the main window. Its called frmMembers, so how do I load the Window with out showing it and keeping it hidden? I was just using the code frmMembers.Maximize since I wanted it to open full-screen.

Also I looked at the WFS, but I am not sure what I am suppose to download or how to use this. I don’t see any concrete example project.

Tim:

Will your mechanism size the regular Generic Buttons when compile with Cocoa? That’s what elastic Window could not do. Would you consider selling your solution?

Markus,

I am sure I do have some overlapping controls, but I isolated the problem down to Elastic Window… I think. In order to use Elastic Window you need to have a registration number. That number has to be put into the Open Event of each window, and the Super for that window is set for Elastic Window.

The code looks like this

// //Registers Elastic Window If Not Me.Register(“My_Key_Number”) Then End If me.ResizeMode ElasticWindowResizeMode.None

This code is somehow making the window visible for a split second which I think is causing the flicker. If you take these lines out, there is no flicker, but then the controls do not resize and it gives you a msgbox that you are using an unregistered version.

Oliver

Thanks for trying to help. I downloaded your module, and followed your directions below.

1. Add the module WIN to your project 2. Add eventhandlers to your Window1, calling these methods: Activate -> PerformanceOptions_OFF Close -> PerformanceOptions_RESTORE Deactivate -> PerformanceOptions_RESTORE Open -> PerformanceOptions_SAVE

It still flickers, so I don’t know if I am doing something wrong or if its the Elastic Window doing something

I appreciate all the people trying to help. I just don’t know where to go from here.