|
Heath Stewart wrote:
if one was to strip the lines for some stupid reason.
One place this is done is in ASP.NET code that's embedded in the page.
|
|
|
|
|
For repainting the nonclient area myself, I process the message WM_NCPAINT.
But the value got from wParam always is 1. Why? How can I get the nonclient area's graphics?
|
|
|
|
|
If you have a reference to the non-client area, you can use Control.CreateGraphics to return a Graphics object for any control. Remember to call Graphics.Dispose on it when you're done, though.
-----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-----
|
|
|
|
|
I know I can get the form's graphics with CreateGraphics(). Can I get the title bar's graphics? or How can I determine the title bar's retangle?
The wParam gotten from WM_NCPAINT always is 1.
|
|
|
|
|
Right, I didn't catch that before. The wParam in the WM_NCPAINT message should be 1 if the entire window frame needs repainting (covered in the docs for WM_NCPAINT). Also in that same doc is an example that you could easily use after importing a couple Win32 functions (I can't think of or find any .NET equivalents).
P/Invoke GetDCEx (optionally ReleaseDC , but Graphics.Dispose would free the handle). and pass hwnd , (HRGN)wParam , and DCX_WINDOW|DCX_INTERSECTRGN . Even though hwnd is 1, this supposedly works (at least according the docs).
I tried a quick example and got minimal success. Of course, I threw it together quickly. I also found on that Graphics.FromHwnd works when passing the Message.HWnd field from the overridden DefWndProc for my form.
Hopefully this helps somewhat. Good luck!
-----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-----
|
|
|
|
|
Please check following codes, it dosen'g work properly, the title bar is still empty.
( the method PanitNonClientArea(Graphics, RectangleF) can work properly. )
<br />
protected override void WndProc(ref Message m)<br />
{<br />
Graphics g;<br />
RectangleF rectf;<br />
<br />
Point pt;<br />
<br />
switch (m.Msg)<br />
{<br />
case WMConsts.WM_NCPAINT :<br />
IntPtr hrgn = m.WParam;<br />
if ( hrgn != (IntPtr)1 )<br />
{<br />
Region rgn = Region.FromHrgn(hrgn);<br />
g = CreateGraphics();<br />
rectf = rgn.GetBounds(g);<br />
PaintNonClientArea(g, rectf);<br />
}<br />
else<br />
{<br />
g = CreateGraphics();<br />
rectf = new RectangleF(0,-23, Width, 23);<br />
PaintNonClientArea(g, rectf);<br />
g.Dispose();<br />
}<br />
<br />
break;<br />
<br />
default :<br />
base.WndProc (ref m);<br />
break;<br />
}<br />
}<br />
|
|
|
|
|
As a quick note, and this may be trivial, but all implementations I've seen (including in Win32) always call the "base" WndProc or DefWndProc . You're only doing it if the message isn't WM_NCPAINT .
Also, the docs for WM_NCPAINT say that it calls the DefWindowProc , which is DefWndProc in the Control class. Did you try putting a breakpoint in your code to see if it's even getting there? If not, you might try moving this to an override of DefWndProc instead of WndProc . I don't know, maybe both callbacks get it.
As I said in my previous post, I had some success. I forgot to mention that I was using Graphics.FromHwnd instead of CreateGraphics . This seemed to work in most cases. I was able to ruin the nonclient area, but could never paint in it. Apparently, I was able to create a Graphics object successfully, but I would always get an exception when creating a Region from the wParam , which would explain why I couldn't paint anything (I couldn't get the bounds in which to paint).
-----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-----
|
|
|
|
|
I found that there is not difference between WndProc and DefWndProc .
Sometimes the WM_NCPAINT 's wParam is 1. In this case, it will not be successful to create a Region .
I found the graphics retrived not the same between
<br />
IntPtr hdc = GetWindowDC(m.HWnd)<br />
Graphics g = Graphics.FromHDC(hdc)<br />
and
<br />
Graphics g = Graphics.FromHWnd(hdc)<br />
|
|
|
|
|
I found the graphics using Control.CreateGraphics only contains the client area, not contains the title bar.
|
|
|
|
|
I can capture the screen using C#,but don't include the cursor.
How can I capture the screen with cursor?
thanks.
|
|
|
|
|
There are actually several articles on how to do this with C# here on CP (just do a search). As far as the mouse cursor, most code I've seen (even in VC++) hide the cursor, do a BitBlt and show the cursor again. Don't hide the cursor for it to show up in the captured image.
-----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-----
|
|
|
|
|
How to implement the doubleclick Event on a Windows.Forms.Button-Control although a single click event is already implemented? How to make it work correctly? How to decide between a single and a double click to call certain code?
SetStyle-event only does not take any effect.
Mr. Labenche
|
|
|
|
|
Even in Win32 code when the two click types are handled, you need to use a timer of sorts. The Click event should start it and the DoubleClick event should stop it and continue handling the event. If the timer goes off, you handle the single-click event (in the timer's Elapsed event handler). If you look at the SDK docs for the Control.DoubleClick event, this behavior is actually discussed. The solution is common.
-----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-----
|
|
|
|
|
Thanks. Problem is still to fire the button-DoubleClick -event.
And furthermore, how to suppress the Elapsed -Event if a double click has happened?
The Elapsed -Event is fired everytime the Timer interval is elapsed, isn't it?
|
|
|
|
|
You don't fire the DoubleClick event, unless you're doing your own control. If you're deriving from a control with a DoubleClick event (or you duplicated it with the appropriate delegate), call the protected OnDoubleClick ). If you are merely listening for the event, you can't fire it (but your application could directly call the event handler if you like).
The Timer will fire the Elapsed as long as Timer.Enabled is set to true . This is covered - with examples - in the docs for the Timer class and its members.
So, like I said in my first post, you make the Click event handler start the timer (set Enabled to true ) and in the event handler for DoubleClick you stop the timer (set Enalbed to false ). The Elapsed event won't be fired, then. This is common practice with practically every implementation I've seen, including in Windows itself. After all, how do you think Windows can differentiate between a click and a double-click? It uses a timer set to the OS's/user's double-click timeout configurable in the Mouse control panel applet.
-----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-----
|
|
|
|
|
Ok. Thank you. I should have taken the Enabled = false property instead of the Stop -method in my DoubleClick -event. I will try again.
|
|
|
|
|
The Stop method sets Enabled to false . If the Elapsed event is still getting fired, then perhaps your interval is too quick. To get the user-defined double-click time, see SystemInformation.DoubleClickTime . You should always use what information you can from the OS in relation to things like this, especially when honoring user preferences (otherwise they tend to get upset).
-----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-----
|
|
|
|
|
I am trying to access a Solaris Unix box from .Net windows form application using sockets or tcpclient classes. I need to send and execute some type of command script that can disable and enable ip/ports on the unix box.
I am not use to the unix environment, therefore I may be doing this totally wrong. If anyone has any code already to share with me that would be great!!
The problem is reading data from a Solaris Unix box. I can get connected to the IP and Port, I can also write to it, but when I read from it nothing happens. No error is produced, no timeout is produced, it just hangs there.
If I Telnet into the same IP I get a login screen. Could this be the hang up? Should I be passing a login and password first?
Below is my code that I am using:
IPAddress myIP = IPAddress.Parse(strIP);
string sszPort = strPORT;
int alPortt = System.Convert.ToInt16 (sszPort,10);
TcpClient Telnet = new TcpClient();
try
{
Telnet.Connect(myIP, alPortt);
Stream TelnetStream = Telnet.GetStream();
if(TelnetStream.CanRead & TelnetStream.CanWrite)
{
MessageBox.Show ("Can Read and Write");
byte[] sendBytes = System.Text.Encoding.ASCII.GetBytes("USER <username>\r\n");
TelnetStream.Write(sendBytes, 0, sendBytes.Length);
byte[] bytes = new byte[Telnet.ReceiveBufferSize];
TelnetStream.Read(bytes, 0, bytes.Length);
returndata = Encoding.ASCII.GetString(bytes);
MessageBox.Show("This is what the host returned to you: " + returndata);
}
else
{
MessageBox.Show("Cannot Read");
}
catch(Exception ee)
{
string excepstr = ee.Message;
}
Telnet.Close();
|
|
|
|
|
Off hand, I can tell you that telnet uses the default port 23. You seem to be using 10. So, telnet'ing into the box isn't a valid test if you don't specify a port. Instead, try "telnet machinename 10" on Windows. Trying typing your data directly and see what's happening then.
-----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-----
|
|
|
|
|
Hi, how do u change the color of the row in datagrid according to their sort.
(sorted by Proj)
Proj Activity
yesh hihi <== this row will be red
yesh byebye <== this row will be red
yesh hoho <== this row will be red
lolo hihi <== this row will be white
lala byebye <== this row will be red
lala byebye <== this row will be red
(sorted by Activity)
Proj Activity
yesh hihi <== this row will be red
hihi hihi <== this row will be red
lolo hihi <== this row will be red
lala byebye <== this row will be white
lolo lalala <== this row will be red
yesh lalala <== this row will be red
this is a sample where there is more columns, rows and values.
Thank you.
|
|
|
|
|
I’m a bit of a nubie and looking for some advice, the code bellow works but looks like a bit of a hack. I know it's a 'WebMethod' its general enough. My concerns lie with the 'Populate product' section toward the bottom.
[WebMethod]<br />
public Product GetProductById(int Id)<br />
{<br />
#region oleDbQueery<br />
OleDbDataAdapter myAdapter = new OleDbDataAdapter();<br />
OleDbCommand myCommand = new OleDbCommand("ProductByIdQueery", oleDbConnection1);<br />
myCommand.CommandType = CommandType.StoredProcedure;<br />
OleDbParameter parameterid = new OleDbParameter("Id",OleDbType.Integer);<br />
parameterid.Value = Id;<br />
myCommand.Parameters.Add(parameterid);<br />
myAdapter.SelectCommand = oleDbSelectCommand1;<br />
myAdapter.SelectCommand = myCommand;<br />
#endregion<br />
DataSet ds = new DataSet();<br />
oleDbConnection1.Open();<br />
myAdapter.Fill(ds);<br />
oleDbConnection1.Close();<br />
Product myProduct = new Product();<br />
myProduct.Id = Int32.Parse(ds.Tables[0].Rows[0]["Id"].ToString());<br />
myProduct.Category = Int32.Parse(ds.Tables[0].Rows[0]["Category"].ToString());<br />
myProduct.ShortTitle = ds.Tables[0].Rows[0]["ShortTitle"].ToString();<br />
myProduct.FullTitle = ds.Tables[0].Rows[0]["FullTitle"].ToString();<br />
myProduct.Price = double.Parse(ds.Tables[0].Rows[0]["Price"].ToString());<br />
myProduct.CurrentQuantity = Int32.Parse(ds.Tables[0].Rows[0]["CurrentQuantity"].ToString());<br />
return myProduct;<br />
}
Sorry for the long snippit. My passed in 'Id' would refer to a unique db key so the dataSet 'should' only ever contain one row.
Do I have to go via a dataSet to populate myProduct object?
All comments greatly welcomed.
tia
|
|
|
|
|
You can use a DataTable instead of a DataSet.
The DataAdapter.Fill() method works with a DataTable object.
Free your mind...
|
|
|
|
|
Try a DataReader.
Thank You
Bo Hunter
|
|
|
|
|
|
I'm writing a control program that will require a lot of screen real estate to interact with the user. One thought I had on how to do this was to use a dual output display adapter and two monitors. I would then create forms that would present specific information on each monitor. My question is how to control which of the two monitors the form is drawn on?
Jeff
|
|
|
|