Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting WindowState to wsMaximmized in TForm.OnCreate event causes exception #95

Closed
ray-tmsk opened this issue May 30, 2018 · 8 comments
Assignees
Labels
Milestone

Comments

@ray-tmsk
Copy link

I have application on Delphi XE7 with ribbon, all OK. Now time for switch to xe 10.2.3.
One user can not use application after then (compiled with xe 10.2.3)
Exception on start "An error occurred while trying to load Ribbon resource "APPLICATION" ....(80004005)

I can not reproduce problem on my computers. In user computer xe7 build work - xe10 build no.
I may provide both builds for test.

Now need good way for hide this exception and provide usual toolbars instead of ribbon. Will be good if TUIRibbon.Load() not generate exception. Because now exception was generated via internal calls (CMVisibleChanged->UpdateControlState->UpdateShowing->CreateHandle->CreadeWnd,Load)
Not easy to catch such exception...
I think setting FLoaded := False in TUIRibbon.Load() will enough for detecting that troubles with ribbon loading.

@joachimmarder
Copy link
Contributor

Does the XE7 build work for this user?
Which Windows versions does this user use?

It would be good to have a more detailed call stack like it is provided by MadExcept or EurekaLog.

@ray-tmsk
Copy link
Author

Yes, xe7 build work.
User work in latest server 2016

No experiments with call stack.
But it must be standard. Try to raise exception instead of framework.loadui

@Smile64
Copy link

Smile64 commented May 31, 2018

The same thing happened to me after upgrading from XE3 to 10.2.3. I noticed the ribbon always fails to load its resource when the form starts in wsMaximized state. I had to switch back to wsNormal, and maximize the form in its OnShow event. That solved the problem for me.

@joachimmarder
Copy link
Contributor

I noticed the ribbon always fails to load its resource when the form starts in wsMaximized state.

We are using 10.2.3 as well and so far could not see this behavior. I just tried the included sample project 07 Text Pad with Action List, set the WindowState property to wsMaximized and run the program. I could not see any failure. I used the latest source from this repository.

Can you please try if you are able to replicate the issue with this sample project?

@Smile64
Copy link

Smile64 commented Jun 4, 2018

OK, it seems, I was wrong. Setting WindowState to wsMaximized in the IDE does not cause an error. Writing WindowState := wsMaximized in FormCreate does. In the sample project too.

I use a component to restore the form's previous state when starting the program. This component sets WindowState programmatically if needed. My forms always failed to open when they were closed in maximized state on the previous run. What I actually did was that I've rewritten the component's code preventing it to save the wsMaximized state, so the forms were always reloaded in wsNormal state. Then I maximized them in OnShow if it was necessary.

In my previous comment I oversimplified things. Sorry. :)

@ray-tmsk
Copy link
Author

ray-tmsk commented Jun 4, 2018

Bingo! Thank you Smile64!
Now I can reproduce trouble too. Easy to fix while see it.
One question remains: why xe7 project work?

@joachimmarder
Copy link
Contributor

Writing WindowState := wsMaximized in FormCreate does. In the sample project too.

Confirmed.

@joachimmarder joachimmarder changed the title Sometime ribbon (build with xe 10.2.3) not loaded Setting WindowState to wsMaximmized in TForm.OnCreate event causes exception Jun 4, 2018
@joachimmarder
Copy link
Contributor

TCustomForm.SetWindowState() calls RecreateWnd(), however the csRecreating is missing in TCustomForm.ControlState. So the test for this flag in TUIRibbon.CreateWnd() brings an unexpected result. The flag might have been correctly inlcuded in XE7.

@joachimmarder joachimmarder self-assigned this Jun 4, 2018
@joachimmarder joachimmarder added this to the V2.5 milestone Jun 4, 2018
SaschaSchaefer added a commit that referenced this issue Sep 6, 2018
- Separated creation and initialization of the ribbon framework. Constructor will now only perform non UI/handle related initialization of the framework
- Load() will now call HandleNeeded before passing the parent form's handle to FFramework.Initialize. That way, recreating the window handle of the form no longer causes issues
- ApplicationModes are now restored when recreating the window handle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants