AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jul 17, 2007, 18:14   #1
Академик
 
Join Date: Jan 2002
Location: Shambala
Posts: 6,670
Rep Power: 8
Reputation: 160
Send a message via ICQ to Երեխա
C# ic harc

Zoxovurd uxexs cakvav mi ban sxal em anum ha errora tali

uremn xndirs dasakana

ka MDI application.

MainForm u mek el ChildForm

uzum em ChildForm pakveluc xabar ani MaiNForm in vor pakvela

Dra hamar delegat,event u argument er em haytararum ChildForm i class um senc

publicclassUserRequestEventArgs : EventArgs
{
publicstring Message;
public UserRequestEventArgs(string s)
{
Message = s;
}
}
publicdelegatevoidUserRequest(object sender, UserRequestEventArgs e);
publiceventEventHandler<UserRequestEventArgs> OnUserRequest;


heto ed nuyn CHildForm i classum grum em vor pakveluc

...
if (OnUserRequest != null)
{
UserRequestEventArgs mtcea =
newUserRequestEventArgs("Message from OnOneSecond");
erRequest(sender, mtcea);
}
this.Close();
...

u mek el MAIN FORM i classum

frm.OnUserRequest += newfrmMain.UserRequest();


u mek el asum em ed nuyn MAINFROM um vor

privatevoid UserReq(object sender, UserRequestEventArgs e)
{
MessageBox.Show( e.Message.ToString());
}

vortex frm ed childform i arden stexcac instance a, isk frmMain el MAIN FORMNA

inchna ste sxal zoxovurd???

compile chi linum

xndrum em es xndir asxhatacneq motnerd henc stacvi (henc CHILD formen pakes main forum MessageBox.SHow lini) aseq grem tesnem.
__________________
Ախպեր դու էմիգրացիան տուրիզմի հետ մի խառնի...

http://moskull.livejournal.com/
Երեխա is offline   Reply With Quote Quote selected
Old Jul 18, 2007, 15:55   #2
Академик
 
Join Date: Jan 2002
Location: Shambala
Posts: 6,670
Rep Power: 8
Reputation: 160
Send a message via ICQ to Երեխա
ste C# imacox chka vor uzena indz ogni ?
__________________
Ախպեր դու էմիգրացիան տուրիզմի հետ մի խառնի...

http://moskull.livejournal.com/
Երեխա is offline   Reply With Quote Quote selected
Old Aug 2, 2007, 17:21   #3
Creator
 
Join Date: Jun 2002
Location: Sliema, Malta
Posts: 23
Rep Power: 0
Reputation: 10
I think in MainForm you should add your event hadler in this way:

frm.OnUserRequest += new UserRequest(frmMain.UserReq);
__________________
Делаешь - не бойся, боишься - не делай!
Michellangelo is offline   Reply With Quote Quote selected
Old Aug 3, 2007, 07:23   #4
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,451
Rep Power: 10
Reputation: 144
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Quote:
Originally Posted by Michellangelo
frm.OnUserRequest += new UserRequest(frmMain.UserReq);
или если .NET2.0 или старше просто += frmMain.UserReq.

Но проблема тут в дизайне и не совсем ясно, как будешь потом отписываться от евента, ведь дочерняя форма-то уже может быть диспознутой. Так можно и мемори ликов нахвататься.
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Aug 3, 2007, 13:54   #5
Академик
 
Join Date: Jan 2002
Location: Shambala
Posts: 6,670
Rep Power: 8
Reputation: 160
Send a message via ICQ to Երեխա
zzvum em es anasun C sharp ic C++ ov u Windows messaging ov hastat aveli hamar er, ste dllimport ban man eeheeee
__________________
Ախպեր դու էմիգրացիան տուրիզմի հետ մի խառնի...

http://moskull.livejournal.com/
Երեխա is offline   Reply With Quote Quote selected
Old Aug 3, 2007, 14:09   #6
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,451
Rep Power: 10
Reputation: 144
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Уфффф....
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Aug 17, 2007, 12:53   #7
---
 
TigrOm's Avatar
 
Join Date: Jun 2004
Location: Yerevan
Posts: 9,146
Blog Entries: 1
Rep Power: 6
Reputation: 447
Send a message via ICQ to TigrOm
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class ChildForm : Form
    {
        public ChildForm()
        {
            InitializeComponent();
        }
    }
}
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class MDIForm : Form
    {

        ChildForm chilForm = new ChildForm();
        public MDIForm()
        {
            InitializeComponent();
            chilForm.Show(this);
            chilForm.FormClosed += new FormClosedEventHandler(OnFormClosed);
        }

        private void OnFormClosed(object sender, FormClosedEventArgs e)
        {
            MessageBox.Show(e.CloseReason.ToString());
        }
    }
}
Но ИМХО есть технологии которые избавят от написания такого кода. Smart Client Software Factory (CAB) и подобные...
TigrOm is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:15.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link