|
But can anybody explain why it takes longer to print a 159KB gif image than it does to print a 1344KB tiff image?
|
|
|
|
|
.NET sends _all_ data to a printer using Raster images. This means if you only send plain taxt to a printer, it still converts it into a raster image. If you communicate with the printer via the Serial port it takes quite a while.
If you only want to send text you can develop a component in VB (VS 6.0) that sends plain text to a printer and use this in .NET.
can't help with the image though...
|
|
|
|
|
Looking of your great help gurus.
I new to know how to get the current user info, namely, domain user name and computer name, IP address.
How to get these Net details in C# ?
Best Regards,
Ashraf.
|
|
|
|
|
To get the domain name, you can use Environment.UserDomainName . For the username, you can use Environment.UserName . To get the computer name, use Environment.MachineName . If you want more information than this, you can P/Invoke the Network Management APIs. See the API documentation on MSDN at http://msdn.microsoft.com/library/en-us/netmgmt/netmgmt/network_management.asp[^] for more information about the Network Management API.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
My many thanks to you. It was very helpping..
Keep best of support to each other..
Best Regards,
Ashraf Alsadiq.
|
|
|
|
|
Hi there,
I'm a newbie in C# and learning the language right now.
I have MFC backgrounds for almost 10 years now and I want to migrate to C#.
My question is simple... What is the equivalent of the MFC TRACE macro for C#?
The goal is to display traces in the output debug window of the IDE the same way as TRACE macro.
Thanks for the answer.
Best regards.
bouli.
|
|
|
|
|
Although these are not macros they are much more powerful than the MFC equivalents.
System.Diagnostic.Trace.WriteLine();
System.Diagnostic.Debug.WriteLine();
The Debug version will only work in the debug build (or any build where you #define DEBUG ).
The Trace version is more for instrumented builds where you want the output to go to a log file of the system event log and it is valid to have available in the release build. The Trace version will only work where you #define TRACE .
See also TraceListener
Also, for future reference: In the next version of .NET the Trace classes are meant to be vastly improved.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
|
|
|
|
|
Hi,
Nice stuffs!
No possible comparison with the simple TRACE macro
Thanks.
|
|
|
|
|
To add to that, the DefaultTraceListener will output messages you pass to Trace or Debug to the output window when you're debugging your application in .NET. To write to files, the event log, or any custom targets you can use additional TraceListener implementations even at runtime (we use one for error logging in our app).
You're right, though, it is much better than the various TRACE macros, though - as Colin mentioned - a much better trace facility would be nice and is expected. To elaborate, every message you pass is passed to each TraceListener , regardless of whether or not they want to handle it (based on a TraceSwitch setting or other proprietary filtering). This can hamper performance.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Call me stupid, but after coding for 1 year now, I'm going to ask such a trivial question:
Object o; //Where does o fit in memory?
o = new Object(); //Now what? Instantiated? What's that?!
//Work on o somehow; then:
o = some_fuction_that_returns_a_newly_created_object(); //Now?
How about the first o that was allocated? I used the same variable to point to two instances (or at least that's what I think) consequently. What happens to the first instance? What about if I want to destroy this o in memory because I simply don't need it anymore?!
Thank you, I appreciate your patience.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
profoundwhispers wrote:
Object o; //Where does o fit in memory?
It allocates enough memory on the stack for a reference (pointer) to the actual object (what ever it may eventually be)
profoundwhispers wrote:
o = new Object(); //Now what? Instantiated? What's that?!
This allocates memory on the heap for the newly instantiated object.
profoundwhispers wrote:
o = some_fuction_that_returns_a_newly_created_object(); //Now?
the actual newly created object will be on the heap. o itself is still a pointer/reference on the stack to that object.
profoundwhispers wrote:
How about the first o that was allocated? ... What happens to the first instance?
The garbage collector will remove it from the system when it gets around to it, assuming nothing else is referencing it.
profoundwhispers wrote:
What about if I want to destroy this o in memory because I simply don't need it anymore?!
If you don't need it anymore just don't reference it. The garbage collector will free the memory when it gets around to it.
One caveat is objects that have a Dispose() method. These usually have resources that the managed heap in .NET cannot garbage collect efficiently. When you no longer need these objects you should call Dispose(). The garbage collector would eventually Dispose it anyway, but it will take a few attempts at it.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
|
|
|
|
|
Thank you, this was extremely helpful!
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Hi Folks,
Let me just say I'm a programming newbie. I have this problem that's been irritating me.
I have a list view in my app and I've specified a DataSource for it. I have other functions that are constantly updating the Array that is the DataSource (it's an array of integers, in this case.)
The only way I've found to have the ListView update is to set the DataSource to null and then reassign it. Is there a more elegant way to do this?
Thanks!
|
|
|
|
|
|
Hi,
I've created an icon-file with a 16x16 icon and selected that file in the "Icon" property of my main form. This changes the icon in the top-left corner of the app, but it doesn't change the icon that appears in the ALT-TAB sequence pop-up. I suppose that I need a 32x32 icon for that purpose, but even if I create a such in the icon file - it still doesn't change from the default .Net icon when running the app. Any ideas ?
/Jan
Do you know why it's important to make fast decisions? Because you give yourself more time to correct your mistakes, when you find out that you made the wrong one. Chris Meech on deciding whether to go to his daughters graduation or a Neil Young concert
|
|
|
|
|
Either change the App.ico file in your project, or replace it / add a new icon (presumably the same one as which you designated as your Form.Icon ) and change the Application Icon to reference that icon in your project properties. You should at least have both a 16x16 and 32x32 icon for your .ico file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
I'm developing a set of Windows form controls that should extend the functionalities of the following classes:
public class MyPushButton : System.Windows.Forms.Button
public class MyCheckbox : System.Windows.Forms.CheckBox
public class MyRadioButton : System.Windows.Forms.RadioButton
I decided to derive a class from each of these base classes in order to get the right notifications from the base class events.
Now these custom controls should apply some graphic effect to the buttons through a set of properties that would be common to all of the "MyXXX" button classes: due to the fact that multiple inheritance is not supported in C#, how can I avoid to have all of the properties and their get/set helpers duplicated in each of the "MyXXX" classes?
Thanks in advance and Kind regards
Seve
|
|
|
|
|
|
does any one of u know a
free-ware tool that can
test software. i.e
does its black box, white box,
regression or other type of testing
|
|
|
|
|
|
OK
After some serious research i've managed to display some balloon tooltips on a notifiyicon, hooked up to a windows form.
But i inteded to write a windows service instead of a form-based application.
Since you need a window handle to run the shell_notifyicon function, needed to display the balloon tooltips, and i don't seem to find the handle from a service, i have a problem
Does anybody know how to get the handle from a windows service, or any way to hook up a balloon tooltip to the notifyicon from a service??
Thx in front
Jochen
|
|
|
|
|
A Windows Service doesn't have a Window handle, so you'll have to P/Invoke GetDesktopWindow :
[DllImport("user32.dll")]
private static extern IntPtr GetDesktopWindow(); Your service, if run as LocalSystem, will also have to have the "Allow service to interact with desktop" option checked in the Service snap-in. See your Control Panel\Administrative Tools for the snap-in.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/
I don't know if any of you are familiar with Dino Esposito article in MSDN magazine on .NET Hooks but I used the class he created named LocalWindowsHook that imports the below API calls
protected static extern IntPtr SetWindowsHookEx(HookType code,
HookProc func,
IntPtr hInstance,
int threadID);
and a few other necessary functions from user32.dll to implement a hook.
I ended up changing his Install function from
public void Install()
{
m_hhook = SetWindowsHookEx(
m_hookType, m_filterFunc,
IntPtr.Zero,
(int)AppDomain.GetCurrentThreadId());
}
to
public void Install()
{
m_hhook = SetWindowsHookEx(
m_hookType,
m_filterFunc,
GetHInstance(),
0);
}
public static IntPtr GetHInstance()
{
return Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]);
}
In an attempt to create a global hook using WH_KEYBOARD.
The problem I have is it doesn't work. It works globally with WH_KEYBOARD_LL but as soon as I use WH_KEYBOARD it doesn't work at all. This meaning it doesn't capture keyboard strokes in either the windows form or anywhere else. Now Dino's code worked fine for a local hook (aka the form) but I want a global or system hook.
Now I have the class he wrote in an external DLL but there must be something else i am missing. If anyone has any suggestions they would be very much appreciated.
Thanks very much.
Dino Esposito modified project and my test windows form can be found here
http://scaninc.ca/hook/globalhook.zip
|
|
|
|
|
The WH_KEYBOARD_LL hook is called in your app. context so can easily be made in C#.
A global WH_KEYBOARD hook however executes in teh context of the app. that is recieving the keyboard message so your code has to be injected into every running process. This is NOT a good idea IMHO. It only seems to work if the m_filterfunc is exported from the DLL in the [EXPORTS] table.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hmm.. I don't believe this is the case.
If a hook is in place globally whether it is WH_MOUSE or WH_KEYBOARD or WH_KEYBOARD_LL the hook functions the exact same for each case. Nothing is injected into any running process, it doesn't work like that. A hook is ultimately a callback function that applications register with a particular system event. It is not injected into every running process as you say. Doing this with C# is no different then any other language as I am just using the windows API.
Now I have the code that can capture WH_MOUSE events at the thread or local application level but I need them to be captured at the global or system level. Any suggestions?
|
|
|
|