|
Hi,
I'm trying to draw a focus rectangle on a button, since, when I load a tabpage, if the first control on that page is a button, it doesn't highlight and you can't tell that it has focus.
So I stumbled across the ControlPaint.DrawFocusRectangle command and put this in after loading the rest of the page:
int x = button2.ClientRectangle.Location.X + 3;<br />
int y = button2.ClientRectangle.Location.Y + 3;<br />
int w = button2.ClientRectangle.Width - 6;<br />
int h = button2.ClientRectangle.Height - 6;<br />
Rectangle r = new Rectangle(x,y,w,h); ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(button2.Handle), r, Color.Red, Color.Red);
But I get nothing.
Then I added a paint event for the button and moved the code there, although instead of saying Graphics.FromHwnd(button2.Handle) , I said e.Graphics . Now it worked, but I'm not able to move away from the button using the up/down arrows. If I throw a messagebox in, after I click the OK button, I can move around without trouble. It seems to have something to do with returning control to the system. Is there anything I can say to give control back to the system? Or am I doing stuff completely wrong?
Thanks so much for any thoughts!!!!!!
Mel
-- modified at 12:18 Monday 1st May, 2006
|
|
|
|
|
Why don't you just call the button's Select method in the form Load handler, and then set the form's ActiveControl to the button? That will select the button and give it a focus rect.
Josh
|
|
|
|
|
I am working on an app that allow users to view training videos from a web interface(they can download it from an intrAnet webpage).
Would it be a good idea to store the video files (typically over 70MB) into a DataBase for better Management and Organization. Or should they be on FileSystem and only tags (Such as Name, MimeType, Size, Created Date etc) be stored in the DataBase?
Thanks in advance.
|
|
|
|
|
student_rhr wrote: Would it be a good idea to store the video files (typically over 70MB) into a DataBase
No!! You'll bog down the database because you have to constantly unpack the thing so the users can see it. Keep them on the server as seperate files and put the link in the database.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Currently I am working on a windows application, and one of my form has to be a system modal type. In good old VB the option was available, but now in C# with .NET framework its not there.
If any one can help me out here and give me some guidence with how to make windows .NET form a system modal type?
My Reauirements are :
The form has to be on top all the time.
No Minimizations allowed.
Cannot switch to any other application.
Can not open windows explorer or press ctrl+alt+delete.
Thanks
Lav Pathak
Application Developer
Auxiliary Enterprises
Kalamazoo, MI
|
|
|
|
|
Calling ShowDialog on a Form-derived class will show it modally. It will be on top of all other windows in your app. If you set the form's MinimizeBox property to false, you won't be allowed to minimize the dialog.
Lav Pathak wrote: Cannot switch to any other application.
Can not open windows explorer or press ctrl+alt+delete.
These features are not available in WinForms. You might be able to use some Win32 calls to accomplish those.
Josh
|
|
|
|
|
Josh thanks for the quick reply, but i need to keep my form on top of all the other apps. I know this is a bad design, but i dont have many options here.
I Dont know what win32 calls i shuold make to make it system wide modal.
Thanks
Lav Pathak
Application Developer
Auxiliary Enterprises
Kalamazoo, MI
|
|
|
|
|
Lav Pathak wrote: I Dont know what win32 calls i shuold make to make it system wide modal.
Me neither.
|
|
|
|
|
Apparently[^], MS doesn't want us to create system modal dialogs.
I tried adding the DS_SYSMODAL style to the underlying Win32 window when the form is initialized, but that didn't work. See below:
private void OnLoad(object sender, EventArgs e)
{
Int32 nStyle = GetWindowLong (this.Handle, (-16));
nStyle |= 0x02;
nStyle = SetWindowLong (this.Handle, (-16), nStyle);
}
[DllImport("User32.dll", SetLastError=true)]
private static extern Int32 GetWindowLong
(IntPtr hWnd, int nIndex);
[DllImport("User32.dll", SetLastError=true)]
private static extern Int32 SetWindowLong
(IntPtr hWnd, int nIndex, Int32 nNewStyle);
I then resorted to this (extremely) cheesy solution which works:
public Form1()
{
InitializeComponent ();
Timer timer = new Timer();
timer.Interval = 1;
timer.Tick += new EventHandler (timer_Tick);
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
this.TopMost = true;
this.Activate();
}
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Ravi Bhavnani wrote: Apparently[^], MS doesn't want us to create system modal dialogs.
I largely agree, and always ontop *option* can be useful in limited circumstances but not as a modal. For any application I'm using my reaction to that sort of behavior would be task manager-kill process. I can see the desire to do something like this for a kiosk type app, but full screen and eating alt-tab, and ctrl-alt-del would be the stronger solution there unless you're using hardware with a nuetered keyboard that can't enter those strokes.
|
|
|
|
|
|
Hi,
In my C# application I am trying to execute a SQL query, transform the query results (using XSL) returned in a form of XML, and ultimately want the resutlset as a string in resultSetToAscii. I have started working on C# very recently, so I am sure that I am doing some silly mistake. Basically my code fails in the 3rd line here and the error desc is "Data at root level is invalid". Anybody any ideas?
XPathDocument destination;
XPathDocument source;
source = new XPathDocument(new StringReader("//row"));
destination = new XPathDocument(_xsl.Transform(source, null, (XmlResolver)null));
XPathNavigator nav = destination.CreateNavigator();
{
XPathNodeIterator iterator = nav.Select("//row");
while (iterator.MoveNext())
{
foreach (Field field in _destinationFields)
{
string data = "";
if (field.name != null)
data = iterator.Current.GetAttribute(field.name, String.Empty);
resultSetToAscii = data.PadRight(field.size, ' ');
}
}
}
|
|
|
|
|
You are creating a StringReader for the string "//row" and try yo use that as an xml document. The problem is that "//row" is far from a valid xml document.
Are you trying to use xpath to read nodes from an xml document? Then you actually have to have an xml document to read from...
---
b { font-weight: normal; }
|
|
|
|
|
Okay I understand. I think the resultset is in the form of xml. I get the resultset by executing this int iRecs = cmd.ExecuteNonQuery();
So what can I pass to this call below?
source = new XPathDocument(...)
Thanks.
|
|
|
|
|
The ExecuteNonQuery doesn't return a result, it only returns the number of records affected by the query. So, you don't have any data to start with.
---
b { font-weight: normal; }
|
|
|
|
|
After reading bytes of a file, if I check
ex) file[0]==0xFE && file[1]==0xFF
and the condition is true, I can say that it is encoded in 'BigEndianUnicode'.
but how do I determine encoding of a file if the file has, say, 'Portuguese(DOS)-codepage 860' as an example.
Encodings other than obvious ones like UTF-8, BigEncidnaUnicode, or ASCII, how do I determine the encodings by reading bytes of the file? Is there any efficient way to check the encoding of a file?
|
|
|
|
|
If the file doesn't contain an encoding string no. MS has developed a statistical guessing engine for IE using byte frequencies that works most of the time, but afaik they've never released a way for 3rd party devs to use it.
|
|
|
|
|
Do you mean there is no way of user knowing what encoding a file has?
|
|
|
|
|
No, there is no way of determining what it is without guesswork.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want to create dialer application in .Net 2.0.
Please guide me how to do this.
Ashwani
|
|
|
|
|
All, I would like to know how to increase the speed of the GDI object for drawing purpose. I need to draw lines connecting 100000 points. I am using graphics.drawline. But it takes approx 5 seconds to finish the task. How can I reduce the drawing time.
CodeBala
|
|
|
|
|
You should see some improvement if you call DrawLines instead of DrawLine.
Josh
|
|
|
|
|
Josh, thanks for your reply. But as per my logic I need to test for the validity of the point before drawing. So I have to use drawline only. Is their any other way??
|
|
|
|
|
Hi Josh, thanks. I used Drawlines. Its amazing. Thanks again
CodeBala
|
|
|
|
|
You could try setting the Graphics.SmoothingMode property to HighSpeed before you draw the lines, like this...
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; Hope that helps
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent
Cheers,
Will H
|
|
|
|