|
Because it's common sometimes to overlook the easy stuff in search of the more complex solution. We all do it
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
(Repeated from our private email so that others searching for this answer will find it.)
Hi Rado,
Ever have one of those problem that just eats at you? Well your situation has bugged me for some time because I just knew there had to be an easier, more elegant way. There is......
The problem was that BeginEdit calls for the two DataRow objects were disabling the constraints for the respective rows, but once you called EndEdit for one DataRow , the primary key value for that first row conflicted with the (not yet committed) second DataRow object. Therefore, I had to assume that there was a higher level way of turning off constraints - either the DataRowCollection or the DataTable . Finally, I found the DataTable::BeginLoadData and DataTable::EndLoadData method, which turn off and on, respectively, constraint checking and index maintenance for the entire table.
<br />
table.BeginLoadData();<br />
<font color=green>
table.EndLoadData();<br />
Note: You mentioned the fact that someone suggested turning constraints off for the entire DataSet . As this technicall will work, using BeginLoadData and EndLoadData will affect only one table instead of all the tables for a given DataSet .
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Before editing your DataRow s, set DataSet.EnforceConstraints to false .
try
{
dt.DataSet.EnforceConstraints = false;
}
finally
{
dt.DataSet.EnforceConstraints = true;
}
|
|
|
|
|
|
Hi
We would like to be able to use the different hardware fonts that exists on most printers, when we use the windows driver "Generic / Text Only" *.
We have written some code that enables us to write text to a "Generic / Text Only" (GTO) printer, but despite many attempts we haven't been able to change the font.
For writing text we use the importer legacy function WritePrinter().
Any ideas?
*) We have to use this driver since we also want to use our code for POS printers etc.
Mads
|
|
|
|
|
use the printing events. I cant remember the name but an event rises before it starts a print. you can then query for the selected fonts like a font-family in html
|
|
|
|
|
Since .NET print any stuff as graphics, the standard .NET printing mechanism doesn't work with a "generic / text only" printer.
Having tried it anyway, we found out that it didn't raise the event (and the code was ok - the event was raised if we choose any other printer).
Personally, I think we have to use some escape sequences - but I haven't been able to find out how to write them.
Thanks for your reply.
Mads
|
|
|
|
|
Perhaps you'll have to use the Windows printer API.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Have you tried crystal reports. I had the same issue with off brand printers. Crystal prints as graphics yes but it can be switched to character printing
|
|
|
|
|
Is there any Method/utlity/Class which can help me in process Monitoring? Startup/Exit/busy etc status..
VikramS
|
|
|
|
|
Take a look at the System::Diagnostics.Process class:
Exit Notification -> Process.EnableRaisingEvents
Enumerating running processes -> Process.GetProcesses
Finding processes - > Process.GetProcessByName
Alive? -> Process.Responding
That should get you started in the right direction.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Hi! I try to create a target bitmap alike the source bitmap ( in size, in pallete). I hope the target bitmap will be created black(or 0) on every pixel. And then program generate the content of target according to the source one, if some pixel isn't be filled it will be still black.
first trial:
dst = (Bitmap)src.Clone();
BitmapData bmSrcData = src.LockBits(new Rectangle(0, 0, src.Width, src.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
BitmapData bmDstData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
//do some processing on BitmapData
This one work! but it seems clone waste much on copying the content. i wanna it be black, so i have to fill it 0 myself. copy and fill are useless duplicate work.
Second trial:
dst = new Bitmap(src.Width, src.Height, src.PixelFormat);
BitmapData bmSrcData = src.LockBits(new Rectangle(0, 0, src.Width, src.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
BitmapData bmDstData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
dst will not has the same palette as src. After the process, dst will be a color image even src is a formerly gray one.
Third one:
dst = new Bitmap(src);
BitmapData bmSrcData = src.LockBits(new Rectangle(0, 0, src.Width, src.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
BitmapData bmDstData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
can't execute! the second LockBits will raise error. anybody know why?
I really puzzled by these methods! any guru can explain what's on earth are these create functions doing? and what's the best way to get my aim?
|
|
|
|
|
novachen wrote:
can't execute! the second LockBits will raise error. anybody know why?
It appears that dst and src might be the same instance, and thus cannot be locked twice. My guess
Unfortunately I cant help you with the others...
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
How to add my componet in to VS.NET (like that Visual Assist)??
Someone can help me, please!!!
Thanks
|
|
|
|
|
hi,
i want to know how to make a function including a parameter with default value?
somethings like this...
public void functionA(int A, int B = NULL)
{
// ...
}
any help?
thanks,
jim
|
|
|
|
|
zecodela wrote:
i want to know how to make a function including a parameter with default value?
As far as I know you can't have default parameters in managed functions.
- monrobot13
|
|
|
|
|
Indeed,
the word I've read everywhere in this regard is that you should use multiple
versions of the member. For ex:
instead of
<br />
public void myFunction(int myInt = 3)<br />
{...}<br />
you should have
<br />
public void myFunction(int myInt)<br />
{<br />
}<br />
AND
<br />
public void myFunction()<br />
{<br />
}<br />
Also, you could have one overload call the other:
<br />
public void myFunction(int myInt)<br />
{<br />
}<br />
AND
<br />
public void myFunction()<br />
{<br />
myFunction(3);<br />
}<br />
HTH,
FOR
|
|
|
|
|
Frank is almost correct. You can have functions/methods with default values in some managed languages, but not in C#. His advice on how to circumvent (what I personally see as a) shortcoming in the C# language is correct: Have overloaded versions of the method as follows:
public void foo (int a); // call third foo with default values
public void foo (int a, int b); // call third foo with default values
public void foo (int a, int b, int c);
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Tom Archer wrote:
public void foo (int a); // call third foo with default values
public void foo (int a, int b); // call third foo with default values
public void foo (int a, int b, int c);
OK, this is a bit picky, but shouldnt the 1st function call the second? As one would design constructor overloads?
leppie::AllocCPArticle(Generic DFA State Machine for .NET);
|
|
|
|
|
You're right....it's picky
Seriously, it depends on your point of view. From a code maintenance standpoint, I would agree with you. But from a performance standpoint it would mean an extra call in the code path.
Personally, I code as you mentioned because I worry more about maintenance than the incredibly small performance hit of an in-proc function-to-function call.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
|
Yep. Me too. That's why I'm slowly navigating back to MC++ for most of my development. I have done some cool C# stuff - even won a Money Magazine technical award a couple of months ago for a C# system I designed and wrote for VeriSign - but for my personal work, I choose MFC/MC++.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Tom Archer wrote:
But from a performance standpoint it would mean an extra call in the code path.
Doesn't the compiler take care of it?
Tom Archer wrote:
Personally, I code as you mentioned because I worry more about maintenance than the incredibly small performance hit of an in-proc function-to-function call.
Exactly.
|
|
|
|
|
Nemanja Trifunovic wrote:
Doesn't the compiler take care of it?
How do you mean? It's still a jump with the extra prolog and epilogue instructions to take care of the stack.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Yes, but since foo(a) always calls foo(a,b,c), the compiler can simply inline every call to foo(a). When you call foo (a), it can push additional two parameters on stack and call foo (a,b,c) directly.
|
|
|
|
|