dbf_usr Posted May 23, 2020 Share Posted May 23, 2020 Как из одной формы обратиться к другой форме? Нужно при закрытии модальной формы передать параметр родительской. Заранее благодарен!! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 23, 2020 Share Posted May 23, 2020 20 minutes ago, dbf_usr said: Нужно при закрытии модальной формы передать параметр родительской. Можете использовать callback. К примеру: \FMSoft\Framework\uniGUI\Demos\Desktop\Form Callback Quote Link to comment Share on other sites More sharing options...
dbf_usr Posted May 23, 2020 Author Share Posted May 23, 2020 Спасибо! Quote Link to comment Share on other sites More sharing options...
dbf_usr Posted June 10, 2020 Author Share Posted June 10, 2020 Еще вопрос, а если параметр не один, а список из 10-20 штук и они имеют разный тип? В Form Callback предусмотрен только один Result. За ранее благодарен! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 10, 2020 Share Posted June 10, 2020 Будете ссылаться на форму. Quote Link to comment Share on other sites More sharing options...
dbf_usr Posted June 13, 2020 Author Share Posted June 13, 2020 On 6/11/2020 at 1:39 AM, Sherzod said: Будете ссылаться на форму. а как наоборот. Из открытой формы почитать свойства компонентов формы родителя? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 13, 2020 Share Posted June 13, 2020 1 hour ago, dbf_usr said: а как наоборот. Из открытой формы почитать свойства компонентов формы родителя? При открытии дочерней формы, передать как параметр... Quote Link to comment Share on other sites More sharing options...
dbf_usr Posted June 13, 2020 Author Share Posted June 13, 2020 55 minutes ago, Sherzod said: При открытии дочерней формы, передать как параметр... У меня много параметров, больше 20 Quote Link to comment Share on other sites More sharing options...
Tokay Posted June 14, 2020 Share Posted June 14, 2020 23 hours ago, dbf_usr said: У меня много параметров, больше 20 число параметров в записи (record) фактически не ограничено, можно передавать одну запись с множеством полей. Quote Link to comment Share on other sites More sharing options...
dbf_usr Posted June 15, 2020 Author Share Posted June 15, 2020 15 hours ago, Tokay said: число параметров в записи (record) фактически не ограничено, можно передавать одну запись с множеством полей. Спасибо! Quote Link to comment Share on other sites More sharing options...
x11 Posted June 23, 2020 Share Posted June 23, 2020 Вот один из примеров, может кому пригодится. На главной форме лежит edRemark: TunimEdit. Нужно открыть другую форму (редактирования), передать в неё текст, где можно этот текст отредактировать в memo и вернуть в главную форму, обратно в edRemark. procedure TfmmMainform.edRemarkTriggerEvent(Sender: TUniFormControl; AButtonId: Integer); begin inherited; if AButtonId = 0 then begin fmmShowMemo := TfmmShowMemo.Create(UniApplication); fmmShowMemo.Caption := TUnimEdit(Sender).EmptyText; fmmShowMemo.memo1.Text := TUnimEdit(Sender).Text; fmmShowMemo.ShowModal(RemarkTriggerCallbackAnonProc);// передаем процедуру обратного вызова end; end; procedure TfmmMainForm.RemarkTriggerCallbackAnonProc(Sender: TComponent; Res: Integer); Var Component: TComponent; begin if Res <> mrOk then exit; // нужно убедиться, что данная процедура была вызвана для формы if Sender is TUnimForm then Component := (Sender as TUnimForm).FindComponent('memo1')// ищем на форме редактирования memo else exit;// Sender не является формой //если не нашли memo1 if not Assigned(Component) then exit; //нашли memo1 if Component is TUnimMemo then edRemark.Text := TUnimMemo(Component).Text; end; Quote Link to comment Share on other sites More sharing options...
x11 Posted June 23, 2020 Share Posted June 23, 2020 Вместо FindComponent можно использовать IsPublishedProp(). Вот ещё один пример. На форме выбора есть дерево, пользователь что-то выбирает в дереве и нажимает ОК. На форме выбора в разделе published есть свойство "SelectedList", в котором будет храниться то, то выбрал пользователь с помощью чекбоксов: property SelectedList: TDictionary<Integer, String> read FSelectedList; т.е. когда пользователь щелкает по чекбоксам, то меняется свойство FSelectedList. procedure TfmmSearchParams.uniDialogCallbackAnonProc(Sender: TComponent; Res: Integer); Var form: Tcomponent; pair: TPair<Integer, string>; list: TDictionary<Integer, String>; begin if Res <> mrOk then exit; list := nil; if Sender is TUnimForm then form := (Sender as TUnimForm) // проверяем, чтобы была форма (форма выбора) else exit; //ищем на форме выбора свойство SelectedList if IsPublishedProp(form, 'SelectedList') then List := GetObjectProp(form, 'SelectedList', TDictionary<Integer, String>) as TDictionary<Integer, String>; //если нашли на форме выбора свойство SelectedList if Assigned(List) then for pair in list do DicRegions.AddOrSetValue(pair.Key, pair.Value);// DicRegions - глобальная переменная текущего модуля Button1.Caption := 'Количество выбранных узлов - ' + DicRegions.Count.ToString; end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.