|
Hi,
AFAIK you can't use header files in C#.
What you can do is define a C# struct and give it the right attributes to make
sure the order is preserved, padding does not occur, etc.
How do you plan on accessing your chip from C#? Wouldn't that require some
native code, hence C/C++ anyway? So why do you need the registers at the C# level??
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks for the response,
I need to access these from the PC side cause these register values are controlled by user, and it woud be nicer to let him address regsters using their names and not the address value
|
|
|
|
|
You could use C++/CLI to aggregate the native structure in a managed class.
|
|
|
|
|
I'm working on WPF project in which I need to implement ZoomIn / ZoomOut on Scrollviewer object with seperate pan zoom window. There are two types of transformation which can be applied i.e. Layout Transform & Render Transform. Now the problem is I want to use the best of both kind of transformation.
I have a pan zoom window which shows the view of my scroll viewer object.When the view of my scrollviewer object changes i notify to pan zoom window to reflect the view of scroll viewer object.
For transformation, scrollviewer object's three properties are important. ViewPortSize, ExtentSize and Offset. When ZoomIn is performed, ViewPortSize and ExtentSize remains same in both Layout and Render transformation while Offset value gets changed in layout transform but in Render transform scrollviewer object's offset value is not changing. Because of this in render transform, even if the view(or layout) of my scrollviewer object in main canvas has changed still I can not send the changed information to pan zoom window (as offset value is same).
So my problem is my ZoomIn / ZoomOut related requirements are perfectly satisfied using Render Transform but if I use Render transform I can not update my view in Pan Zoom Window. Can any one suggest me the work around for this problem.
(I want to implement the zooming in the same way as implemented in Microsoft Visio. Pressing ctrl key n mouse wheel move wil provide the zooming operation in visio)
Below I'm pasting one link in which the problem described is I think somewhat related to my problem.
https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=991579&SiteID=1[^]
Hope I have been able to put up my question in proper way. Pls revert back in case more clarification needed. Thanks in advance.....
|
|
|
|
|
In the book I'm reading there is only explanation about RadioButtons.
Are there multiple choice button class somewhere? whats the name?
I basically need this to ID data I want to delete from a textfile.(to know which line to delete)
any tips how do I do it? I read something about datatables and grids, is that related to what I want to do? where can I find how those classes work?
|
|
|
|
|
CheckBoxes are designed to have a checked, unchecked, intermediary states. But it depends on the framework/IDE for how to set the state settings.
Regards,
Thomas Stockwell
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.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi guys,
I have the following code in my C# application calling a C++ dll. Please advice if this is a correct way to use a struct.
public struct pTest
{
public StringBuilder Raw;
public StringBuilder trn;
public StringBuilder ece;
public StringBuilder Ct;
public StringBuilder At;
}
[DllImport("c:\\Parser.dll")]
public static extern int Parse(string tst);
[DllImport("c:\\Parser.dll")]
public static extern pTest GetParseData();
#endregion
In my code when I call the functions, as follows
res=POSShare.UtilObj.Parse(stn);
POSShare.UtilObj.GetParseData();
I get the pinvoke error when I call the function. Please help?
sasa
|
|
|
|
|
You should be more specific. What error are you getting? Which function is generating error: is it Parse() or GetParseData()? How does your unmanaged struct look like?
|
|
|
|
|
Thank you Giorgi, Here is C++ dll code that I am trying to call.
typedef struct {
LPTSTR lpsRaw;
LPTSTR lpsTransit;
LPTSTR lpsAccount;
LPTSTR lpsCSN;
LPTSTR lpsAmount;
} LPMICR;
LPMICR (CALLBACK* GetParseData) ();
int (CALLBACK* ParseMICR) (LPTSTR lpStr);
Here is my C# code:
public struct pMICR
{
public StringBuilder Raw;
public StringBuilder Transit;
public StringBuilder Account;
public StringBuilder CSN;
public StringBuilder Amount;
}
[DllImport("c:\\Parser.dll")]
public static extern int ParseMICR(string Micr);
[DllImport("c:\\Parser.dll")]
public static extern pMICR GetParseData();
I am getting the following error: Method's type signature is not pinvoke compatible. This happens when I call getparse data function. Parsemicr function completes just fine.
Please advice.
sasa
|
|
|
|
|
Hi,
if the API is fixed, you will need more C# code to get the marshaling right.
I try to keep P/Invoke stuff as simple as possible, so...
if you can choose the API, I would simplify as much as possible; I suggest you
pass the StringBuilders one by one as parameters to the GetParseData function,
and have it return just some result code (int or bool).
Good practice is to pass the capacity of each of the StringBuilders too.
So it could look like:
[DllImport("c:\\Parser.dll")]
public static extern int GetParseData(StringBuilder Raw, int RawLen, StringBuilder Transit,
int TransitLen, ...);
The native code can accept the data as pointers and lengths, and is allowed to write
to the dereferenced pointer (within the limits of the StringBuilder's capacity, you
really must create them with a sufficient "initial" capacity, they won't be grown by
the native code!)
And if you feel the need to keep the results in a single struct, you could
create one (with strings) and load it from the StringBuilders once GetParseData() returns.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi Luc,
I believe this is the second or third time you have come to my rescue, thank you for that.
yia I agree with you, unfortunately this dll is written by an outside source so I can't modify it. I have requested them to modify it. Hopefully they will do so. Either way you say that I would require more marshalling, what do you mean by that? how would I do it?
Please advice.
sasa
|
|
|
|
|
Hi,
assuming the native code is allocating the strings and just passing pointers to them through
the struct, then you should declare the struct as containing IntPtr, then use one of
the Marshal methods, such as Marshal.PtrToStringAnsi().
BTW some one should sone how free the native strings. What does the API say about that?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Have you tried decorating the struct with the StructLayoutKind attribute.
[StructLayoutKind.Sequential]
public struct pTest
{
public StringBuilder Raw;
public StringBuilder trn;
public StringBuilder ece;
public StringBuilder Ct;
public StringBuilder At;
}
I always knew that some day I would wake up in the morning and decide to live forever, or die in the attempt.
|
|
|
|
|
yes I have that already and it is still giving me the error. Thank you for your response either way.
sasa
|
|
|
|
|
I want to display a syncfusion menubar alongwith a logo on its side on the top of a Windows Form.How do i go about this?
Keshav Kamat
India
|
|
|
|
|
What's a syncfusion menubar?
3d party control?
If so - does it come with documentation?
-Larantz-
|
|
|
|
|
I'm trying to include a c++ dll in my C# project. Im having some problems. I need to check and see if the problem lies in my C# code, or the C++ DLL code. Can someone link me to a C++ DLL that they know works when called correctly from C#? Something simple that I can test my syntax with. Thanks.
|
|
|
|
|
To call methods from c++ dll by using P/Invoke. To test your c# syntax just call any winapi function so you won't need any extra dll's. For examples of platform invoke have a look at this website: http://pinvoke.net/
|
|
|
|
|
Thanks Giorgi.
|
|
|
|
|
the use of this class inorder to pass data between forms :Application.OpenForms["OpenFormName"].Controls["ControlName"].Text
But I can't manage to use this myself, how do I use it properly to pass data from a variable in class A to a variable in class B??
|
|
|
|
|
Where did you read it? It will have more information about it. Have a look at this too:
http://www.codeproject.com/dotnet/passingvaluesbetweenforms.asp
|
|
|
|
|
|
I'm currently working on a small DLL that enables you to change control names on the fly (e.g. used for swapping languages).
Works fine so far, however I have a problem with the MenuItems.
The names are stored in a text file like this:
FormName.ControlName;english name;german name;french name
However the MenuItems names cant be retrieved at runtime? There is no .Name property for the MenuItems.
Any ideas?
|
|
|
|
|
c0rvus wrote: There is no .Name property for the MenuItems.
There is name property for the menuitem but it is the name of the menu. If you can retrieve the menu object then you can access its items through the MenuItems property
|
|
|
|
|
Hm,.. I know how to retrieve all the MenuItems from the Menu itself but I dont know how to retrieve the name of a MenuItem which is extremly important to me as I need it to create a unique identification for each control.
for instance:
ContextMenu
->mnuItem1
->mnuItem2
->mnuItem3
->mnuSubItem1
->mnuSubItem2
is my menu.
That would mean i had the following entries in my textfile:
Form1.mnuItem1;....;....
Form1.mnuItem2;....;....
so i would try something like this:
private void RenameMenuItem(MenuItem item, string formName)
{
GetName(formName + "." + item.Name) <--- that would be what i'd like it to be
foreach(MenuItem menuItem in item.MenuItems)
{
RenameMenuItems(menuItem);
}
}
You see, I really need the item's name to read the according new name from the text file.
|
|
|
|