|
I have a C++ Dll that returns the pointer to the start of an image in memory and it also returns the size of the image in memory, in C++ I use memcpy to copy it to a vairable, however I am new to C# and need to know how to copy the memory block to a jpg file.
|
|
|
|
|
use the Marshel Class to read write assgin all that is needed to and out of a memory block
do not forget u're in manged coding!!!!!
Here is a good Red MSDN[^]
Have Fun
Never forget it
|
|
|
|
|
Hi
I have an app I wrote with VS2003, in c#. In it I have a simple form that has a few buttons on it. As the user uses the app, there is a logical flow of events, so that different buttons are enabled at different times.
What I would like to do is assign the space bar on the keyboard to diferent buttons at different times, so that the user can just keep using that instead of the mouse.
I could not find any way to do this for a form button - only for a menu item. Anyone know how?
|
|
|
|
|
Hi,
AFAIK there is no direct way to link a shortcut to a button.
What you can do is this:
- set Form.KeyPreview true;
- give the Form a KeyDown or KeyPress handler, where you check for space, and decide if and
which button is to be clicked, then do a Button.PerformClick().
|
|
|
|
|
You will have to write some code inside the KeyDown event of the form, and take the required action when the space key is pressed. The form's KeyPreview property must be set to true to get the KeyDown events even the focus is on any child control.
You can check my blog post for an example of handling this event for creating various shortcut keys.
http://www.nirandas.com/blog/index.php/ways-to-set-short-cut-keys-for-controls-on-a-windows-forms-net-application/[^]
Remember! if the focus is on a text field, users will not be able to type a space if it is used for triggering any other action.
|
|
|
|
|
Hey, I have been desperately trying to save and load an image from xml. My latest attempt resulted in me getting encoding issues.
This is how I load from xml
ProfileImageData = mT.FirstChild.Value;<br />
byte[] content = UTF8Encoding.UTF8.GetBytes(ProfileImageData);<br />
MemoryStream stream = new MemoryStream(content);<br />
ProfileImage = new Bitmap(stream);
This is how i save to xml
<br />
MemoryStream stream = new MemoryStream();<br />
Image.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);<br />
Byte[] dat = stream.ToArray();<br />
<br />
XmlCDataSection mImageData = mRoot.OwnerDocument.CreateCDataSection(<br />
System.Text.UTF8Encoding.UTF8.GetString(dat, 0, dat.Length));
Any hints, tips, anything on how I could get this to work?
|
|
|
|
|
Hi,
Is it possible to retreive the avaiable parameters for an executable. For instance, if Setup.exe has a /silent switch, it would be able to retreive that? or is that sort of thing not possible?
Thanks for the help!!
Jason
|
|
|
|
|
Their is no way to find out out executable paramters of applications if they are not documented. .NET applications are also capable of having paramters (in the Main procedure of the application switch the header to: public shared main(string[] args) )
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
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Thanks,
Do you have a good suggestion for creating a program that can run an executable and automatically find a silent switch? maybe parsing from a Setup.exe /?
|
|
|
|
|
Their is no way to find out out executable paramters of applications if they are not documented
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
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Yeah, there is. Besides looking for strings in the executable image, you could debug the assembly code or, better yet, just try various switches and see what happens.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote: debug the assembly code
depending on the language it was written in
Joe Woodbury wrote: just try various switches and see what happens.
Good idea. Lets just run some random executables and see what happens..
Not on my PC thank you.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote:
depending on the language it was written in
Doesn't matter what language it was written in. It all ends up debuggable with the right low level tools.
Ashfield wrote: Lets just run some random executables and see what happens..
That's not what I said nor the original poster. I said to try various switches on an existing executable
. When looking for help on command line arguments, I often try /help, -help, /?, -? and so forth. If that doesn't work, I've tried /silent, /quiet and so forth.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Point taken, everythng can be debugged if you have the patience. My impression from the original post was that he was going to scan a load of executables to see if they had various options, hence my comments, but I understand your interpretation too.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have following in my form
MySqlDataAdapter da;
DataSet ds;
private void MyForm_Load(object sender, EventArgs e)
{
ds = new DataSet();
string strSQL = "SELECT A,B,C,D FROM MyTable";
da = new MySqlDataAdapter(strSQl,myConnection);
da.Fill(ds, "Example");
gridForExample.DataSource = ds.Tables["Example"];
}
private void btnRefresh_Click(object sender, EventArgs e)
{
da.Fill(ds, "Example");
}
So, MyTable has only six rows in database. Every time da.Fill(ds, "Example"); executes grid view
showing 6 more but same rows. I mean 6 then 12 then 18 and so on.
But I expect to see only 6 rows, don't I? Or am I mistaken?
Please help.
Thanks
|
|
|
|
|
There is no indication in this code sample that you have cleared your dataset from its first or subsequent fills, so you are just adding another 6 rows to the previous number of rows each time you do a refresh. You should do a ds.Clear() prior to the Fill if you do not want to keep appending rows to the dataset.
|
|
|
|
|
Thanks for the answer. I don't know how I miss that point?
Anyway thanks again.
|
|
|
|
|
I have an windows service that sends a message via remoting to a gui app on the same machine, which works great.
Now I need to send an unrelated message back from the GUI to the service i.e. two way messaging. I tried to create another remoting channel on a seperate port, however this does not work. I feel as though I'm missing the point here as it would seem I can't run a client and server in the same app. How would I go about this?
ChannelServices.RegisterChannel(new TcpChannel(), false);
rmComDataReceived = (ComDataReceived)Activator.GetObject(
typeof(ComDataReceived), "tcp://localhost:50050/ComDataReceived");
ChannelServices.RegisterChannel(new TcpServerChannel(50051), false);
rmSendPagingMsg = new SendPagingMessage();
ObjRef refSendPagingMessage = RemotingServices.Marshal(rmSendPagingMsg, "SendPagingMessage");
rmSendPagingMsg.SendPagingMessageEvent += new SendPagingMessage.SendPagingMessageEventHandler(Service_SendPagingMessageEvent);
The code above produces the error message: The channel 'tcp' is already registered
|
|
|
|
|
Hi!
You'll have to use a different constructor at least for your second channel.
With the constructor you use TcpServerChannel(int port) ) the server channel also gets the name "tcp", already taken by your first tcp channel. That's the reason for the error message you get.
Try this instead:
ChannelServices.RegisterChannel(new TcpServerChannel("guiChannel", 50051, null), false);
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
At the button click event, it displays records, but the problem here is that instead of showing all the 30,000 records, its displaying only the first row of record and that too upto the no. of total records which is close to 30,000 ( i.e First row of record is being repeated 30,000 times ).
I tried using loops, but it hangs somewhere.........i'm wrong somewhere........i need help........the code is shown below........
myTable.rows.count ]fecthes the correct 30,000 records count
OleDbConnection myCon = new OleDbConnection();
OleDbDataAdapter myAdp = new OleDbDataAdapter();
DataViewManager myDvMngr = new DataViewManager();
DataSet myDS = new DataSet();
DataTable myTable = new DataTable();
string report_file = "<path of="" report="">";
ReportDocument ReportDoc = new ReportDocument(); </path>
private void btnReport_Click(object sender, System.EventArgs e)
{
makeReport(report_file);
{
SetParamValue("@parameter1", myTable.Rows[recordCount]["CLNT#"].ToString());
SetParamValue("@parameter2", myTable.Rows[recordCount]["CNAME"].ToString());
SetParamValue("@parameter3", myTable.Rows[recordCount]["CSEX"].ToString());
SetParamValue("@parameter4", myTable.Rows[recordCount]["CSS#"].ToString());
}
crystalReportViewer1.ReportSource = ReportDoc;
}
|
|
|
|
|
You seem to be missing the loop, but you may want to try something like:
foreach (DataRow row in myTable.Rows)
{
SetParamValue("@...", row["CLNT#"].ToString();
... and so on.
}
|
|
|
|
|
Is anyone out there to help me out...........i tried using the DataRow as well, i'm getting weird results:
1. The first record is repeated 30,000 times and the report shows no other records.
2. After some code changes, the Crytal Reports again shows one record for 30,000 times and then the Crystal Reports screeb blinks and it displays the second record and displays it 30,000 times and so on until I close the program........
Please help me friends.........
|
|
|
|
|
thanks for the reply........i'm already using the SetParamValue() as shown below:
private void makeReport(string ReportFile)
{
ReportDoc.Load(ReportFile);
}
private void SetParamValue (string paramName, string paramValue)
{
for(int i=0; i < ReportDoc.DataDefinition.FormulaFields.Count; i ++ )
{
if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName=="{" + paramName + "}")
{
ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\"";
}
}
}
|
|
|
|
|
In C++, There is a delete command. But i simular in C#. I am creating program that will have huge ammount of temporary data in memory. I want to get rid of it, without closing process and GC to clean it up. I am also importing WinAPI calls.
|
|
|
|
|
In C# you need to call the Dispose method if you want to manually delete items. GC does some cleaning, but at times even with the combination of the two methods, .NET applications do hog some memory. Another way to minimalize the memory used is to only import libraries that you will be using for that particular class.
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
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|