473,466 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with coding

I am trying to get something like this working:

public class classA
{
// Here I want to do something with GetMessage form:
Form f = new getMessage.GetMessage();
f.Show();
does not work. Can that be actually done? Can I work with GetMesasge
form here?
}

public class classB
{

public class GetMessage : Form
{
public GetMessage()
{
Text = "my_unique_id";
}
}
}

Thanks
Aug 20 '08 #1
4 1029
markgoldin <ma*************@yahoo.comwrote:
I am trying to get something like this working:

public class classA
{
// Here I want to do something with GetMessage form:
Form f = new getMessage.GetMessage();
f.Show();
does not work. Can that be actually done? Can I work with GetMesasge
form here?
}
Well, there are a few problems here:

1) There's no such class as getMessage.GetMessage - there's
classB.GetMessage though

2) You're trying to write code directly into a class - aside from
variable initializers, code goes in methods (and properties etc).

If you change your code to:

public class classA
{
void SomeMethod()
{
// Here I want to do something with GetMessage form:
Form f = new classB.GetMessage();
f.Show();
}
}

then it will compile. Of course, you've then got to call SomeMethod...

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 20 '08 #2
On Aug 20, 3:41*pm, "markgoldin" <markgoldin_2...@yahoo.comwrote:
I am trying to get something like this working:

public class classA
{
* * // Here I want to do something with GetMessage form:
* * Form f = new getMessage.GetMessage();
* * f.Show();
* * does not work. Can that be actually done? Can I work with GetMesasge
form here?

}

public class classB
{

* * public class GetMessage : Form
* * {
* * * * public GetMessage()
* * * * {
* * * * * * Text = "my_unique_id";
* * * * }
* * }

}

Thanks
what are you trying to do? not code, but in words
Aug 20 '08 #3
I am trying to adapt some code. Let me show it.
Some parts were removed from the sample.
//DataAdapterLauncher.cs
using System;
using System.Net.Sockets;
using Lightstreamer.DotNet.Server;
using System.Net;
using System.Threading;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class DataAdapterLauncher
{
static void Main(string[] args)
{
Form f = new SocketToLightStreamer.GetMessage();
f.Show();
f.Hide();
ApplicationContext ctx = new ApplicationContext();
Application.Run(ctx);
}
}

//SocketToLightStreamer.cs
using System.Collections;
using System.Threading;
using System;
using System.Runtime.InteropServices;
using Lightstreamer.Interfaces.Data;
using System.Windows.Forms;
public class SocketToLightStreamer : IDataProvider
{
private IItemEventListener _listener;
public void SetListener(IItemEventListener eventListener)
{
_listener = eventListener;
}
public class GetMessage : Form
{
const int WM_COPYDATA = 0x004a;
public GetMessage()
{
Text = "my_unique_id";
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_COPYDATA:
COPYDATASTRUCT mystr = new COPYDATASTRUCT();
Type mytype = mystr.GetType();
mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
IDictionary eventData = new Hashtable();
eventData["scan"] = mystr.Data;
SocketToLightStreamer a = new SocketToLightStreamer();
a._listener.Update("floorupdate", eventData, false);
break;
}
base.WndProc(ref m);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public Int32 ID;
public int Length;
public string Data;
}
}
This code will compile fine, but when I run it I get "null reference" at a
line:
a._listener.Update("floorupdate", eventData, false);

Aug 20 '08 #4
On Wed, 20 Aug 2008 13:14:52 -0700, markgoldin <ma*************@yahoo.com>
wrote:
[...]
This code will compile fine, but when I run it I get "null reference"
at a
line:
a._listener.Update("floorupdate", eventData, false);
What reference is null? I'm presuming the member field "_listener" based
on the code you posted. It seems that the SetListener() method isn't ever
being called with a non-null reference. Do you have any reason to think
that it should have been?

Pete
Aug 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Larry | last post by:
Help Please http://www.angelfire.com/folk/ps197_brooklyn_ny I currently have a main page that has a list of about 50 names. I then have 50 pages that are linked to the main page The...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
9
by: Peter | last post by:
My problem is the last bit of coding below, the like statement does not work. what I have is a product options field and in it is stored characters i.e. "avcy" etc what the query does is...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
0
by: jonipony | last post by:
HELP: Float Left box is drifting to the right in ie! -------------------------- I need som HELP with my CSS coding! On the following web page my design falls apart at screen size 800 x 600...
4
by: m.shidoshi | last post by:
I was recently put in charge of heading up my company's website, and while I have a lot of experience on the design side of things, I'm still very new to the programming side. When I started, the...
14
by: key9 | last post by:
Hi All On coding , I think I need some basic help about how to write member function . I've readed the FAQ, but I am still confuse about it when coding(reference / pointer /instance) , so I...
1
by: al2004 | last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for each team and prints the averages in a neatly formatted table along with the team name....
1
by: bazbella | last post by:
Hi I Need Help To Make A Scroll Box For My Web Page Also Need To Put Some Coding In To It Of A Banner For Poeple To Copy To Display Our Banner On There Page (my Space) Is There Some Sort Of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.