|
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.
|
|
|
|
|
How is it possible to change the position and size of the client region of a form ? I have built my personal form inheriting from Form, but need to position the client region accordingly...
Thanx
Forak
|
|
|
|
|
I've just solved this problem myself with a custom control instead of a form. To change the client area you need to override the WndProc method and listen for the WM_NCCALCSIZE message. If you want to do some painting in the non-client area you need to listen for WM_NCPAINT. Here's my solution:
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
enum WM_MESSAGE
{
WM_NCCALCSIZE = 131,
WM_NCPAINT = 133,
WM_NCHITTEST = 132,
WM_NCLBUTTONDOWN = 161,
}
enum WM_NCCALCSIZE
{
WVR_ALIGNTOP = 16,
WVR_ALIGNLEFT = 32,
WVR_ALIGNBOTTOM = 64,
WVR_ALIGNRIGHT = 128,
WVR_HREDRAW = 256,
WVR_VREDRAW = 512,
WVR_REDRAW = (WVR_HREDRAW | WVR_VREDRAW),
WVR_VALIDRECTS = 1024
}
[StructLayout(LayoutKind.Sequential)]
struct NCCALCSIZE_PARAMS
{
public RECT rgrc0, rgrc1, rgrc2;
public IntPtr lppos;
}
[StructLayout(LayoutKind.Sequential)]
struct WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;
public int x, y;
public int cx, cy;
public int flags;
}
[DllImport("User32.dll")]
private extern static IntPtr GetWindowDC( IntPtr hWnd );
[DllImport("User32.dll")]
private extern static int ReleaseDC( IntPtr hWnd, IntPtr hDC );
[DllImport("User32.dll")]
public static extern int RedrawWindow(IntPtr hwnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, int fuRedraw);
protected override void WndProc(ref Message m)
{
switch ( m.Msg )
{
case (int)WM_MESSAGE.WM_NCCALCSIZE :
if ( m.WParam == IntPtr.Zero )
{
RECT rect = (RECT) Marshal.PtrToStructure(m.LParam, typeof(RECT));
rect.Left += 1;
rect.Top += 5;
rect.Right -= 1;
rect.Bottom -= 1;
Marshal.StructureToPtr(rect, m.LParam, false);
}
else
{
NCCALCSIZE_PARAMS csp = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
csp.rgrc0.Left += 1;
csp.rgrc0.Top += 5;
csp.rgrc0.Right -= 1;
csp.rgrc0.Bottom -= 1;
Marshal.StructureToPtr(csp, m.LParam, false);
}
break;
case (int)WM_MESSAGE.WM_NCPAINT :
{
IntPtr hDC = GetWindowDC( m.HWnd );
Graphics g = Graphics.FromHdc( hDC );
...
ReleaseDC( m.HWnd, hDC );
}
break;
}
base.WndProc (ref m);
}
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
}
Refer to the SDK docs here[^] for more information on what WM_NCCALCSIZE actually does.
Hope this helps.
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I've been searching for a tutorial that explains how to make alpha bitmaps in C# with DirectX, with no luck. I'd really like to know how the settings in SurfaceCaps and SurfaceDescription must be manipulated to allow me to use, say, a PNG file. Any help is much appreciated.
|
|
|
|
|
Well you say DirectX, but do you mean DirectDraw or Direct3D?
I can tell you as a matter of fact that you will get no alpha-blending of any sort with DirectDraw. There are some hacks you can do to sidestep into other technologies (GDI+ for instance) and back, but this resulted in about a 93% performance degridation when done on every frame.
Our solution is to recode our entire graphics engine using D3D sprites instead of DD.
Hope that helps.
-Hiro_Antagonist
|
|
|
|
|
I did mean DirectDraw, in fact. Hm...sounds like I should learn some Direct3D. Thanks.
|
|
|
|
|
The SelectSingleNode function returns a "System.Xml.XmlNode" object, while the ReadNode function expects something else. You'll need to take a look at the documentation to see if you can either use something different to get the job done, or to see if there is a way to translate the result of SelectSingleNode into something that ReadNode can accept.
This is one of those situations that is best handled by reading the documentation. Either use the MSDN library on your computer, or head here[^].
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi,
I have little experience writing code, so your help is much needed, and will be really appreciated....please help!!
I need to build a CONSOLE application, written in C#, It should cycle thru the states as shown:
Stop -> Prepare to Go,
Prepare to Go -> Go,
Go -> Prepare to Stop.
Thanks...in advance
__________________________________________
This is what I have come up with till now, but it seems wrong:
using System;
namespace traffic_light
{
///
/// Summary description for Class1.
///
enum State
{
prepare_to_go,
go,
prepare_to_stop,
stop,
}
class Class1
{
private State _state;
public Class1()
{
_state = State.prepare_to_go;
Console.WriteLine ( _state );
_state = State.go;
Console.WriteLine ( _state );
_state = State.prepare_to_stop;
Console.WriteLine ( _state );
_state = State.stop;
Console.WriteLine ( _state );
}
}
}
|
|
|
|
|
You're not too far away. Since you're obviously trying to learn something new, I'll provide leading questions rather than actual answers.
1) How many times is it supposed to cycle through these states?
2) How would you write code to do something that many times?
3) Does the code you have successfully perform one complete state change cycle?
4) (Less important) Would a separate class method (not the constructor) be a better place to do this work?
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|