|
Hi everyone
how would i add text to a rich text box named 'richTextBox1' located in Form1 with the namespace "winApp1"...
i am adding text from a function inside a different class like this:
winApp1.Form1.richTextBox1.Text
but all i get is:
'winApp1.Form1.richTextBox1' is inaccessible due to its protection level
how can i remove the protection
Thanks in advanced
Roman
|
|
|
|
|
Declare richTextBox1 as public or internal.
|
|
|
|
|
thanks, why didn't i think of that
|
|
|
|
|
Hello good people,
I recently discovered the GCHandle class and its use.
However, I can't seem to understand something...
In one of my projects I'm using SetWindowsHookEx() , which gets a function pointer, or a delegate to be exact...
However, I've no use with this delegate whatsoever...
My first attemt at writing the code was something like the following:
SetWindowsHookEx(... ,new BlaBlaDelegate(MyCallback), ...); The above, sometimes, generated an exception which said that I tried to reference a null object (Not in these exact words of course ).
The solution I came up with was to keep a reference in a global variable inside my class.
So the new code is somewhat like:
BlaBlaDelegate bla;
...
SetWindowsHookEx(..., bla = new BlaBlaDelegate(MyCallback), ...); Works fine.
As MSDN documents:
"...Once allocated, you can use a GCHandle to prevent the managed object from being collected by the garbage collector when an unmanaged client holds the only reference. Without such a handle, the object can be collected by the garbage collector before completing its work on behalf of the unmanaged client."
Question is... Should I use GCHandle instead of holding a direct reference?
If so, when should I use the Free() method?
Right after the call to SetWindowsHookEx() ?
GCHandle is supposed to "prevent the managed object from being collected...when the unmanaged client holds the only reference.".
So why use the Free() method right after the API call? (That's what MSDN examples show BTW)
Thanks in advance,
Shy.
|
|
|
|
|
In this case, the delegate to your MyCallback needs to stay alive for as long as you want the hook to work. So, if your windows hook lasts for as long as your application is running, never call Free() on the object.
Why the MSDN example calls free right away, I've no idea. Are they using GCHandle for keeping an object alive just for a single call (i.e. no callbacks)?
|
|
|
|
|
|
I'd just use a direct reference, but whatever works I guess.
Really odd...seems like the MSDN article is wrong. Either I'm missing something or the article is wrong.
|
|
|
|
|
I need to create an intranet website (stored within a company firewall) where a customer can call our support desk and the system checks which reps are currently available to answer a phone call, then routes the phone call to the rep via VOIP.
In other words, each rep will not be speaking through a phone but rather their PC (which I'm assumming only VOIP can handle).
I'd prefer to create my own .NET app to handle this so if anyone knows of a tutorial or a good starting point to begin researching, that would be great. Also, if anyone knows of a commercial solution already out there that can handle this, I'd appreciate that info as well.
Thanks in advance.
-Goalie35
|
|
|
|
|
No, I don't mean hiding it under a box or something.
I need a way, from a console app, to completely hide the mouse cursor. Back in the days of Window 3.1, I think I did something like that once. You think I still have the code for that? HAHAHA!
So, how do you do it?
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Cursor.Hide
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote: Cursor.Hide
That doesn't work for a console app.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
namespace HideMouse
{
class Program
{
static void Main(string[] args)
{
while (true) {
Cursor.Position = new Point (-10, -10);
}
}
}
} This doesn't hide the mouse, but renders it effectively useless.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: but renders it effectivly useless.
I tried that. The mouse doesn't actually move beyond (0, 0), so there's still a piece of it visible. Possibly because I'm using UltraMon and/or Synergy. I need a system-wide way of doing this.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Try (2048, 2048) .
[edit]
And of course I was brain damaged when I wrote that code. You want to set the cursor's position to a static Point instead of newi ng one up zillions of times per second.
[/edit]
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Try (2048, 2048).
It must be something I have installed, perhaps, but that only moves the mouse cursor to the bottom right of the screen. I can still see a piece of it.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Bummer.
Are you running dual monitors? Do you have better luck with outlandishly large (yet valid) coords like (16384, 16384) ?
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Are you running dual monitors?
Not on this computer. But I am running Synergy. That may be causing problems.
There must be some way though of telling Windows at the system level to turn off the mouse pointer.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Perhaps you could try setting it to a custom cursor that's transparent and has no hot spot?
/ravi
|
|
|
|
|
System.Console.CursorVisible = false , does that work Marc?
|
|
|
|
|
Judah Himango wrote: System.Console.CursorVisible = false,
That nukes the blinking cursor in the console window. But the mouse cursor is still staring at me.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Marc Clifton wrote: That nukes the blinking cursor in the console window. But the mouse cursor is still staring at me.
Calling the Cursor.Hide from the Windows Forms APIs doesn't work either, eh?
|
|
|
|
|
Judah Himango wrote: Calling the Cursor.Hide from the Windows Forms APIs doesn't work either, eh?
Nope. I think that's too intimately tied to a form. Some of the methods in Cursor work, like setting the position, while others don't, like Show/Hide and Clip, it seems.
Ain't console mode fun! This is for a turnkey app that displays some videos where user doesn't even have a mouse, so I want to be able to completely remove the Windows mouse pointer from the screen. I tried negative coordinates and positions > screen extents, but no luck.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
You mention some of the cursor methods work... It'd be a hack, but how about creating a custom cursor that simply is a completely transparent bitmap. If it actually affects the cursor, it would be invisible.
|
|
|
|
|
Have you checked any of the Win32 API calls? I know it's possible since Windows Media Player in full screen mode hides both the task tray and the mouse cursor after a few seconds of no keyboard/mouse activity.
[edit]Look at the ShowCursor[^] function or the SystemParametersInfo[^] function and setting SPI_SETMOUSEVANISH.[/edit]
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Hello,
I have the following problem, In a window form I have a panel (with autosroll enabled) and inside this panel I would like to add dynamicly other panels. I have a variable that holds the number of panels inside the main Panel. So whenever I add a new panel,its location is calculated by (number_of_panels+space_between_two_panels)*panel_height
The code works fine.. until I scroll down the mainpanel to the bottom, then when I add a new panel inside it there is a huge gap between the last panel and the newly added one.
Any one can tell me why? and how to solve it ?(I dont want to scroll the main panel all the way up just to add a new panel).
Help appreciated,
Pawel
|
|
|
|