|
struct Test
{
int iCount;
}
static void main ()
{
Test T1;
Add objAdd=new Add(ref T1);
MessageBox.Show(Convert.ToString(T1.iCount));
}
class Add : Form
{
Test t;
public Add(ref t1)
{
t=t1;
}
public btnNext_Click(object sender,EventArgs e)
{
t.iCount++
}
}
In the main function, a structure of type Test is created . I am passing this as a ref to a Form class Add.
The form class has a button, a click on which will increment the iCount of the structure by 1.
When the form closes, control returns to main() , where the iCount is to be displayed.
The problem is this, in Class Add I need to store the reference of the structure for future use. But this is not happening, in the constructor of Add, the reference t1 is being assigned to t. But, the declaration of t in the class initializes a new instance of the structure and therefore any changes to the structure is not getting reflected in the structure T1, when control return to main().
What can be done here? I cannot change the design of the application.
Help would be deeply appreciated.
-- modified at 6:39 Thursday 11th May, 2006
|
|
|
|
|
You have to make Test a class, or wrap it in a class before passing it to the Add function. Something like
struct Test
{
int iCount;
}
class TestWrapper
{
public Test test;
public TestWrapper(Test test) { this.test = test;}
}
class Add : Form
{
public Add(TestWrapper t)
{
t.test.iCount = 2;
}
}
static void Main()
{
TestWrapper w = new TestWrapper(new Test());
Add a = new Add(w);
Console.WriteLine(w.test.iCount);
}
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Hello, i need to call c# dll on vb.6 program,
i try this:
using System;
c# class:
namespace COMInterop
{
public class TestCom
{
public TestCom()
{
}
public string Hello()
{
return "hello";
}
}
}
then i go to vb6 , i add the reference on my COMInterop.tlb
and i copy the dll on the working folder of vb6 program.
vb6 code :
Private Sub Form_Load()
Dim temp As New COMInterop.TestCom
MsgBox(temp.Hello)
End Sub
and it work properly.
but on this way i have to add the reference on my vb6 project.
how can i use my dll without doing this?
i try to do:
Private Sub Form_Load()
Dim temp As Object
Set temp = CreateObject(TestCom)
End Sub
but this give me an error:
Run-Time error '429':
ActiveX component can't create object
Some one can help me? thanks
|
|
|
|
|
Cliffer wrote: but on this way i have to add the reference on my vb6 project.
how can i use my dll without doing this?
You can't. None of the Managed Code languages support exporting methods in a way that would allow you do this. You have to go through the COM reference to get at a Managed Code .DLL's methods.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
As you have a MVC pattern it should definitely be handled by the view. I assume every game object has a view assigned to it which controls how it is displayed. This one should also decide what image to use.
|
|
|
|
|
i am using vs2003 c# ,from couple of days i am facing
a strange problem,the problem is that
when iam trying to display message box
messagebox.show("some string","message");
the messagebox is showing the caption but
but displaying empty box,i.e main message
"some string" is not showing in message box.
and when i am showing combobox the selected item
is coming in combobox but while dropping down the list
from combobox the list of items is not displaying though
it is populating and when i am selecting blank item
after selection that item is displaying in combo text box.
same thing is happening with listbox also
please can any body help me out
rahul
|
|
|
|
|
Very interesting !
Can you show us that string ?
I think, your problem is in encoding.
Best regards, Alexey.
|
|
|
|
|
i am not using any special string iam just using
simple code to show message box
i.e messagebox.show("My message");
and blank message box is displaying
and i am binding combobox with
dataset it is pouplating but blank list
is coming on dropping down
i don't know why it is happening
becouse a week back every thing was working fine
rahul
|
|
|
|
|
Try running your application on another computer.
If there is no bug - reinstall your system.
Best regards, Alexey.
|
|
|
|
|
|
NHibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
at NHibernate.Impl.SessionImpl.CheckId(Object obj, IClassPersister persister, Object id)
at NHibernate.Impl.SessionImpl.FlushEntity(Object obj, EntityEntry entry)
at NHibernate.Impl.SessionImpl.FlushEntities()
at NHibernate.Impl.SessionImpl.FlushEverything()
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
I get this error when I'm deleting some items (and sub items) form my database, I'm using NHibernate for my Datalayer. Does anybody knows what's going wrong or where I have to start looking what's causing this error?
|
|
|
|
|
Hi,
I would like to ask if anyone could give me an advice.
I want to play a video file, but not from a file or url but from a stream.
I was looking for some examples but I only found smaples that are playing videos from a files.
-- modified at 4:39 Thursday 11th May, 2006
|
|
|
|
|
try saving the stream to a temporary file
|
|
|
|
|
Thanks, but it isn't solution for my problem.
I'm looking for some advice how to play a video from a memory buffer or a stream.
File using is not efficient.
|
|
|
|
|
Hi,
Can we have a ListBox ValueMember Collection?
If we have SelectionMode as MultiExtended, and we select more than one values in the listbox, then can we show its respective value member as we can show the SelectedIndices (Collection of selected index)
If there is a way could you please post an example with it..
And if there is not then What are the alternatives (without using and temp array to kepp track of it..some memory mgmt is required here)
Thanks a lot
|
|
|
|
|
try out following codes
for(int i=0;i < listBox1.Items.Count;i++)
{
if(listBox1.GetSelected(i))
{
MessageBox.Show("",listBox1.GetItemText(listBox1.Items[i]));
}
}
rahul
-- modified at 5:25 Thursday 11th May, 2006
|
|
|
|
|
This would work absolutely fine, but you did not get my problem
I am displaying some value in the listbox and actually require some different value, say for e.g. i am showing names in the box whereas if the user selects a name i am retriving the corresponding employee ID for that name. Now this scenario is possible through ValueMember and DisplayMember property of ListBox.
DisplayMember = name
ValueMember = empId
Now the code which you gave me works fine if i need to retrive the DisplayMembers from listbox..
My question though,here was i needed the ValueMembers to corresponding selection
Thanks a lot
-- modified at 6:14 Thursday 11th May, 2006
|
|
|
|
|
Hi,
when I load an image using this
Bitmap bitmap = (Bitmap)Image.FromFile(pic.Path) ,
it is not possible to delete the file afterwards, unless you exit the program. I tried to call .Dispose() on the object, but it seems like a bug in the FromFile method.
I found out a workaround
Bitmap origbmp = new Bitmap(pic.Path);<br />
Bitmap bitmap = new Bitmap(origbmp);<br />
origbmp.Dispose(); .
I keep working with the copy of the original bitmap as it's not locked anymore.
But, loading an image using Bitmap 's constructor, it's impossible to load animated GIFs as it seems that Bitmap doesn't support them.
Now, how can I use animated GIFs and other image formats AND be able to delete the file afterwards?
Thx
Stefan
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
Don't pat yourself on the back too hard. This has been known for at least 4 years now, and it's not exactly a bug. Though, some people would probably argue that it is.
An eaiser method would be to load the bitmap from a FileStream instead of creating two Bitmaps to get one. You can read more about it in this[^] KB article on MSDN.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: This has been known for at least 4 years now, and it's not exactly a bug. Though, some people would probably argue that it is.
When you call .Dispose() and the handle won't get free, it's a bug!
Dave Kreskowiak wrote: You can read more about it in this[^] KB article on MSDN.
Thank you, that worked!
Regards,
Stefan
|
|
|
|
|
Hi to all
I am working on a project of developing client/chat server software in .net. The textual chatting software has been devoloped and is working well. But now I have been asked to add another feature of audio/video conferencing(chatting) into the chatting software. But i have no clues. Can anybody suggest me resources on net or any guideline..plz help.
-- modified at 7:40 Thursday 11th May, 2006
|
|
|
|
|
hi...
i just wanted to make an ftp client without making an ftp server... actually wanted to make a client that downloads files from an ftp server some where... now the problem that i am facing is that i can't get an ip to where i can submit my requests on port 20.... plz provide help in this regard that is ... is it possible to only develop a client and not a server... secondly wat ip would be used in this regard...
thanx
haseeb
|
|
|
|
|
|
What do you mean? If you want to download files from an FTP server, you have to know what server it is you want to download from.
---
b { font-weight: normal; }
|
|
|
|