Dynamically created windows problem

Discussion forum about all things Team Developer 7.x
Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 761
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Dynamically created windows problem

Post by Igor Ivanovic » 04 Oct 2018, 05:54

Hi guys,

I've been using dynamically created forms (with SalCreateWindowsEx) a lot in my apps, but until now they were a known, fixed size, so it was easy to manipulate them.
Now, I have to create more then one on a, lets call it container form, and I have a problem that if the created form or the sum of forms is larger then the container form I would want it to show scrollbars, but I'm struggling with it.
I know I could use a cSplitterWindow, but I need more than one on a form, and it allows only one.

One solution I was thinking of was to create multiple cSplitterWindows, but it would produce a hierarchy of forms I would rather avoid and I am not sure if it would work.
The problem is that I have very little time to make a prototype and I'm stuck.

So I am asking for a little help here, anything that could point me in the right direction.

Thx.
Igor Ivanovic
Image

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1088
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Dynamically created windows problem

Post by Dave Rabelink » 04 Oct 2018, 08:31

Igor Ivanovic wrote:
04 Oct 2018, 05:54
... problem that if the created form or the sum of forms is larger then the container form I would want it to show scrollbars, but I'm struggling with it.
What is the issue with the scrollbars?

The container form will automatically show scrollbars when the child's get out of view.
First of all, for each child form to create on the container, you need to set the page width and height to a very small number

Code: Select all

Page width : 0.001"
Page height : 0.001"
This is to ensure that the child forms will never show their own scrollbars. Only the container form should have scrollbars.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1088
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Dynamically created windows problem

Post by Dave Rabelink » 04 Oct 2018, 09:02

Another tip:

After the child form is created, the form must be "informed" that a child is now present to manage the container form scrollbars.
I would expect that TD would take care of that when creating the child, but it seems that the form does not initially takes care of the created childs.

To force the container form to display the scrollbars and manage them afterwards when resizing the container, do this:

Code: Select all

Set hWndChild = SalCreateWindowEx( frmChild, hWndForm, nLeft, nTop, nChildWidth, nChildHeight, CREATE_AsChild )
!
Call SalGetWindowLoc( hWndChild , nLeft, nTop )
Call SalSetWindowLoc( hWndChild , nLeft, nTop )
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 761
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Dynamically created windows problem

Post by Igor Ivanovic » 04 Oct 2018, 11:18

Dave,

That's exactly what I was missing! :D :D :D
I knew about the first tip, but I completely missed the second one!

Thank you very much, you saved my day!

Cheers,
Igor Ivanovic
Image

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 761
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Dynamically created windows problem

Post by Igor Ivanovic » 04 Oct 2018, 12:56

Just found out a funny thing.
Using your tip I found out that although I set the left coordinate to zero in CreateWindowEx, the call to:

Code: Select all

Call SalGetWindowLoc( w_hWndChild1 , nLeft, nTop )
would return 0.078 as the nLeft value.

In fact, if I set window location to another something else, and get it with SalGetWindowLoc, the left coordinate will always be 0.078 greater after the call.
I tried with various form attributes (like accessories, menu, etc) enabled and disabled, but I always get the same offset of 0.078 and couldn't get to the reason why.
Is it a known behavior for some reason or just a plain bug?
Igor Ivanovic
Image

Nils Jänicke
Germany
Posts: 15
Joined: 20 Sep 2017, 11:56
Location: Villingen-Schwenningen, Germany

Re: Dynamically created windows problem

Post by Nils Jänicke » 04 Oct 2018, 13:23

Yes this is a bug in TD 7.
Do not use SalGetWindowLoc, use your value of your call of SalCreateWindowEx. Then it should work.

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 761
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Dynamically created windows problem

Post by Igor Ivanovic » 04 Oct 2018, 13:30

Nils,

Did you already opened a ticket or should I do it?
Igor Ivanovic
Image

Nils Jänicke
Germany
Posts: 15
Joined: 20 Sep 2017, 11:56
Location: Villingen-Schwenningen, Germany

Re: Dynamically created windows problem

Post by Nils Jänicke » 04 Oct 2018, 14:03

No. They had fixed a similar problem with dialog boxes (here also SalGetWindowLoc returned a few pxels more on window 10 PC's) with 7.0.5, but for the problem with SalCreateWindowEx and child form window I think there is no ticket yet, Ive done a workaround. It seems that this problem only occurs on Windows 10 and not on all themes.

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 761
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Dynamically created windows problem

Post by Igor Ivanovic » 04 Oct 2018, 14:40

On my system (win10) it behaves the same with all the themes.
I've opened a ticket for it.
Igor Ivanovic
Image

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests