|
bankai123 wrote: I can't do that with the Form_Closing event as it stills closes it.
You can. If the user doesn't want to close the form, assign true to the Cancel property of the passed CancelEventArgs instance.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks, that's exactly what I was looking for. I gotta learn to read MSDN better :P
|
|
|
|
|
I have a Main Form call FormA, FormA call a Lookup Form named FormB using following Code
<br />
FormB formb = new FormB();<br />
FormB.Show();<br />
in FormB there is a textboxA to let the user to enter certain string value that need to passback to FormA and execute several statements in FormA when user press a button in FormB
Any1 has any idea how to do that?my fren advise me to use delegate but i not very familiar with delegate coding structure, i greatly appreciated if any1 can provide the sample coding to do that;)
|
|
|
|
|
There are many ways to accomplish your task.
1) Best way would be to make a custom event. As you told that you dont know much about delegates so I think it will be even difficult for you.
2) Make a static method in FormA and call it from FormB's click event handler by either passing it this (FormB object) as an argument if FormB is not class variable in FormA. In that method get all the values from FormB and then you could just close FormB or even destroy it.
3)In the click event handler of FormB, get its Parent by FormB.Parent, this will yeild you the reference to FormA's object. Now you could do anything with it.
You can use any of the above mentioned way. Hope it helps.
Regards
Khalid
|
|
|
|
|
Thanks man, i am trying the method u suggest
|
|
|
|
|
Hi every body,
I have to call a DLL that contain a function follow:
typedef struct _ProStruct {
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
} ProStruct
int MyBuggingFunc(long bDebugMode,ProStruct* pProStruct,TCHAR* Location);
When I call it in C# 2005 such as:
public struct ProStruct{
long hProcess;
long hThread;
int dwProcessId;
int dwThreadId;
}
[DllImport("MyBugFunc.dll",CallingConvention = CallingConvention.Cdecl)]
public static extern int MyBuggingFunc(int bDebugMode,
ProStruct pProStruct,String Location);
private void Form1_Load(object sender, EventArgs e)
{
try
{
ProStruct pPI = new ProStruct();
int ret = MyBuggingFunc((int)(1), pPI, "MyTest.dkt");
}
catch (Exception loi)
{
MessageBox.Show(loi.Message);
}
}
When the form is loaded, there is an error occurs:
"PInvokeStackImbalance was detected
Message: A call to PInvoke function 'WindowsApplication4!WindowsApplication4.Form1::MyBuggingFunc has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
"
I assume some parameters have incorrect type with convention in calling DLL from third party DLL. I tried to fix it many times but I get the the same error.
Could you help me to resolve my problem?
Thanks all of you!
Hoang Quoc Dat
|
|
|
|
|
Your long types are what's wrong. In C++, long is 32-bits long. In C#, long is an alias for System.Int64, which is 64 bits long.
Try this:
public struct ProStruct{
int hProcess;
int hThread;
int dwProcessId;
int dwThreadId;
}
|
|
|
|
|
Thank you very much.
I've tried to fix my problem as you shown but the same error uccurs.
Can you have any ideals to help me?
Thanks again!
Hoang Quoc Dat
|
|
|
|
|
public struct ProStruct{int hProcess;int hThread;int dwProcessId;int dwThreadId;}
Thank you very much.
But I've tried it before but the same error occurs.
Could you have any other ways?
Thanks
Hoang Quoc Dat
|
|
|
|
|
Try this:
[StructLayout(LayoutKind.Sequential)]
public struct ProStruct{
IntPtr hProcess;
IntPtr hThread;
int dwProcessId;
int dwThreadId;
}
|
|
|
|
|
Hi,
I have a situation where I have a class which I would like to be visible within its assembly, but only to be able to be created by a single other class. Ideally I would make the constructor private and the other class a friend and this would solve the problem, but that's not possible in c#. I was hoping there may be some special property of a nested class to allow this but it doesn't seem so.
Can anyone think of another way to do this?
Thanks,
Matt
|
|
|
|
|
There is no clean way. C# sucks.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: There is no clean way. C# sucks.
Aww man...come on now. I come from a C++ and Java background; to me, C# rocks.
|
|
|
|
|
matt cole wrote: I have a situation where I have a class which I would like to be visible within its assembly, but only to be able to be created by a single other class.
Create an interface representing the functionality of the first class. Have the first class implement that functionality as a private class to the second class:
public interface ISomeInterface
{
void DoSomething();
}
public class MyClass
{
private class MyPrivateClass : ISomeInterface
{
public void DoSomething()
{
}
}
public ISomeInterface Create();
{
return new MyPrivateClass();
}
}
Maybe not exactly what you're looking for; you have the interface in your namespace which may not be implemented any where else, but that may not be a problem.
|
|
|
|
|
Hi is it possible to edit a DataRow on a dataset. I am reading an xml file and editing a certian row then exporting the xml file. I know how to delete the row and add a row at the end of the dataset with the updated information but i don't want to have to add it to the end of the dataset evertime i edit a row. Could someone help me out please?
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
ds.Tables[0].Rows[intRow][intCol]= "test";
//or
ds.Tables[0].Rows[intRow]["ColumnName"]= "test";
Tamimi - Code
|
|
|
|
|
HI
i want to encrypt my data and save it to registry and decrypt it and retrieve.
how to do ??
|
|
|
|
|
The .NET framework has a bunch of encryption/decryption algorithms built in to the cryptography namespace. The registry stuff is easily found with google.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
ok . i know, but how to do ?? please help me
|
|
|
|
|
Well, you know where the info is, in the framework. Don't they have google where you live ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
With replies like that you can see why they made him an MVP :P
|
|
|
|
|
|
Hi there...
I am getting crazy with these ugly buttons from visual studio 2003... When i make my programs in C/C++ (allegro), GTK+ for linux and others i have a good support to choose the button style i want to use.
I just wanna know if can i change the style buttons on Visual Studio 2003, C#.
ahhh, not only buttons, radio, check, combo, all things...
thank you guys...
Lucas
|
|
|
|
|
You'll need to design or use someone elses custom controls. The VS03 controls are primarily the stock win32 ones that've been around since NT3.5. IIRC Vista offers a full set of newer shinier ones but you'll need C#3.0 for that.
|
|
|
|
|
dan neely wrote: IIRC Vista offers a full set of newer shinier ones but you'll need C#3.0 for that.
Hm? Isn't it framework 3.0 that is needed, i.e. the format WinFX? C# 3.0 doesn't add anything visual, does it?
---
b { font-weight: normal; }
|
|
|
|