|
You mean in the browser? Can't be done.
You can set the text that is displayed, though:
var done = 42;<br />
window.status = 'Progress: '+done+'%';
---
b { font-weight: normal; }
|
|
|
|
|
You'd have to do an OwnerDraw status bar. Something like this.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
When I update the data in my PropertyGrid, the PropertyGrid scrolls to the last selected property. The user is going to be scrolling through the properties as they update, so I need to disable this auto scrolling feature. I played around with the AutoScroll property but that didn't seem to do the trick. Has anybody else seen this problem. My Google search didn't produce any answers.
Thanks in advance
|
|
|
|
|
Just in case someone else encounters this problem, here is my current solution:
1) Extend the PropertyGrid class.
internal class HookPropertyGrid : PropertyGrid<br />
{<br />
public VScrollBar VScrollBar<br />
{<br />
get<br />
{<br />
object view = Controls[1];<br />
string className = "System.Windows.Forms.VScrollBar";<br />
return (VScrollBar)PluginGuiUtil.GetFirstControlOfType((Control)view, className); <br />
} <br />
}<br />
<br />
public int GetVScrollPos()<br />
{<br />
if (null != VScrollBar)<br />
{<br />
return VScrollBar.Value;<br />
}<br />
return 0;<br />
}<br />
<br />
public void SetVScrollPos(int pos_)<br />
{<br />
if (null != VScrollBar)<br />
{<br />
VScrollBar.Value = pos_;<br />
}<br />
}<br />
}
2) Before you set the selected object of the PropertyGrid, save off the current scroll pos. After setting the selected object, restore the previous scroll position.
int pos = m_propertyGrid.GetVScrollPos();<br />
<br />
PropertyTable props = new PropertyTable();<br />
<br />
CreateKnownProps(props);<br />
<br />
PopulateKnownProps(props, e_);<br />
<br />
CreateAndPopulateUnknownProps(props, e_);<br />
<br />
m_propertyGrid.SelectedObject = props;<br />
<br />
m_propertyGrid.SetVScrollPos(pos);
The only problem I have seen with this solution is that a selection rectangle will be drawn at the wrong location initially. As soon as you move the scroll bar the selection jumps back to the correct item. This problem only occurs if the selected item is off screen.
|
|
|
|
|
I have a problem that i have to find out how i can find out the current volume of the audio. Basicly i want to have the the audio file split when it gets to a section that nothing is playing.
|
|
|
|
|
Hi,
I'm trying to build a test in nUnit, that checks if after a specific function call, all numeric property values are set to zero. Since I don't know if I will eventually add other properties, I tried building this test in a generic way. I'm not even sure I can do something like this, but if yes, how should I do it?
I'm used to programming in VB 6 and a bit of VB.Net, so I'm not too sure where to start on how to do this in C#, but I've tried a couple of things that look like this :
MyClass myClass = new MyClass();
for (int i = 0; i <= myClass.GetType().GetProperties().GetUpperBound(0);i++)
{
if (myClass.GetType().GetProperties()[i].PropertyType.IsValueType)
{
if (myClass.GetType().GetProperties()[i].GetType().IsArray)
{
MessageBox("Don't forget to check array properties eventually!");
}
else
{
Assert.AreEqual(0,(int)myClass.GetType().GetProperties()[i].GetValue(myClass.GetType().GetProperties()[i],null));
}
}
}
Each time, I get a System.Reflection.TargetException.
Thanks in advance if anyone can help me!
P.S. Maybe it could be easyier to access the object's private variables directly, but I don't know how to do that either.
jG
|
|
|
|
|
You can't reach the private propertys of a class unless you use reflection. They are supposed to be unreachable, that is why they are private in the first place.
A more object oriented way of doing this would be to supply an interface that the method has to implement.
interface IVerifyable {
bool Verify();
}
When you create a class that needs verification, you inherit the interface and implements the method.
public class MyClass : IVerifyable {
private int myValue;
public bool Verify() {
return myValue != 0;
}
}
This way each class is responsible for it's own verification.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
Thanks for the answer. I wasnt' trying to reach private properties yet, but I guess that might turn out to be a problem also eventually.
But if I want to check things automatically, how could I do it?
For example, in 6 months, I add a myValue2 to my class, and forget to add the check in the IVerifiable method, nothing is going to tell me that I forgot to do it.
Is is simpler to access properties generically inside the clas?
Thanks again
jG
|
|
|
|
|
Accessing the properties directly is of course more simple and efficient than through reflection.
Letting the class itself be responsible for it's own verification makes it much more flexible. You can build any kind of verificaton, and the code that is using the verification method needn't know anything about how it works.
Of course, any changes to the class might affect the verification. On the other hand, it might also affect a number of other things, like serialization or disposal.
To have the verification inside the class itself also makes the code easier to follow. If you get back to the code after a year, it's more likely that you remember that there is any verification at all if it's in the class itself, instead of buried away in some other class.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
I would usually say you are right, but in this case, I have at least 20 tests yet for my class, and I'm not sure I want them to be included in the code and follow everywhere I use the class.
Also, I am mostly doing those tests right now to learn how to work with nUnit (something I'm not used to doing), and I hope that if I get back to the code after a year, I will use nUnit again also, so the tests will follow.
Thanks again for the comment!
P.S. Lovely site by the way.
jG
|
|
|
|
|
This piece of code seems to work fine.
private void CheckNumericValues(object instance)
{
foreach(PropertyInfo propertyInfo in instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if (propertyInfo.PropertyType == typeof(System.Int32))
{
object val = propertyInfo.GetValue(instance, null);
Assert.AreEqual((int)val, 0);
}
}
}
Of course, it works for only properties returning int, you'd have to write separate if conditions for each numerical type if you want generic numeric value checking.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil,
Thanks, this did work for me.
jG
|
|
|
|
|
RDBMS is should only be used for simple applications.For todays applications they are not appropiate.
I agree that OODBMS is not well know but the things in the POEAA ate al most 6 months of my development time.
which included identity maps,seperated interfaces,repository,query object,finders,mappers,topological sorting,lazy loading,List Loader,Layer supertype ...etc.
yes in some way I had read the book so many times and applied ALL the enterprise patterns it has got but I still think
POEAA is missing something that it is based on SQL which is a structured system....(for me right now SQL stands for Stupid Query Language)
As SQL is procedural I think it should not exist in todays applications.(but u know people love to sell DB)
Why did we do the patterns in POEAA?
The reason is...... ;we wanted an OO code that we could reuse.....but every thing is hidden between the idea
of the primary key,foreign key idea that we should not be exposed of.
The devil is in the uniequness of the primary key...it makes the developer bring the bussiness logic into the database(normalization), where it is not really appropiate.
Such as think as a human brain does not use pointers(primary keys ) to remember? Does anybody say hmmmmmm my name is (pointer 124567)john smith.
I don't think so.The brain uses objects to remember other objects....
So why is this SQL thing is SO succesfull?
the reason is no body is doing any "domain model" in their applications as the procedural way is the easy way.
Smile [ ] Crying [:'(]
Why am I smiling and crying ?
Because I have erased ALL patterns in POEAA which makes me cry But we are thinking about burning the book when it gets cold that makes me laugh.
All the work we had done does not make sense with an OODBMS.
(.....still it took me so much time to figure out that Data Mapper idea is so "concrete idea" (narrow minded idea )that it does not live for so long even it is your hand written one)
thanks for the discussion caddre
PS: all these ideas are my point of view.
PS2: I did not want to offend any people who are writing data mappers they can be usefull in simple SQL CRUD applications.
Ps3:Myth: ODBMS products do not scale
www.service-architecture.com/object-oriented-databases/articles/myth_odbms_do_not_scale.html
....As of March, 2003, the Stanford Linear Accelerator Center (SLAC) stored over 800 terabytes of production data using Objectivity/DB.
>>>>>>>>>> most of the DB's in the world are smaller than a terabyte....(more than 90 percent)
|
|
|
|
|
hmmmm that makes sense...I have always hated SQL.
|
|
|
|
|
tolgayikilmaz wrote:
As SQL is procedural I think it should not exist in todays applications
SQL is primarily a set-based language that happens to have elements of a procedural language in order for it to fit with existing code bases.
tolgayikilmaz wrote:
Stanford Linear Accelerator Center (SLAC) stored over 800 terabytes of production data using Objectivity/DB
That's great. However, storage is one thing, retrieval is another.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
OODBMS is 44X faster than any SQL...
of course if u are using OO.
|
|
|
|
|
I've used an OO database in the past and I can't say that I was all that impressed with its performance.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
|
Hi,
Does anyone has an idea on how can I open the form,so that initally when it is opened it is set to the maximum window size as if I have clicked the maximize button?
Thanks,
E.A.
|
|
|
|
|
|
I've been trying to figure out how to extract information from all the windows presently on the desktop for about a week now. I've made it a ways, but now I am most thoroughly stuck. The following code I've gathered from various places. It compiles fine in VS 2005 RC1 against the .NET 2.0 framework.
However, at runtime it gets hung up when trying to return the windowlist. It gives a generic error and stops execution when it attemps to run the following line:
foreach (Window x in Windows)<br />
{<br />
Windows.Add(x.Title + ": " + x.hWnd.ToString());<br />
}
Here is the entire rest of the code. It should compile for you fine, with a simple cut and paste job.
I really need to get this code working. If you have the time, and want to chat: my AIM is navinineteen.
The following is two separate files:
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowScraper<br />
{<br />
public class FormWindowList : System.Windows.Forms.Form<br />
{<br />
<br />
private System.Windows.Forms.ListBox listBoxWindowList;<br />
private System.Windows.Forms.Button buttonUpdateWindowsList;<br />
private System.Windows.Forms.Button buttonSaveImage;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public FormWindowList()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.listBoxWindowList = new System.Windows.Forms.ListBox();<br />
this.buttonUpdateWindowsList = new System.Windows.Forms.Button();<br />
this.buttonSaveImage = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.listBoxWindowList.Location = new System.Drawing.Point(16, 16);<br />
this.listBoxWindowList.Name = "listBoxWindowList";<br />
this.listBoxWindowList.Size = new System.Drawing.Size(256, 173);<br />
this.listBoxWindowList.TabIndex = 0;<br />
this.buttonUpdateWindowsList.Location = new System.Drawing.Point(64, 200);<br />
this.buttonUpdateWindowsList.Name = "buttonUpdateWindowsList";<br />
this.buttonUpdateWindowsList.Size = new System.Drawing.Size(160, 23);<br />
this.buttonUpdateWindowsList.TabIndex = 1;<br />
this.buttonUpdateWindowsList.Text = "Update Windows List";<br />
this.buttonUpdateWindowsList.Click += new System.EventHandler(this.UpdateWindowList);<br />
this.buttonSaveImage.Location = new System.Drawing.Point(64, 232);<br />
this.buttonSaveImage.Name = "buttonSaveImage";<br />
this.buttonSaveImage.Size = new System.Drawing.Size(160, 23);<br />
this.buttonSaveImage.TabIndex = 2;<br />
this.buttonSaveImage.Text = "Save Image";<br />
this.buttonSaveImage.Click += new System.EventHandler(this.SaveImage);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(292, 273);<br />
this.Controls.Add(this.buttonSaveImage);<br />
this.Controls.Add(this.buttonUpdateWindowsList);<br />
this.Controls.Add(this.listBoxWindowList);<br />
this.Name = "FormWindowList";<br />
this.Text = "Window List";<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new FormWindowList());<br />
}<br />
<br />
private void UpdateWindowList(object sender, System.EventArgs e)<br />
{<br />
listBoxWindowList.Controls.Clear();<br />
<br />
ArrayList windows = WindowScraper.GetWindowList();<br />
foreach (string window in windows)<br />
listBoxWindowList.Items.Add(window);<br />
}<br />
<br />
private void SaveImage(object sender, System.EventArgs e)<br />
{<br />
<br />
}<br />
<br />
}<br />
}<br />
... and the second file.
<br />
<br />
using System;<br />
using System.Collections;<br />
using System.Text;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace WindowScraper<br />
{<br />
public class WindowScraper<br />
{<br />
public static ArrayList Windows;<br />
<br />
public struct Window<br />
{<br />
public string Title;<br />
public int hWnd;<br />
public Window(string Title, int hWnd)<br />
{<br />
this.Title = Title;<br />
this.hWnd = hWnd;<br />
}<br />
}<br />
<br />
<br />
<br />
private const int GWL_EXSTYLE = (-20);<br />
private const int WS_EX_TOOLWINDOW = 0x80;<br />
private const int WS_EX_APPWINDOW = 0x40000;<br />
private const int GW_OWNER = 4;<br />
<br />
public delegate int EnumWindowsProcDelegate(int hWnd, int lParam);<br />
<br />
[DllImport("user32")]<br />
private static extern int EnumWindows(EnumWindowsProcDelegate lpEnumFunc, int lParam);<br />
<br />
[DllImport("User32.Dll")]<br />
public static extern void GetWindowText(int h, StringBuilder s, int nMaxCount);<br />
<br />
[DllImport("user32", EntryPoint = "GetWindowLongA")]<br />
private static extern int GetWindowLongPtr(int hwnd, int nIndex);<br />
<br />
[DllImport("user32")]<br />
private static extern int GetParent(int hwnd);<br />
<br />
[DllImport("user32")]<br />
private static extern int GetWindow(int hwnd, int wCmd);<br />
<br />
[DllImport("user32")]<br />
private static extern int IsWindowVisible(int hwnd);<br />
<br />
[DllImport("user32")]<br />
private static extern int GetDesktopWindow();<br />
<br />
<br />
private static bool IsTaskbarWindow(int hWnd)<br />
{<br />
int lExStyle;<br />
int hParent;<br />
lExStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);<br />
hParent = GetParent(hWnd);<br />
bool fTaskbarWindow = ((IsWindowVisible(hWnd) != 0) & (GetWindow(hWnd, GW_OWNER) == 0) & (hParent == 0 | hParent == GetDesktopWindow()));<br />
if ((lExStyle & WS_EX_TOOLWINDOW) == WS_EX_TOOLWINDOW)<br />
{<br />
fTaskbarWindow = false;<br />
}<br />
if ((lExStyle & WS_EX_APPWINDOW) == WS_EX_APPWINDOW)<br />
{<br />
fTaskbarWindow = true;<br />
}<br />
return fTaskbarWindow;<br />
}<br />
<br />
<br />
public static int EnumWindowsProc(int hWnd, int lParam)<br />
{<br />
if (IsTaskbarWindow(hWnd))<br />
{<br />
StringBuilder sb = new StringBuilder(1024);<br />
GetWindowText(hWnd, sb, sb.Capacity);<br />
String xMsg = sb.ToString();<br />
{<br />
if (xMsg.Length > 0)<br />
{<br />
Windows.Add(new Window(xMsg, hWnd));<br />
}<br />
}<br />
}<br />
return 1;<br />
}<br />
<br />
public static ArrayList GetWindowList()<br />
{<br />
Windows = new ArrayList();<br />
EnumWindows(EnumWindowsProc, 0);<br />
foreach (Window x in Windows)<br />
{<br />
Windows.Add(x.Title + ": " + x.hWnd.ToString());<br />
}<br />
return Windows;<br />
}<br />
<br />
}<br />
}<br />
<br />
|
|
|
|
|
I didn't look at the whole code block you posted, but only the first part. I noticed there is a big problem that will cause it to crash:
<br />
foreach (Window x in Windows)<br />
{<br />
Windows.Add(x.Title + ": " + x.hWnd.ToString());<br />
}<br />
You'll notice that you're saying for every Window object in the Windows IList you are adding a new windows object to the IList.
Windows.Add is adding a new Window to the list you are enumerating!! This will cause it to never end and eventually run out of memory. Now the compiler is supposed to tell you that you can't change the value of a list while it's in use in a loop, but who knows why it didn't.
|
|
|
|
|
Can anybody give me any information on creating a taskbar application (ie when you minimize windows media player, or TrueLaunchBar). Any information or links would be great.
Thanks
JGA
|
|
|
|
|
How can I determine the col number and row number of the current cursor position in a richTextBox control?? I really need that very fast.
Regards
|
|
|
|
|
Use GetLineFromCharIndex(theRichTextBox.SelectionStart) to retrieve the line/row number.
To get the column number you'll have to count the characters from SelectionStart backwards until you reach '\n'.
Regards,
mav
|
|
|
|
|