|
Hi
Anyone out there know how to do a 'GetPixel' (i.e. find what colour is at a Point) with c#? There's a method GetPixel for a BitMap, but not for an arbitrary point on the screen (or a graphics object). MFC had what I needed, but it's gone from .NET!
|
|
|
|
|
chris fearnley wrote:
(or a graphics object).
You can assign a Bitmap to graphic object with Graphics.FromImage() ,then if you do change in graphic object it is reflected in bitmap. So GetPixel() works there too. I can't undestand how it doesn't solve it.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
I don't have an image to use Graphics.FromImage() , I just have some lines that have been mathematically drawn. Can I convert the whole area into a Bitmap,then use GetPixel() ?
|
|
|
|
|
Search this site to find lots of example. You can first create a Bitmap object and assign it to Graphics object, then draw whatever you want to it. This will works I think.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
I've just started studying C# and have gotten myself thoroughly confused when it comes to Events. I understand about Delegates and realise the benefits of them, along with how they are constructed/used but Events are causing my head to explode.
I've read through all the tutorials I can find and have looked through the beginners Delegates & Events threads on these boards but still cannot make head nor tail of it.
Can anyone please explain in REALLY simple terms how to create an Event, how to piece the code together and why the code seems to have to be split between different functions and classes, which to me is confusing the issue enormously?
Any help would be appreciated!
|
|
|
|
|
|
hi,
do someone know witch DLL file can contains all nio functions?
like this one: int _kbhit( void ); //Checks the console for keyboard input.
i want to import this function in my c# application.
thank u in advance!
|
|
|
|
|
ok, i've found this in msvcr71.dll
<br />
...<br />
[System.Runtime.InteropServices.DllImport("msvcr71")]<br />
static extern bool _kbhit();<br />
<br />
[System.Runtime.InteropServices.DllImport("msvcr71")]<br />
static extern int _getch();<br />
<br />
public bool KbHit()<br />
{<br />
return _kbhit();<br />
}<br />
<br />
public char GetChar()<br />
{<br />
return (char)_getch();<br />
}<br />
...<br />
|
|
|
|
|
this is a major major problem for me...i could fail my module if i dont implement this in my system!!
i've downloaded some examples from this site but i could not understand whats it doing..and how to implement it in my forms..im hoping some one out there can help me out here...it'll be one reall really appreciated help.
anyways this is my situation, i have frmQueue which has a datagrid showing only one column (ACCT ID) and another form named frmDiagnosis which has got a textbox called txtACCTID. the user clicks on the first cell in the datagrid in frmQueue and it gets loaded in the textbox in frmDiagnosis.
pls some one help me here. im new to C# so the examples really make me feel blur...
CODER
|
|
|
|
|
Declare private varibale in your frmQueue class , type of your frmdiagnosis , and set the TopMost property of it to true. Then when you want to create your form use Show() instead of ShowDialog() ,and then in the CurrentCellChange event of Datagrid set the text of frmQueue varibale, but don't forget to set the textbox modifier to public .
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Declare private varibale in your frmQueue class , type of your frmdiagnosis , and set the TopMost property of it to true.
hi mazdak, im not clear about what u said, how do i declare the variable?..
just : "private string celldata"???
and also the forms are already opened.
hope u can help me here
thx in advance
CODER
|
|
|
|
|
ASGill wrote:
how do i declare the variable?..
Yes.
ASGill wrote:
and also the forms are already opened.
Well, you open them somewhere, they haven't open by magic , whenever you open second one use Show() instead of ShowDialog().
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Hi Guys,
I'm trying to convert a char[] data recieved from my socket connection into string. please help.
This is what i'm doing
iRx = theSockId.thisSocket.EndReceive (asyn);
char[] chars = new char[iRx + 1];
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
System.String szData = new System.String(chars);
if I concatinate the szData to a string variable it gives me a space in between words while if I concatinate it to a control.text it was ok .
Is there a way to solve this.
/Dabuskol .. pls..
|
|
|
|
|
Look at the documentation for the String class. It has a constructor that takes a char[] array:
char[] buffer = new char[] {'H', 'e', 'l', 'l', 'o'};
string str = new string(buffer);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Okay this is what I would like to do. Say there is a game running that has chat capability and sends messages to the server through packets...well i would like to be able to create a small c# app that is capable of inserting text directly into the chat box and then sending it to the server while the game is running. -Basically automating GM tasks and instructions- I know what port is being used if that helps, and im kinda sure that it must go through the client for the char authentication to be used still, so directly sending to server is out. Well thanks for the help.
|
|
|
|
|
If you use DirextX for your game, you can use DirectPlay which is available in .net too for network services like chating, if you don't search for Socket keyword in this site or google to find some example about comunicating for chat services.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
One way is to find the control's HWND (window handle) using assorted native APIs like FindWindow , which you can P/Invoke in C#. If you use an application like Spy++ (that is installed as part of the Platform SDK, which can be installed with VS.NET and is by default), you can find the window class for the chat window. Once you get that HWND , you can call SendMessage (which you must also P/Invoke) using the WM_SETTEXT (0x000c) message (or whatever message the control uses to place text in the buffer). You can find this easily enough using Spy++ and logging the messages posted to the application pump for the control. Of course, this is assuming that you can interact with the application like this. A friend of mine who used to play Everquest some time ago found that older versions of the application 1) didn't run in windowed mode, and 2) would quit if any other window because active. This is no longer true for EQ, but it might be for your game. All you can do is try it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am looking for a way to print and html page from an embeded web browser window. Is there an easy way to do this. I created the document because I did not want to go through all the trouble of designing my own print function to do every line and all the text on the page.
|
|
|
|
|
Call AxWebBrowser.ExecWB with OLECMDID.OLECMDID_PRINT , and with the OLECMDEXECOPT enumeration you want (like OLECMDEXECOPT.OLECMDEXECOPT_PROMPT to show the print UI). If you read the documentation for the IDM_PRINT[^] (works the same as OLECMDID_PRINT ), you can see what you can pass for the pvaIn and pvaOut params. For instance, to just print the page using the default printer without showing the UI, you could do the following:
object pvaIn = 1;
object pvaOut = null;
axWebBrowser1.ExecWB(OLECMDID.OLECMDID_PRINT,
OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut); Executing commands on the AxWebBrowser control (from creating an ActiveX interop assembly on the shdocvw.dll library, as is common) is the same as getting the IOleCommandTarget , which does the same functionality as using the various commands from the Internet Explorer (iexplore.exe) application. So, if you passed parameters to prompt the user to pick a printer and change other options, it would be the same as File-<Print in Internet Explorer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You should be able to just use javascript: window.print();
Michael Flanakin
Web Log
|
|
|
|
|
I am trying to load text into a CheckBoxList ASP.NET Web control and preserve all ASCII chars (incl. successive blanks). Someone suggested that I replace the blanks in my strings with " ". It worked fine, except for some reason one of the lines is broken
i.e.
1.32 -
20.65
There is nothing visible in the HTML displace by "Show Source" in the IE browser to account for the break between the "-" and the "2" ASCII chars. There are many lines the the output preceding and followin that do not break.
Gary Hyslop
|
|
|
|
|
Possibly, the control isn't wide enough to render the text as a single line and the HTML rendering engine is doing word-wrap to display the text on two lines.....?
RageInTheMachine9532
|
|
|
|
|
Output as many times as necessary. This is an entity reference for a non-breaking space and won't be trimmed by the control like the space character would.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a problem with focus on an C# MDI Child form; On a double-click listview event, I call legacy C++ DLL that opens a dialog box. I needed to click once to get focus on the dialog and then the second click would activate any button etc.
Okay, to fix that, I changed the doubleclick event to a mousedown, and now when I open the C++ dialog it is fine.
Great, but when I close that dialog and return to the MDI, the focus problem is in C#; I have to first click anywhere on the form to get focus before buttons work properly.
Does anyone know how I can eliminate this problem? - many thanks
Paul.
|
|
|
|
|
I have since discovered that the form is in focus but the mouse movements are not recognized. I created a label on the form to display mouse coordinates on the mousemove event. When I return from the C++ DLL, the mouse is not recognized until I click somewhere on the form.
|
|
|
|