|
Hi Tom,
1.
yes I would like to have the C code in a compilable and runnable form. Please email it
using the email button below. Have some questions:
1.1. Which tool do you use to build it ? (I hope Visual Studio 6)
1.2. Does it use "normal" sizes (1B byte, 2B short, 3B int, ...) ?
1.3. Where did you get the source exactly ?
1.4. Did you change anything ? If so did you comment that in the source ?
1.5. Did you add code to print out:
- struct sizes ?
- and field offsets ? Are they what you expected ?
- field values ?
2.
I entered your C# code in a C# project, but I am missing a lot:
several vcl_### types such as vc1_eMBType; I hope most of them are int enums.
I think you best also send me the source of C# class that is supposed to call the C stuff.
3.
to access vc1DEC_sState.sPosition one must get all its members marshalled (almost) correctly;
as long as something is wrong in say vc1_sPicture, it will continue to give that kind
of run-time errors.
And that's exactly why I tend to build a marshalling job from bottom to top,
so you get something working and this gives you the energy to continue...
4.
Are you sure you need the unsafe keyword ? what is it supposed to bring you ?
5.
some of your fields are public, most of them not. Why is this ?
If you dont need to access most of the fields in C#, you can replace them by something simpler
having the same size (such as vc1_sMB in vc1DEC_sState !?!?
Greetings
|
|
|
|
|
Hi Tom,
FYI: in C# the following struct
[StructLayout(LayoutKind.Sequential)]<br />
public struct ccc {<br />
int a1;<br />
byte b1;<br />
int a2;<br />
byte b2;<br />
int a3;<br />
byte b3;<br />
}
has a Marshal.Sizeof of 24 as I expected; each byte gets followed by 3 padding bytes
to align the next int.
And that is also how I recall it from C (I did not test that now).
|
|
|
|
|
how i can validate a formula.
formula contains column names of a table..
pls help for this
Lakshmi
|
|
|
|
|
What formula?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
hi guyz..
Any one know how to make a datagrid with checkbox in each row(email style),
I will use it for multiple selection, I'm using c#.net 2003.. I want my application to have this feature..
tnx in advance n_n
|
|
|
|
|
Hey
Try this link for some hints:
http://www.asp.net/learn/dataaccess/tutorial12cs.aspx?tabid=63
Hope it helps
Dan
|
|
|
|
|
Hi all,
I have try to convert a pdf to tiff file.My below the code snippet is working fine when i open a tiff file and convert some other format..But it didn't work when i open the pdf file,it will be thrown error like "Parameter is not valid" from below the code at bold line "Image image = Image.FromStream(fromImageStream, false,true);" please help me what i did wrong.
private void button4_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
FileStream fstPersons = new FileStream(@"c:\\toto.tiff",<br />
FileMode.Create,FileAccess.Write);<br />
BinaryWriter wrtPersons = new BinaryWriter(fstPersons);<br />
<br />
FileStream fStream = new FileStream(@"c:\\Sample.pdf", FileMode.Open,<br />
FileAccess.Read);<br />
BinaryReader reader = new BinaryReader(fStream);<br />
<br />
FileInfo info = new FileInfo(@"c:\\sample.pdf");<br />
<br />
byte[] fromImage = null;<br />
<br />
fromImage = reader.ReadBytes((int)info.Length);<br />
<br />
reader.Close();<br />
fStream.Close();<br />
<br />
MemoryStream fromImageStream = new MemoryStream();<br />
fromImageStream.Write(fromImage, 0, fromImage.Length);<br />
Image image = Image.FromStream(fromImageStream, false,true);<br />
Bitmap bitmap = (Bitmap)image;<br />
EncoderParameters encoderParams = new EncoderParameters();<br />
encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, 50L);<br />
ImageCodecInfo codecInfo = GetEncoderInfo("image/tiff");<br />
MemoryStream newImage = new MemoryStream();<br />
bitmap.Save(newImage, codecInfo, encoderParams);<br />
byte[] data = newImage.ToArray();<br />
<br />
wrtPersons.Write(data);<br />
<br />
fstPersons.Close();<br />
wrtPersons.Close();<br />
<br />
}<br />
<br />
<br />
<br />
private static ImageCodecInfo GetEncoderInfo(String mimeType)<br />
{<br />
int j;<br />
ImageCodecInfo[] encoders;<br />
encoders = ImageCodecInfo.GetImageEncoders();<br />
for(j = 0; j < encoders.Length; ++j)<br />
{<br />
if(encoders[j].MimeType == mimeType)<br />
return encoders[j];<br />
}<br />
return null;<br />
}<br />
thanks in advance
|
|
|
|
|
Stream operations are very much like good old file operations:
if you write a file, then want to read what has been written, you must either close and reopen,
OR somehow "rewind" the file. Look for an appropriate stream method
(or property) to do this...
|
|
|
|
|
hi
while reading a file named with underscore i am having error illegal characters found how can i remove it and how to find the particular position in a file
|
|
|
|
|
please be specific, show the error messages and Exception.ToString(), show the code,
tell us which parts work and which dont...
(so read and apply the forum guidelines !)
|
|
|
|
|
Hi,
I have the following hardcoded labels:
this.labelAWeekAgo1.Text = lastWeek.ToString();
this.labelAWeekAgo2.Text = lastWeek.ToString();
..
this.labelAWeekAgo10.Text = lastWeek.ToString();
with each individual label contained within a loop that contains a function with the result generating "lastweek".
How can I code the label variable that changes programatically ie the number at the end of the labels name depending on which pass thru the loop I'm in eg
for i=0 etc
this.labelAWeekAgo[i].Text = lastweek.ToString();
Glen Harvy
|
|
|
|
|
Use For loop
for(i=0;i<9;i++)
{
//your code
}
or you can use foreach which is more easy.
Details[^]
Regards,
Satips.
|
|
|
|
|
Thanks for the prompt reply.
I'm trying to avoid having to do the following for each hardcoded label:
Label[] lbThisWeek = new Label[10];
for (int i = 0; i < lbThisWeek.Length; i++)
{
lbThisWeek[i] = new Label();
}
lbThisWeek[0] = this.labelThisweek1;
lbThisWeek[1] = this.labelThisweek2;
lbThisWeek[2] = this.labelThisweek3;
lbThisWeek[3] = this.labelThisweek4;
lbThisWeek[4] = this.labelThisweek5;
lbThisWeek[5] = this.labelThisweek6;
lbThisWeek[6] = this.labelThisweek7;
lbThisWeek[7] = this.labelThisweek8;
lbThisWeek[8] = this.labelThisweek9;
lbThisWeek[9] = this.labelThisweek10;
Doing this allows me to use the loop to perform my actions but it seems I have to create separate arrays for each item as I can't see how you pass [i] to a hardcoded control name.
Glen Harvy
|
|
|
|
|
Hi,
create a collection of your labels (an array, an ArrayList, a List, whatever),
and foreach them.
If its all the labels on a form, you could also foreach your form's controls as in:
foreach (Control c in myForm.Controls) {
Label lbl=c as Label;
if (lbl!=null) doSomethingToLabel(lbl);
}
Finally you could use reflection to find all the labels with a specific name syntax,
but that seems overkill (and expensive) in this case.
|
|
|
|
|
Thanks,
Yes - it looks like an array for each label concerned is the easiest - thank heavens for search & replace.
Glen Harvy
|
|
|
|
|
Ho ho, I think no one suggested changing the label names; if you replace myLabel1 by
myLabel[1] the Visual Designer will no longer understand it (the declarations would
be wrong).
What you should do is keep the labels as they are, and on top of that create a list
(an array or some other collection) that holds references to them, so you can foreach it.
You could create and populate the list right after the call to InitializeComponents().
|
|
|
|
|
Create an array of references to your labels:
Label[] labelAWeekAgo = new Label[] { labelAWWeekAgo1, labelAWWeekAgo2, ... ,labelAWWeekAgo10};
Note that the index for the array is zero based.
If you use foreach to loop the array, you don't use an index:
string lastWeekString = lastWeek.ToString();
foreach (Label label in labelAWeekAgo) {
label.Text = lastWeekString;
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi All,
I have developed a windows application using serial port.
Now, i am asked to convert it into a .exe file(console application)..Is it possible? if so, how can i do it??
could any one please help me...
Thanks in Advance.
|
|
|
|
|
Just create a console app and move your code into it. The main thing is, a console app does not have events, so you need to build your own menus and so on in plain text.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have done it in the same way...
ITs running well on my machine... But when I run that .exe file on another machines its saying
" application failed to initialize properly: Click OK to terminate the program"
whats the problem??
how can I run my .exe on another machines as well....???
|
|
|
|
|
There can be several reasons for this, try Google to see them.
Best guess is read access violation on some DLL file.
BTW the message typically includes an error code, if it did you should show it.
|
|
|
|
|
please give me code for create an child(already designed) form with in mdi form
|
|
|
|
|
We cannot do your work.
What you have done so for and what error it shows tell us that i have done this but i am getting this error.
Regards,
Satips.
|
|
|
|
|
It's a pretty straightforward question, probably just one function call to do it. I'd answer it, if I knew.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
private void categoryToolStripMenuItem_Click(object sender, EventArgs e)
{
empCat cat = new empCat();
cat.MdiParent = MdiParent;
cat.Show();
}
this is the code tell me the correct code where mdiparent is a form name cat is a object of empCat ( which i want to make a child of Mdi Parent Form).
Please Provide me Correct Code
|
|
|
|