|
I'm trying to use some unmanaged code in my app. Right now i'm getting errors that indicate the struct i'm using is not correct. Below is the unmanaged struct i'm trying to use and following that is my C# implementation of it. Can anyone spot what i'm doing wrong in my struct and suggest how to fix it? Thanks.
Unmanaged version:
typedef struct _FAX_COVERPAGE_INFO {
DWORD SizeOfStruct;
LPCTSTR CoverPageName;
BOOL UseServerCoverPage;
LPCTSTR RecName;
LPCTSTR RecFaxNumber;
LPCTSTR RecCompany;
LPCTSTR RecStreetAddress;
LPCTSTR RecCity;
LPCTSTR RecState;
LPCTSTR RecZip;
LPCTSTR RecCountry;
LPCTSTR RecTitle;
LPCTSTR RecDepartment;
LPCTSTR RecOfficeLocation;
LPCTSTR RecHomePhone;
LPCTSTR RecOfficePhone;
LPCTSTR SdrName;
LPCTSTR SdrFaxNumber;
LPCTSTR SdrCompany;
LPCTSTR SdrAddress;
LPCTSTR SdrTitle;
LPCTSTR SdrDepartment;
LPCTSTR SdrOfficeLocation;
LPCTSTR SdrHomePhone;
LPCTSTR SdrOfficePhone;
LPCTSTR Note;
LPCTSTR Subject;
SYSTEMTIME TimeSent;
DWORD PageCount;
} FAX_COVERPAGE_INFO, *PFAX_COVERPAGE_INFO;
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME,
*PSYSTEMTIME;
C# version:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class FAX_COVERPAGE_INFO
{
public int SizeOfStruct = 0;
public String CoverPageName=null;
public bool UseServerCoverPage=true;
public String RecName = null;
public String RecFaxNumber = null;
public String RecCompany = null;
public String RecStreetAddress = null;
public String RecCity = null;
public String RecState = null;
public String RecZip = null;
public String RecCountry = null;
public String RecTitle = null;
public String RecDepartment = null;
public String RecOfficeLocation = null;
public String RecHomePhone = null;
public String RecOfficePhone = null;
public String SdrName = null;
public String SdrFaxNumber = null;
public String SdrCompany = null;
public String SdrAddress = null;
public String SdrTitle = null;
public String SdrDepartment = null;
public String SdrOfficeLocation = null;
public String SdrHomePhone = null;
public String SdrOfficePhone = null;
public String Note = null;
public String Subject = null;
public SystemTime TimeSent;
public int PageCount = 0;
}
[StructLayout(LayoutKind.Sequential)]
public class SystemTime
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
|
|
|
|
|
BOOL is same size as int I think.
|
|
|
|
|
Hi.
Does anybody knows how to create a windows account with c# or some api's calls in c++? ( specifically a "restricted" one)
Or a installer that creates windows accounts...
Thanks
Alejandro
|
|
|
|
|
I have an rtf file that I can creating
in some of the sections I am placing contentholders [contenthere] throughout the document.
I need to be able to open up that file and search and replace that [contentholder] with the read data.
The code I used to do this is:
<br />
FileStream swfile = new FileStream(Server.MapPath("") + fPath + filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);<br />
<br />
StreamReader sr = new StreamReader(swfile);<br />
StreamWriter sw = new StreamWriter(swfile);<br />
However, I am able to loop through the document but the original is still there when done.
here is the code I use to actually search and replace:
<br />
while(sr.Peek() >=0)<br />
{<br />
myContent = sr.ReadLine(); <br />
<br />
<br />
if(VB.InStr(myContent, "[PROSPECT]", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{<br />
myContent += myContent.Replace("[PROSPECT]", objGCache.GetProspectName());<br />
sw.Write(myContent);<br />
}<br />
else<br />
{<br />
if(VB.InStr(myContent, "{PROSPECT}", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{<br />
myContent += myContent.Replace("{PROSPECT}", objGCache.GetProspectName());<br />
sw.Write(myContent);<br />
}<br />
else<br />
{<br />
if(VB.InStr(myContent, "(PROSPECT}", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{<br />
myContent += myContent.Replace("(PROSPECT)", objGCache.GetProspectName());<br />
sw.Write(myContent);<br />
}<br />
}<br />
}<br />
<br />
if(VB.InStr(myContent, "{CONTACT NAME}", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{<br />
myContent += myContent.Replace("{CONTACT NAME}", objGCache.GetContactName());<br />
sw.Write(myContent);<br />
}<br />
<br />
if(VB.InStr(myContent, "{ADDRESS}", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{ <br />
myContent += myContent.Replace("{ADDRESS}", objGCache.GetAddress1());<br />
sw.Write(myContent);<br />
}<br />
<br />
if(VB.InStr(myContent, "{CITY, STATE ZIP}", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{<br />
myContent += myContent.Replace("{CITY, STATE ZIP}", objGCache.GetCity() + "," + objGCache.GetState() + " " + objGCache.GetZip()); <br />
sw.Write(myContent);<br />
}<br />
<br />
if(VB.InStr(myContent, "[WWH]", Microsoft.VisualBasic.CompareMethod.Text) > 0)<br />
{<br />
myContent = myContent.Replace("[WWH]",newcontent);<br />
sw.Write(myContent);<br />
}<br />
<br />
<br />
<br />
<br />
<br />
}<br />
Sorry for the length and bad formatting, dont have time to look all pretty
If anyone could give some advice asap, that would be greatly appreciated.
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
You are using += instead of = when assigning the result of the replacement to the string. That means that you are creating a new string by concatenating the original string with the replaced string.
You should do all the replacements first, then write the resulting string to the StreamWriter. If you write the string after each replacement, if the line contains more than one content holder you will be writing the line several times, and only the last one fully processed.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for the reply Guffa,
So you are saying that what I have there should work fine I just need to stop adding to the string by using += and just use =, but the rest of the code seems viable to you?
I will change that and see if it makes a difference. Thanks for your time.
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
Also read the second paragraph in my previos reply.
---
b { font-weight: normal; }
|
|
|
|
|
oh yea I caught that and just wanted to make sure that was the only thing you saw wrong with the code. I will try this when I get a chance, caught up in another project at the moment. Dont you just love deadlines..*sigh*
Thanks again for the help on this
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
Hello,
I'm using the following code to get the number of rows in an Excel worksheet.
range = (Excel.Range)excelWorksheet.Columns["A", Type.Missing];<br />
range = range.get_End(Excel.XlDirection.xlDown);<br />
Console.WriteLine(range.Row.ToString());
It works fine with any number of rows (I've tried up to 2000), however if my worksheet has 1 row in only it returns the total number of rows - 65536. Any suggestions?
Thanks in Advance
Jonny
|
|
|
|
|
Hi Everybody,
Can anyone tell me how we can calculate working hours base on two intervals of time.
like
Starting Date: 17-05-2006 09:00 AM - Ending Date: 17-05-2006 05:00 PM ?
If ending date something like this then what to do?
Starting Date: 17-05-2006 09:00 AM - Ending Date: 18-05-2006 08:00 AM
I'm using C#.Net
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
if you use it as variables of type DateTime then it's not problem.
search the commands and static commands between DateTime, and most importent TimeSpan (TimeSpan - Represents Time intervals), I suggest the TimeSpan\DateTime parse method, and TimeSpan.Substract method.
if you are still having troubles I'll give you a sample code.
|
|
|
|
|
for your request (I got the email... but there is no msg here, so if I would post there you wouldn't get the email notification).
I've built this method, a small method that all you need is two datetimes...
private TimeSpan SubTime(DateTime dt1, DateTime dt2)
{
TimeSpan ts = TimeSpan.Parse(dt2.ToString("H:mm:ss"));
return ts.Subtract(TimeSpan.Parse(dt1.ToString("H:mm:ss")));
}
now you use it like this:
DateTime dateDiff = DateTime.Parse(SubTime(DateTime.Now, DateTime.Now.AddHours(3)));
simple no?
btw I think DateDiff is in SQL... this is C#.
if you want to pick datetime you can use the datetimepicker that has alot of functionality, and very comfort, if you want to display the DateTime you just do in a label, Text property = DateTime1.ToString("formatting")
eg. DateTime1.ToString("dd-month-yyyy hh:mm AM/PM") // just built it for you from a book I have - needed to custom make some stuff.... should work and if theres a problem try to search it, or if theres a real problem send me a msg...
Hope I helped
NaNg.
|
|
|
|
|
Hi all!!
I'm using a DataGridView and sometimes my DataGridViewTextBoxCell's
(due to text wrapping) become bigger then the datagrid height.
When this happens, even if I scroll down, there are some text lines of
each row which never show up.
Is this a bug? Does anyone know a workaround?
Thanks a lot in advance for any hints about this issue...
Pedro
|
|
|
|
|
There is a select commandfield button in the column of a gridview.
How is it possible to replace this button with a value of a text of one of the column cells in that row?
For example: each record in the grid view has a button (select commandfield) which I have called it accept.
This button redirects the user to another page and passes a value from the text in one of the columns.
But for some of these records I would like to show the text of the value of that cell instead of showing the button.
Hope this is clear.
Thanks
|
|
|
|
|
Hi,
How can we pass an enum as a parameter
i.e if i declare enum value1, value2
now how can i pass entire enum
|
|
|
|
|
like a regular veriable?
eg.:
public enum BBB { Vall, Val2, val3 }
public static BBB next(BBB val) { return val+1; }
just a simple use of it...
you can use the whole enum if you include the namespace to your project, or you use the name space (eg. if BBB is in System then System.BBB)
and that's it...
|
|
|
|
|
I wanted to create my own custom ComboBox derived from ToolStripComboBox but ToolStripComboBox does not reveal all of the underlying functionality of the ComboBox (for example, there is no OnMeasureItem in ToolStripComboBox) so I decided to create a class that derives from ComboBox with all my functionality and then create another class that derives from ToolStripComboBox that will use my custom ComboBox. The problem is that this doesn't work either because there is no way to replace the standard ComboBox in the ToolStripComboBox. The ComboBox property in ToolStripComboBox is not virtual and using the new keyword with ComboBox in my derived class still results in the base ComboBox being used. Does anybody know of a way around this?
Thanks
|
|
|
|
|
i have a textbox, a button and a checkbox in my form.
if button click and then checkbox click , in my textbox i can draw rectangle ,this is not problem
but checkbox doubleclick , still i can draw rectangle to the textbox, how can i block this.
my code;
bool bbas=false;
bool rbutton=false;
private void button1_Click(object sender, System.EventArgs e)
{
bbas=true;
}
private void textbox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(bbas&&rbutton)
{
graphic.DrawRectangle(blackpen,e.X-25,e.Y-25,50,50);
graphic.FillRectangle(blackbrush,e.X-25,e.Y-25,50,50);
}
}
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
rbutton=true;
}
|
|
|
|
|
Hello...
I'm sorry, but I don't no exactly what you want. But I think I can solve the problem.
In the method :
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
rbutton=true;
}
you must change it to :
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
if(checkbox1.Checked)
{
rbutton=true;
}
else
{
rbutton=false;
}
}
or
private void checkbox1_CheckedChanged(object sender, System.EventArgs e)
{
rbutton = this.checkbox1.Checked;
}
Because double click event does not exists in checkbox. That's why, just use .Checked or not to enable or disable drawing.
|
|
|
|
|
if(checkbox1.Checked)
{
rbutton=true;
}
else
{
rbutton=false;
}
helped me , thank you guy
|
|
|
|
|
hi jackalfb!
just a code optimization...
rbutton = checkbox1.Checked;
you can also use this and will get the same result..
microsoc
|
|
|
|
|
|
You should do your drawing in the Paint event.
|
|
|
|
|
tkanks you friends
i think answers will help me.
|
|
|
|
|
How do I loop through the form elements in C#?
Regards,
ma se
(South Africa)
|
|
|
|