|
I am migrating from C++ to C# so I am quite new at it, but I understand what you are saying...
Thanks
|
|
|
|
|
Rajesh R Subramanian wrote: Native code will run faster than managed code. Period.
Umm. Not sure I agree with you there. Badly written c++ code could easily run way slower than well written c# code.
Simon
|
|
|
|
|
Quite obvious! And the no. of processors, clock speed of the processor(s), available physical memory, etc., comes into place.
But, my comment was 'generic', without taking these things into account and assuming the the code is written equally well (on both languages).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
I am making a setup file in Dot Net. I am opening one form during setup for doing some setup in between of installtion. I want to disable or hide the Cancel Button the installation form until and unless user does not saves the value on the other form. After he saves the values i want to enable the Cancel button.
Any reply will be appreciated.
Thanks
Imran
Imran
|
|
|
|
|
Hi all,
I have a printing functions in my C# WinForms (.Net 3.5) application that prints to a printer that supports colour printing.
I am using a custom class that inherits from PrintDocument.
My printed page contains an image and some text. The Image contains colour.
Now, I can print everything just the way I want it to look in colour. But I want to include an option to print in 'Black and White'.
I can handle the text fine as I can just change the colour, but the image is where I am having issues.
I have already tried to set the DefaultPageSettings.Color property to false, this does not work, thou I suspect that is because I am inheriting the PrintDocument class and am expected to handle this functionality myself.
EDIT: I just realised that I am not handling the ability for multiple copies manually but when I set in DefaultPageSettings then it is auto handled as expected so I am now thinking that they is something causing the Color property to not be applied automatically.
I also tried creating a Bitmap with a grayscale pixelformat and drawing the image to that before drawing that bitmap the the PrintDocument's Graphics - This spat out a 'Out Of Memory' exception (admittedly, I could have made an error in the code but I don't really want to take this option anyway if possible)
A third option, which I have not tried yet, is to loop the image's pixels and convert them to grayscale - which is easy enough but again I would rather avoid that effort is possible.
Can anybody recommend the best way to handle this?
Thanks for any answers contributed
UPDATE:
OK, now I'm having what I would call strange results...
If I print the document with PrintDocument.Color set to true the Image is in colour (as expected)
If I print the document with PrintDocument.Color set to false the Image is in colour (not wanted)
If I manually convert the Image to grayscale and print with Color set to true the Image has a slight green tint (due to the greyscale conversion values)
But, if I manually convert the Image to grayscale and print with Color set to false then no green tint (i.e. the printer has printed the image in back and white as wanted!!!)
If anyone can see the logic in that then please let me know, BTW the image to greyscale function is done before passing the image to the custom PrintDocument class
Life goes very fast. Tomorrow, today is already yesterday.
modified on Friday, June 26, 2009 8:39 AM
|
|
|
|
|
try this:
_document.DefaultPageSettings.Color = False
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
before (or should I say after) I try that, maybe you could try reading this[^]
specifically, the 7th line (excluding empty lines)
Life goes very fast. Tomorrow, today is already yesterday.
modified on Friday, June 26, 2009 8:18 AM
|
|
|
|
|
Hi everyone,
Let me ask about some problem.
Is there any way to determine the key press/mouse click is human action or simulation?
If yes, please guide me to the article/links.
Thanks and Regards,
alien
!alien!
|
|
|
|
|
Well, you could perhaps check if the keypresses happen faster than a human could do them, or if the mouse always hits an exact position, but overall, I'd say no.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Some way is there in the Treeview. Suppose if you would like to check whether the operation is perfromed by Mouse/ keyBoard / Unknown, you can do the following
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Action == TreeViewAction.Unknown)
{
}
else if (e.Action == TreeViewAction.ByKeyboard)
{
}
else if (e.Action == TreeViewAction.ByMouse)
{
}
}
|
|
|
|
|
mutpan wrote: else if (e.Action == TreeViewAction.ByKeyboard)
{
}
else if (e.Action == TreeViewAction.ByMouse)
{...
The query was to know if the key press and the mouse clicks were automated or done by a human.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I cannot think of any way to do this. I'm just curious though, why do you need to know if the events were simulated or normal?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
This is something that comes up in my area of work (games) particularly for MMOs where the "real money traders" put a lot of effort into finding ways to beat the system and generate resources they can sell.
I don't know if you're looking at similar problems, but the only way to really tell is by analysing the mouse movements and clicks, and looking for patterns and other signs.
For example, a very simple hack might click repeatedly on the same points at very regular times, which is easy enough to detect. Of course the gold farmers soon realised this and started adding randomness to positions and times. This is harder to detect, but still possible.
It's also possible to look for patterns, such as the same player doing the same actions for days at a time, or players who never actually play the game, and spend all their time in resource generation. IP address tracking can also be used, since the majority of these operations are in China, and a few other locations in the far east.
It is a big problem, and there isn't a lot of information out there on how best to deal with it. Most companies are developing their own strategies, and there's minimal sharing of knowledge on this. (Unfortunately, I can't say too much on what my own company is doing, as we're releasing our first online game next year...)
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Anyway, Thank all for reply.
My problem is exactly as molesworth said.
I will try to find the strategies.
!alien!
|
|
|
|
|
Win32 sends identical messages for human and software generated input on the normal desktop. While this makes things simpler for software automation (eg automated UI testing), it also makes simply detecting gaming cheats, or preventing malware from clicking through warnings for you, next to impossible. Preventing that is the reason behind the secure desktop in Vista.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
I'm making an application in C# and would like it to run on devices of different resolutions/dpi's. However, the default scaling leaves the images looking blocky and unclear.
Is there a method to scale images that gives nice results?
|
|
|
|
|
I would like to change the border color of Text Box in C#. I subclassed the TextBox control and override the WndProc function to catch the PAINT Messages to draw the border with my color.
But the border color hasn't changed, still i am getting the default border color of text box that is Black color. The same code works fine with .NET 1.0 but not working in .NET 2.0 and the latest versions.
Can anyone tell what is the difference between .NET 1.0 painting and .NET 2.0 painting for TextBox?
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
class MyTextBox : TextBox {
private const int WM_NCPAINT = 0x85;
private const int WM_ERASEBKGND = 0x14;
private const int WM_PAINT = 0xF;
[DllImport("user32.dll")]
static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);
[DllImport("user32.dll")]
static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
protected override void WndProc(ref Message message) {
base.WndProc(ref message);
if (message.Msg == WM_PAINT)
{
IntPtr hdc = GetDCEx(message.HWnd, (IntPtr)1, 1 | 0x0020);
if (hdc != IntPtr.Zero) {
Graphics graphics = Graphics.FromHdc(hdc);
Rectangle rectangle = new Rectangle(0, 0, Width, Height);
ControlPaint.DrawBorder(graphics, rectangle, Color.White, ButtonBorderStyle.Solid);
message.Result = (IntPtr)1;
ReleaseDC(message.HWnd, hdc);
}
}
}
}
Thanks in advance
|
|
|
|
|
I just tried your code with .NET 3.5 using VS 2008 and it worked ok, except that when I mouse over the textbox the border reverts to its original color
If its just the border style/color you want to change whats wrong with setting the BorderStyle and BorderColor properties?
|
|
|
|
|
There is no border color property for TextBox. The code which i shown in my initial post works fine if i put my textbox in the windows form. But it is not working with the custom form which i derived it from System.Windows.Form.
|
|
|
|
|
mutpan wrote: There is no border color property for TextBox
My bad.
Have you considered writing your own implementation of Textbox, or looking what else is around other than the native one.
|
|
|
|
|
J4amieC wrote: when I mouse over the textbox the border reverts
The textbox has all sorts of wierd behaviour when it comes to painting. In the past I've tried overriding OnPaint for a few things and it never behaved as expected. IIRC I gave up - always a good policy!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Textbox behaves diffewrently because the .NET implementation is just a wrapper around the native draw code. For starters, to even get OnPaint to be called you have to SetStyle(ControlStyle.UserPain,true) but it still behaves weirdly.
In actual fact, online advice is to override WndProc as the OP has already done.
|
|
|
|
|
J4amieC wrote: is just a wrapper around the native draw code
Yeah, I figured that out way back when I was doing battle with it. It's about time they gave us a shiny new .net one . I did start creating one from scratch but I found quickly that it's far from trivial and wasn't worth the effort at the time.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hello
I'm building a windows application for our company, which checks the state of a list with web links. The proxy settings in our company are setted by an automatic configuration script. Is it possible to use these settings to st up WebRequests?
WebProxy proxy = WebProxy.GetDefaultProxy(); <- doesnt work.
Thanks for your help!
Best regards
succo
|
|
|
|
|
hi i m new in C#, and i have a dll, in dll some function are just like
public void hndRecordSave(project.frmMain f)
Member of BusinessLayer.Business
in which record save as data from textbox or combo box of a form, i just wana to know how this dll created, what the functioning behide that.
-----------------------------
i thinks u all don't understand my prob, so i m again trying..
i hav a project in which someone uses a dll, and suppose in this project a form (frmmain) contain some textboxes, combobox and some button also as save, delete..
and clicking on save- programmer just call
objDLL.hndRecordSave(this); //// as form name is same frmMain
and record saved
i just wana to know at ceating dll how he manage all form in function.
thanks again. hope u all understand what i want to say.
modified on Friday, June 26, 2009 5:54 AM
|
|
|
|