Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Create TIWFrame dynamically (and place in TIWModalWindow)



Permlink Replies: 2 - Last Post: Jan 15, 2018 2:56 AM Last Post By: Denville Longhu... Threads: [ Previous | Next ]
Denville Longhu...

Posts: 57
Registered: 3/4/06
Create TIWFrame dynamically (and place in TIWModalWindow)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 14, 2018 9:01 AM
I would like to create a TIWFrame dynamically and place it as the content of a TIWModalWindow. I have done this previously (following advice I found on-line) by placing a TIWRegion on the main form, placing an instance of the frame in that, and assigning the aforementioned region as the ContentElement of the ModalWindow.

Now I plan to have a considerable number of frames each dealing with a specific topic and I want to show them in the ModalWindow; I do not want to clutter up the main form with (albeit invisible) regions each containing a specific frame, both because it really mucks up the form designer and because I don't want to go through that when I add another frame. So I am trying to achieve this by creating a specific frame on demand, and assigning it to the one region placed on the main form for this purpose. (I would like to do that dynamically also, but that can wait.)

I have trawled and tried and followed every bit of (often contradictory) advice I have found but without success. I simply cannot get the frame to render within the region. In order to reduce the problem to its basics, I have bypassed the ModalWindow and simply look to see the frame rendered on the form within the region. Using the code below, the region sizes correctly but simply present blank (in its native assigned pink colour). No sign whatsoever of the frame (trivially simple, just a green background with a single button it, just for something to see).

static T_IWFrame1* RwsHelperFrame3;

void __fastcall TIWForm3::IWButton2AsyncClick(TObject *Sender, TStringList *EventParams)
{
if ( RwsHelperFrame3 == NULL )
{
RwsHelperFrame3 = new T_IWFrame1( WebApplication );
RwsHelperFrame3->Name = "RwsHelperFrame3";
}

IWRegion4->Width = RwsHelperFrame3->Width;
IWRegion4->Height = RwsHelperFrame3->Height;
RwsHelperFrame3->Parent = IWRegion4;
RwsHelperFrame3->Top = 0;
RwsHelperFrame3->Left = 0;

// IWModalWindow1->Reset();
// IWModalWindow1->Title = "Testing Frame";
// IWModalWindow1->Buttons->CommaText = "ENTER,Cancel";
// IWModalWindow1->ContentElement = IWRegion4;
// IWModalWindow1->Show();
}

Here IWRegion4 is the TIWRegion placed on the main form. I reccon If I can get the simplified version working, the ModalWindow bit will work too.

Can anyone tell me what I am doing wrong ? Many thanks.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: Create TIWFrame dynamically (and place in TIWModalWindow)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 14, 2018 9:18 AM   in response to: Denville Longhu... in response to: Denville Longhu...
Denville Longhurst wrote:
I would like to create a TIWFrame dynamically and place it as the content of a TIWModalWindow. I have done this previously (following advice I found on-line) by placing a TIWRegion on the main form, placing an instance of the frame in that, and assigning the aforementioned region as the ContentElement of the ModalWindow.

Now I plan to have a considerable number of frames each dealing with a specific topic and I want to show them in the ModalWindow; I do not want to clutter up the main form with (albeit invisible) regions each containing a specific frame, both because it really mucks up the form designer and because I don't want to go through that when I add another frame. So I am trying to achieve this by creating a specific frame on demand, and assigning it to the one region placed on the main form for this purpose. (I would like to do that dynamically also, but that can wait.)

I have trawled and tried and followed every bit of (often contradictory) advice I have found but without success. I simply cannot get the frame to render within the region. In order to reduce the problem to its basics, I have bypassed the ModalWindow and simply look to see the frame rendered on the form within the region. Using the code below, the region sizes correctly but simply present blank (in its native assigned pink colour). No sign whatsoever of the frame (trivially simple, just a green background with a single button it, just for something to see).

static T_IWFrame1* RwsHelperFrame3;

void __fastcall TIWForm3::IWButton2AsyncClick(TObject *Sender, TStringList *EventParams)
{
if ( RwsHelperFrame3 == NULL )
{
RwsHelperFrame3 = new T_IWFrame1( WebApplication );
RwsHelperFrame3->Name = "RwsHelperFrame3";
}

IWRegion4->Width = RwsHelperFrame3->Width;
IWRegion4->Height = RwsHelperFrame3->Height;
RwsHelperFrame3->Parent = IWRegion4;
RwsHelperFrame3->Top = 0;
RwsHelperFrame3->Left = 0;

// IWModalWindow1->Reset();
// IWModalWindow1->Title = "Testing Frame";
// IWModalWindow1->Buttons->CommaText = "ENTER,Cancel";
// IWModalWindow1->ContentElement = IWRegion4;
// IWModalWindow1->Show();
}

Here IWRegion4 is the TIWRegion placed on the main form. I reccon If I can get the simplified version working, the ModalWindow bit will work too.

Can anyone tell me what I am doing wrong ? Many thanks.

Your problem is that you are doing it in an async event. The modal "stuff" needs to be pushed down to the client with the main form rendering.

You can show it and change components with async but they have to be present on the form. You just can't create it in async.

Dan
Denville Longhu...

Posts: 57
Registered: 3/4/06
Re: Create TIWFrame dynamically (and place in TIWModalWindow)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2018 2:56 AM   in response to: Dan Barclay in response to: Dan Barclay
Dan Barclay wrote:
Denville Longhurst wrote:
I would like to create a TIWFrame dynamically and place it as the content of a TIWModalWindow. I have done this previously (following advice I found on-line) by placing a TIWRegion on the main form, placing an instance of the frame in that, and assigning the aforementioned region as the ContentElement of the ModalWindow.

Now I plan to have a considerable number of frames each dealing with a specific topic and I want to show them in the ModalWindow; I do not want to clutter up the main form with (albeit invisible) regions each containing a specific frame, both because it really mucks up the form designer and because I don't want to go through that when I add another frame. So I am trying to achieve this by creating a specific frame on demand, and assigning it to the one region placed on the main form for this purpose. (I would like to do that dynamically also, but that can wait.)

I have trawled and tried and followed every bit of (often contradictory) advice I have found but without success. I simply cannot get the frame to render within the region. In order to reduce the problem to its basics, I have bypassed the ModalWindow and simply look to see the frame rendered on the form within the region. Using the code below, the region sizes correctly but simply present blank (in its native assigned pink colour). No sign whatsoever of the frame (trivially simple, just a green background with a single button it, just for something to see).

static T_IWFrame1* RwsHelperFrame3;

void __fastcall TIWForm3::IWButton2AsyncClick(TObject *Sender, TStringList *EventParams)
{
if ( RwsHelperFrame3 == NULL )
{
RwsHelperFrame3 = new T_IWFrame1( WebApplication );
RwsHelperFrame3->Name = "RwsHelperFrame3";
}

IWRegion4->Width = RwsHelperFrame3->Width;
IWRegion4->Height = RwsHelperFrame3->Height;
RwsHelperFrame3->Parent = IWRegion4;
RwsHelperFrame3->Top = 0;
RwsHelperFrame3->Left = 0;

// IWModalWindow1->Reset();
// IWModalWindow1->Title = "Testing Frame";
// IWModalWindow1->Buttons->CommaText = "ENTER,Cancel";
// IWModalWindow1->ContentElement = IWRegion4;
// IWModalWindow1->Show();
}

Here IWRegion4 is the TIWRegion placed on the main form. I reccon If I can get the simplified version working, the ModalWindow bit will work too.

Can anyone tell me what I am doing wrong ? Many thanks.

Your problem is that you are doing it in an async event. The modal "stuff" needs to be pushed down to the client with the main form rendering.

You can show it and change components with async but they have to be present on the form. You just can't create it in async.

Dan

Well blow me down ! Works beautifully. Thank you.

Denville.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02