Altair

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-10-24
14:54
1176 views
Hi, how to close a LoginForm passing control to MDIForm without closing the application?
1 Solution
Accepted Solutions
Chris Glazier

Micro Focus Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-10-24
15:34
Change the main.cbl program to display the loginform first and then start the application with the main form depending on the results of the login.
Example:
main.cbl
class-id winformlogin.Main. method-id Main static attribute System.STAThread. local-storage section. 01 mainForm type winformlogin.Form1. 01 loginForm type winformlogin.LoginForm1. 01 myresult type DialogResult. procedure division. set loginForm to new winformlogin.LoginForm1 set myresult to loginForm::ShowDialog if myresult = type DialogResult::OK set mainForm to new winformlogin.Form1() invoke type System.Windows.Forms.Application::EnableVisualStyles() invoke type System.Windows.Forms.Application::Run(mainForm) else invoke type System.Windows.Forms.Application::Exit end-if goback. end method. end class.
LoginForm1.cbl
class-id winformlogin.LoginForm1 is partial inherits type System.Windows.Forms.Form. working-storage section. method-id NEW. procedure division. invoke self::InitializeComponent() goback. end method. method-id btnOK_Click final private. procedure division using by value sender as object e as type System.EventArgs. set self::DialogResult to type DialogResult::OK invoke self::Close() goback. end method. method-id btnCancel_Click final private. procedure division using by value sender as object e as type System.EventArgs. set self::DialogResult to type DialogResult::Cancel invoke self::Close() goback. end method. end class.
2 Replies
Chris Glazier

Micro Focus Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-10-24
15:34
Change the main.cbl program to display the loginform first and then start the application with the main form depending on the results of the login.
Example:
main.cbl
class-id winformlogin.Main. method-id Main static attribute System.STAThread. local-storage section. 01 mainForm type winformlogin.Form1. 01 loginForm type winformlogin.LoginForm1. 01 myresult type DialogResult. procedure division. set loginForm to new winformlogin.LoginForm1 set myresult to loginForm::ShowDialog if myresult = type DialogResult::OK set mainForm to new winformlogin.Form1() invoke type System.Windows.Forms.Application::EnableVisualStyles() invoke type System.Windows.Forms.Application::Run(mainForm) else invoke type System.Windows.Forms.Application::Exit end-if goback. end method. end class.
LoginForm1.cbl
class-id winformlogin.LoginForm1 is partial inherits type System.Windows.Forms.Form. working-storage section. method-id NEW. procedure division. invoke self::InitializeComponent() goback. end method. method-id btnOK_Click final private. procedure division using by value sender as object e as type System.EventArgs. set self::DialogResult to type DialogResult::OK invoke self::Close() goback. end method. method-id btnCancel_Click final private. procedure division using by value sender as object e as type System.EventArgs. set self::DialogResult to type DialogResult::Cancel invoke self::Close() goback. end method. end class.
Altair

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2013-10-24
19:41
Thanks Chris. Perfect! Thank you very much