|
Hi All,
I am developing one IE add on which detects HTML document events like click, change etc.
Now, I want to add the functionality like capturing menu bar clicks, toolbar clicks or address bar click.
I am searching in MSHTML & SHDOCVW dll, but not got anything relevant to this.
If anyone has the idea, how can I achieve this, please let me know.
Thanks In Advance
Vikas K
Vikas Kohli
|
|
|
|
|
I have a situation like follows :
void EventHandler(Function arguments)
{
//Set of global variables takes in values from the Function arguments
Example :
Sum = Function Argument1;
Value = Function Argument2;
//Makes a call to Function (say, 'FunctionProcess') with the respective values.
Example :
FunctionProcess(Sum,Value);
}
My query is that what happens if I receive an event and am in the middle of processing the so called "FunctionProcess" and i receive another event. The new event has different values of 'Sum' and 'Value'. What would be the result? Would it crash the normal functioning of the program?
Copleted bsc computer science.and programmer and web programmeing
|
|
|
|
|
That can't happen in a 'normal' situation as each method call including your event handler is sychronous (blocking).
If there is any threading going on, that can happen however, and you would need to lock the values.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Adding to Dave's reply, a lot of handlers execute on the main thread (aka GUI thread). Obviously that thread can only do one thing at a time, so it deals with the messages from its input queue one by one. That is why changing a Label.Text and performing a lengthy operation in one handler only shows the changed text after the operation has finished.
However there is a whole bunch of asynchronous handlers (mostly "input handlers" such as for networking, SerialPort, etc) that run on different threads, normally ThreadPool threads. I did a little experiment[^] on the subject. One of the conclusions is methods called from such handlers could be running concurrently, depending on the source of the event. Say two serial ports calling the same method. So if you are not sure, do at least one of the following:
- check the documentation (it often isn't very specific on this issue);
- perform a little experiment (as I did);
- when still in doubt, or to make sure, provide a synchronization mechanism (maybe use a lock); be careful though since that may cause new issues.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I am currently making a comic strip creator in visual C#.. one of its feature is to have an avatar or character creator which will then be used for making a comic strip.
my problem is that I don't know how to merge images from different pictureboxes and make them as one image..
can you give me some pointers or codes on how to do this? I'm still a newbie on programming so i really need help.. and i need to finish my software in less than 1 month.. thanks in advance..
|
|
|
|
|
|
tnx for the link.. i will give this a try..
|
|
|
|
|
i need help
how can i merge images from two different picture boxes into one pic box???
|
|
|
|
|
Hi,
I want to know the about user control and how to use them?
I saw many application to create wizard, all application uses user control like one for header, one for footer, Please tell me how to use user control?
|
|
|
|
|
look at this[^]
BTW: that was a google search for 'c# user control' and the first hit on the list
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
If i have this class for example :
<br />
public Class A<br />
{<br />
public void Func1()<br />
{<br />
....<br />
}<br />
<br />
virtual public void Func2()<br />
{<br />
....<br />
}<br />
}<br />
<br />
Public Class B :A<br />
{<br />
<br />
override public void Func2()<br />
{<br />
...<br />
}<br />
<br />
}<br />
I don't want to override Func1 but i allso don't want it to be exposed to the user.
What is the best way to do so?
|
|
|
|
|
use "protected" instead of "public"
|
|
|
|
|
But if i will use "protected" i will not be able to access func1 in an instance of class A, Just in Class B!
|
|
|
|
|
From your question : "I don't want to override Func1 but i also don't want it to be exposed to the user."
That means -> Func1 must be
protected (Func1 visible to child classes)
or
private (Func1 is not visible)
From your 2. question : "But if i will use "protected" i will not be able to access func1 in an instance of class A, Just in Class B!"
That means -> Func1 must be public.
So, you can choose between them..
I think, you have a design problem.
|
|
|
|
|
What you want isn't possible with standard inheritance as far as I can work out if I'm understanding you correctly.
If you want a common function between two classes, but with their own implementation, and an additional function in one (or more) of them, I would use an interface.
public interface IInterface
{
void Func2();
}
public class A : IInterface
{
public void Func2()
{
}
}
public class B : IInterface
{
public void Func2()
{
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I think he wants class B to make its inherited Func1 non-accessable.
|
|
|
|
|
The best I can come up with is the code below. So long as the classes are in a seperate assembly to the code accessing them, then it will work, although it only hides it from intellisense and creates a compile error if there is an attempt to use the method. If they are in the same assembly as the accessing code then the method will be visible, though unuseable.
I'm not keen on it as it's not very OOP - if B derives from A then it should have everything that A has, but MS do it all the time, so who am I to question this method?
public class A
{
public void Func1()
{
}
public virtual void Func2()
{
}
}
public class B : A
{
[EditorBrowsable(EditorBrowsableState.Never),
Obsolete("This method is not useable in this class", true)]
public new void Func1()
{
throw new InvalidOperationException("This method is not useable in this class");
}
public override void Func2()
{
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
You want to override the method and make it non-public? That's not allowed. You could mark it Obsolete or have it throw an Exception.
P.S. Most likely you want class B to wrap class A, not derive from it. And maybe use an interface.
modified on Monday, July 20, 2009 10:48 AM
|
|
|
|
|
hi I have this code that convert an picture box image in bytes
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] data = ms.ToArray();
ms.Close();
MessageBox.Show("image Converted in bytes");
now i want to compress these bytes too according to this code
plz help me
|
|
|
|
|
|
Why don't you try to help yourself first.
Instead of posting here for each line of code you need writing, attempt to do the code yourself then come here when you get stuck. You can also ask here for general guidance, for instance if you want to know how to compress an array of bytes then you can ask that question, to which you were earlier given an answer the same as you have received in this post - the only different here is someone has gone and searched for you.
In my opinion you are having a lucky day with everyone seeming so helpful, but if you don't start to attemp the work for yourself, people will be less willing to help you.
Also, in relation to your post, somebody was trying this the other day and found that compressing a JPEG stream in fact made it larger, this was possible due to the fact a JPEG file format is already designed for compression, so you may be best just leaving it as it is.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi,
I'm using MeasureString method to calculate size of a string. I used same font type and style. But for Chinese and Japanese text primitives the MeasureString returning more height than the height returned when English or French text primitives are passed to the MeasureString.
I used the following statement
return g.MeasureString(measureString, m_font, new PointF(0, 0), m_stringFormatForSizeCalc);
Where m_stringFormatForSizeCalc is set by the following method
m_stringFormatForSizeCalc = CreateSizeCalculationStringFormat();
StringFormat CreateSizeCalculationStringFormat()
{
StringFormat stringFormatForSizeCalc = StringFormat.GenericTypographic.Clone() as StringFormat;
stringFormatForSizeCalc.Trimming = StringTrimming.None;
stringFormatForSizeCalc.Alignment = StringAlignment.Near;
stringFormatForSizeCalc.LineAlignment = StringAlignment.Near;
stringFormatForSizeCalc.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap;
return stringFormatForSizeCalc;
}
Ex: font Arial Regular size 100.
For Chinese and Japanese strings height is 153
For English and French strings height is 149
|
|
|
|
|
This is normal for those characters. If you noticed, you're not exactly looking at a Latin character set. So, what's the problem??
|
|
|
|
|
The height calculated from MeasureString is used to find the font point size with the following formula
font point size = (adjustedPixelsPerInch) * (fontEmHeight / fontAscentAndDescention) );
adjustedPixelsPerInch = height in pixels * 0.75
0.75 is points per pix.
The problem is if i use different text primitives(say Chinese and English) of same size 100 and font type Arial regular.
While trying to render the text primitives the height calculated from MeasureString for Chinese string is higher than the English string. So the font point size that will be calculated while rendering is more than the actual 100 that has been set.
|
|
|
|
|
Raghu566 wrote: adjustedPixelsPerInch = height in pixels * 0.75
So where did this ".75" magic number come from??
|
|
|
|