|
If assume you have a master panel called "panelMaster". Inside this, you have 10 sub panels "panel1", "panel2", ... "panel10". You can set "AutoScroll" to true for "panelMaster" and your app will display vertical scrollbars when panelMaster is not large enough to fit and display all of the subcontrols.
- Malhar
|
|
|
|
|
but i've 1000 or more panels inside, so how can i do?
|
|
|
|
|
I need this because i'm constantly leaving my USB thing in the computer, so the idea is, app runs when usb is inserted, if i log off and i've left my stick, logoff is paused/stoped, and i get a message telling me to remove it.
(this wouldn't be so bad if it was only my home computer)
|
|
|
|
|
Usually when a "stick" is connected to a pc, it has a drive letter assigned.
Test for that and then display your message. In XP the "shutdown -a" command will abort
a shutdown of the pc.
|
|
|
|
|
I have a requirement to use a dll written in Visual C++ 6.0 in my C# application. In order to establish the link between my application and the dll, I have written a ATL COM Component in Visual C++.NET [visual studio .NET version 8]. This COM component is referenced in my C# application. The COM component statically links with the 6.0 dll.
I am facing problems in passing data from C# to the dll through the COM component.
Description:
1. The dll exposes a function as:
__declspec(dllexport) int __stdcall ProblemFunction(int param1, BYTE param2, BYTE param3, BYTE *param4, DWORD *param5);
2. In the COM wrapper component, I have declared an interface method as:
[id(25), helpstring("method ProblemFunc")] HRESULT ProblemFunc([in] SHORT param1, [in] BYTE param2, [in] BYTE param3, [in, out] BYTE* param4, [in, out] LONG* param5, [out, retval] BYTE* param6);
where, param6 is used to return the value returned by dll function to the C# client application.
The implementation of this interface function is given below:
STDMETHODIMP
Wrapper::ProblemFunc(SHORT param1, BYTE param2, BYTE param3, BYTE* param4, LONG* param5, BYTE* param6)
{
*param6 = ProblemFunction(param1, param2, param3, param4, (DWORD*)param5);
return S_OK;
}
3. In the C# client application, I am calling the COM function as:
byte returnValue = DllWrapperObject.ProblemFunc(value1, (byte)value2, (byte)value3, ref value4, ref value5);
Here, I am facing problems passing value4 and value5 because:
a. For value4 I need to pass a structure.
b. For value5 I need to pass the size of the structure being passed in value4.
The structure to be passed is as required by the dll. The C++ structure is:
typedef struct
{
DWORD var1;
DWORD var2;
struct
{
DWORD var3;
char var4[16];
DWORD var5;
} var6[3];
} TEST_STRUCT;
I wrote the structure's equivalent in C# as a class as I had to create an array. The C# implementation of the above given structure is:
internal class InnerStruct
{
long var3;
char[] var4 = new char[16];
long var5;
internal static int GetSizeOfClass()
{
return (sizeof(long) + sizeof(char) * 16 + sizeof(long));
}
}
internal class TestStruct
{
long var1;
long var2;
InnerStruct[] var6 = new InnerStruct[3];
internal static int GetSizeOfClass()
{
return (sizeof(long) * 2 + InnerStruct.GetSizeOfClass() * 3);
}
}
Questions:
1. Is there any better way to define the structure equivalent in C#?
2. How can I get the size of the structure/class for passing it to the dll?
3. How to pass the handle of the structure/class object from C# to the dll so that it can fill it up and return it to the client app for future usage?
|
|
|
|
|
Ok,
You can define your C# structure like this:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct InnerStruct
{
public int var3;
[MarshalAs(ByValTStr, SizeConst = 16)]
public string var4;
public int var5
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
public InnerStruct[3] var6;
}
2. uint structSize = Marshal.Sizeof( typeof( TestStruct ) );
3.
TestStruct ts = new TestStruct();
ProblemFunc( value1, value2, value3, ref ts, structSize );
Deus caritas est
|
|
|
|
|
Thanks for replying to the query, but the problems do not get fixed... I am still facing problems with the following:
1. I cannot define array of structures as mentioned:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
public InnerStruct[3] var6;
}
when I compile the code, I get the error as:
Array size cannot be specified in a variable declaration (try initializing with a 'new' expression).
2. I cannot use the new operator inside structures, like this:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
public InnerStruct[] var6 = new InnerStruct[3];
}
when I compile this code, I get the error as:
'TestStruct': cannot have instance field initializers in structs.
3. As I had mentioned earlier, the VC++ 6.0 dll expects a byte pointer. To call the ProblemFunction() from a code in VC++ 6.0, I will be passing the information as:
TestStruct testVar;
int size = sizeof(testVar);
ProblemFunction(value1, value2, value3, (BYTE *)&testVar, &size);
Now that I have written the wrapper on same lines, the ProblemFunc needs proper values. That means that I need to somehow pass TestStruct object defined in C# as a byte pointer to the COM function ProblemFunc()
Can you please help me out with this....
Regards,
Nataraj.
|
|
|
|
|
Ok, change your TestStruct to look like this
StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct TestStruct
{
public int var1;
public int var2;
[MarshalAs(UnmanagedType.LPArray, SizeConst = 3)]
public InnerStruct[] var6;
}
TestStruct ts = new TestStruct();
uint sizeStruct;
System.IntPtr p;
ts.var6 = new InnerStruct[3];
structSize = Marshal.Sizeof( typeof( TestStruct ) );
p = Marshal.AllocHGlobal( structSize );
Marshal.StructureToPtr( ts, p, true );
ProblemFunction(value1, value2, value3, p, structSize );
Marshal.FreeHGlobal( p );
Deus caritas est
|
|
|
|
|
|
|
hi,
Why this code has no effect?
RegistryKey regKey ;
string strServiceName = "";
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\9");
strServiceName = regKey.GetValue("ServiceName").ToString();
regKey.Close();
regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\" + strServiceName + "\\Parameters\\Tcpip", true);
regKey.SetValue("IPAddress", Encoding.ASCII.GetBytes("10.1.1.1/0/0"));
regKey.Close();
|
|
|
|
|
This code will be hugely unreliable as this registry path "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\9" will not exist on all PC's - mine inclusive.
When I do locate the info on my local machine, it is in ... \CurrentVersion\NetworkCards\2. Following the service name through to SYSTEM\CurrentControlSet\etc leads me to the IPAddress you are trying to set, but bad news - its set to 0.0.0.0 (probably because im on a company LAN - so all the dhcp settings etc are set instead)
Maybe go back to the drawing board and consider what it is you are actually trying to accomplish, and if there is another way to do so!
|
|
|
|
|
|
The easiest way it to run something like the following thru a Process:
netsh interface ip set address "Local Area Connection" static 192.168.0.2 255.255.255.0 192.168.0.1 0
|
|
|
|
|
|
hi
i a want to inject process in other process. how to that in c#.net ?
Please give an example or source or article in c#.net ..
thanks
|
|
|
|
|
Are you not listening? You cant! Thats why its called a managed SECURE environment!
|
|
|
|
|
Firstly, you cannot inject a process into another process; however, you can inject a DLL into another process. Secondly, it is not a good idea to try to insert a .NET assembly into another process, because that process may have another version of the .NET framework already loaded that your assembly is not compatible with, or, worse, it may depend on the .NET Framework in some way, but may not have loaded it yet - and in inserting the .NET assembly, you may make the process be unable to load the framework version that it needs.
For these and many other reasons, I strongly advise against trying to do this with .NET. I also think that you should read up a lot better on all the details of DLL injection before you try to do it (in an unmanaged language).
|
|
|
|
|
I have a webservice and I need to log the full SOAP message.
I need to get the full SOAP message, including both SOAP Header and SOAP Body.
[WebMethod]
public string MyMethod()
{
string szSOAPMessage = "";
string szReply = "";
szSOAPMessage = ????(); // This is the part I need to know
Log( szSOAPMessage );
DoSomething();
return szReply;
}
Does anybody know how to get it?
|
|
|
|
|
It doesnt really happen like that... the SOAP message actually specifies how to call "MyMethod", what parameters to pass to it, and what response to expect.
If you compile your webservice and view it in a browser by entering debug, or browsing directly, you will see it lets you call your webmethods to test them. These pages will display a great deal of info on the format of the messages sent.
To access the actual soap message in transit, you need to go one step above your actual method, to the proxy class generated for you when you add a web reference (it can be viewed by going to Project>View all files in the menu of VS).
|
|
|
|
|
Hello,
Have a look at SoapExtension class in MSDN. Also see this
HTH. Cheers
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
how to display image in specified cell loading from sql - table...
Regards...
|
|
|
|
|
You have to provide more information for someone to be able to answer your question.
What kind of cell? How do you specify it? What are you loading? How is the sql involved? What kind of table?
---
b { font-weight: normal; }
|
|
|
|
|
I have posted some pictures in my SQL - Table, column photo(img type) contains pictures.
now i want to display picture in specified cells of gridview.
example gridviewColumn Picture should laod picture(s) from (SQL-Table) column photo.
Hope u can understand question.
Regards
|
|
|
|
|
Hi all,
can anyone tell me why my(Test) custom property is value can not be stored.
Its always null.Its displaying in property window and getting user input.
Thanks in advance..
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
namespace EMS.NET
{
[ToolboxItem(false)]
public class JTextBoxColumn : System.Windows.Forms.DataGridViewColumn
{
public JTextBoxColumn(): base(new JTextBoxCell())
{
}
private String mTest;
[TypeConverter(typeof(StringConverter))]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public String Test
{
get { return mTest; }
set { mTest = value; }
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
if (value != null && !value.GetType().IsAssignableFrom(typeof(JTextBoxCell)))
{
throw new InvalidCastException("Must be a Text Box Cell");
}
base.CellTemplate = value;
}
}
}
[ToolboxItem(false)]
public class JTextBoxCell : DataGridViewTextBoxCell
{
public JTextBoxCell()
: base()
{
}
private String mTest;
public String Test
{
get { return mTest; }
set { mTest = value; }
}
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
JTextBoxEditingControl ctl = DataGridView.EditingControl as JTextBoxEditingControl;
ctl.Dock = DockStyle.Fill;
if (this.Value == null || this.Value.ToString() == System.DBNull.Value.ToString())
ctl.Text = "Null";
else
ctl.Text = this.Value.ToString();
}
public override Type EditType
{
get
{
// Return the type of the editing contol that CalendarCell uses.
return typeof(JTextBoxEditingControl);
}
}
public override string ToString()
{
return "JTextBoxCell";
}
public override Type ValueType
{
get
{
// Return the type of the value that CalendarCell contains.
return typeof(String);
}
}
public override object DefaultNewRowValue
{
get
{
// Use the current date and time as the default value.
return DBNull.Value.ToString();
}
}
}
[ToolboxItem(false)]
public class JTextBoxEditingControl : TextBox, IDataGridViewEditingControl
{
private int RowIndex;
private DataGridView _DataGridView;
private bool _DataChanged;
public JTextBoxEditingControl()
{
}
public void PrepareEditingControlForEdit(bool selectAll)
{
// No preparation needs to be done.
}
public Cursor EditingPanelCursor
{
get
{
return base.Cursor;
}
}
public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
{
return EditingControlFormattedValue;
}
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
{
this.Font = dataGridViewCellStyle.Font;
this.ForeColor = dataGridViewCellStyle.ForeColor;
this.BackColor = dataGridViewCellStyle.BackColor;
}
public DataGridView EditingControlDataGridView
{
get
{
return _DataGridView;
}
set
{
_DataGridView = value;
}
}
public bool EditingControlValueChanged
{
get
{
return _DataChanged;
}
set
{
_DataChanged = value;
}
}
public bool RepositionEditingControlOnValueChange
{
get
{
return false;
}
}
public bool EditingControlWantsInputKey(Keys key, bool dataGridViewWantsInputKey)
{
return true;
}
public int EditingControlRowIndex
{
get { return RowIndex; }
set { RowIndex = value; }
}
public object EditingControlFormattedValue
{
get { return this.Text.ToString(); }
set
{
String NewValue = value as string;
if (NewValue != null)
{
this.Text = NewValue;
}
}
}
protected override void OnTextChanged(EventArgs e)
{
_DataChanged = true;
this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
base.OnTextChanged(e);
}
}
}
Where there is a will there is a way
|
|
|
|
|