|
Why do you want to handle these WM_ messages??
for example: Why not add the Load event to the form instead of WM_INITDIALOG?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C# and C++!
|
|
|
|
|
I know in PreFilterMessage you are able to 'cancel' incoming messages, but it possible to process the messages here ?? I need process WM_NCHITTEST and return e.g. always HTCLIENT.
Exist something like PreProcessMessage where you are able to preprocess all messages which are incoming into app ?
Thanx.
W.
|
|
|
|
|
You can use WndProc for that. It is not necessary to use PreFilterMessage
|
|
|
|
|
yes it is possibility, but Iam writing program like form desinger and I need ever when is called WM_NCHITTEST process this and return HTCLIENT ...Do you know how to do this ?
W.
|
|
|
|
|
I assume you're changing it to HTCLIENT so that the user can't drag the form around, correct? If thats the case just don't let the message be dispatched to the form (return true from PreFilterMessage).
James
|
|
|
|
|
I declare a byte array:
byte[] byteIn = new byte[1024];
I write to it like so:
newin = false;
Console.WriteLine("Waiting to recieve new data from client");
while(!newin)
{
mySocket.Receive(byteIn, 0, mySocket.Available, SocketFlags.None);
strIn = Encoding.ASCII.GetString(byteIn);
if(strIn != strInbuff)
{
newin = true;
}
strInbuff = strIn;
Console.WriteLine(strIn);
}
The problem is, next time I loop to this nested while statment if I write a smaller value to my byte[ ] it leaves some info unwritten... I need a way of clearing it. Is there some function for this that I can't find on msdn?
Also, If anyone has a better way of detecting new input from a socket let me know... for now I use this resource consuming while loop.. it requires a string for input and a string to see if that input is new (in which case the loop is broken).
Another quick question. I want to declare a class public, like so:
cserver CServer = new cserver();
is how i delcare it, but this object is not accessable to other functions/objects... i cant do public cserver CServer = new cserver(); , I already tried
Thanks.
|
|
|
|
|
...not accessible...
the members of the cserver-object are not accessible? by default all members are declared for private use only. so add a "public" keyword to each of the members you want to access from outside the class in the class-definition itself.
btw: to use "public" in the declaration of the CServer-variable makes no sense - access-rights are defined within the class-definition itself, thats by design.
it seems, you have to read another "introduction to object-oriented programming" article - or i misunderstood your question.
:wq
|
|
|
|
|
Specifically it says 'type or namespace not found'
My only prior use of objects was in php, I never had to deal with a class being declared in another class.
class myClass
{
int number;
public upNum()
{
this.number++;
}
}
class anotherClass
{
public static void myFunction()
{
numclass.upNum();
}
}
class app
{
public static void Main()
{
myClass numclass = new myClass();
anotherclass.myFunction();
}
}
Sorry for the formatting, but why won't anotherclass be able to access numclass (well I know why, I need to know how to let it).
Thanks.
|
|
|
|
|
Is there any way to check how long since the last user input on the PC? Ie: ICQ sets itself to 'Away' status after x minutes.
I've seen ppl call windows functions from their c# apps and i have a feeling this will be the same (user32.dll perhaps).
I am a novice in this area, so any tips would be appreciated...
|
|
|
|
|
what about the dirty way? have a timer reset each time a mouse or keayboard event occurs?
:wq
|
|
|
|
|
http://www.saurik.com seems to be down.
does anyone have an alternate download-location?
thx in advance.
:wq
|
|
|
|
|
|
yeppa!
you're right. today it works again
seems there were serverproblems yesterday...
:wq
|
|
|
|
|
Hello
I'm having extreme problems adding a WebBrowser control to a .NET C# application, that is if I add the COM control from Microsoft then the COM brigde seem to be so badly broken that the BeforeNavigate2 will never ever fire. (All other events of the control will fire correctly as expected)
I also tried to wrap the Control into another control in VB6 and import that com control, but .NET does not like that and simply gives a blue screen there.
So my question here is has anyone been sucessful in using a browser control in .NET app, and been able to get the BeforeNavigate2 event to work ?
Thanks
Björn
|
|
|
|
|
Its been a known bug for 6 months now so who knows if it'll ever get fixed.
Andy Gaskell, MCSD MCDBA
|
|
|
|
|
|
Hi
How can i display the "sub" properties of a class or struct (like image, size, font) in the property grid?
I am designing custom controls and would like to "group" related information. IOW. control have Borders property that refers to a Borders object (class/struct) , that contains 4 Border objects (class/struct) for each side. Each object contains various info like color, width, style, etc.
Thx
|
|
|
|
|
You can get each one and convert it to string and put the text in grid.Something like this:
datagrid[1][1].Text = yourcontrol.BackGroundColor.Tostring();
Is that what you want or I'm in wrong way?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Sorry i have no clue what you are trying to explain, but thx for the quick answer.
OK, lemme explain a bit more. I have a Button control with a Borders Property. Borders is a class (see below). I would like to individually edit the properties of all Properties within Borders at DESIGN TIME.
Here's the code:
<br />
public class Border<br />
{<br />
int width;<br />
int margin;<br />
Color colorNormal;<br />
Color colorOver;<br />
Color colorDown;<br />
ButtonBorderStyle style;<br />
<br />
public Border()<br />
{<br />
width = 1;<br />
margin = 1;<br />
colorNormal = Colors.borderColorNormal;<br />
colorOver = Colors.borderColorOver;<br />
colorDown = Colors.borderColorDown;<br />
style = ButtonBorderStyle.Solid;<br />
}<br />
<br />
public ButtonBorderStyle Style <br />
{<br />
get {return this.style;}<br />
set {this.style = value;}<br />
}<br />
<br />
public int Width <br />
{<br />
get {return this.width;}<br />
set {this.width = value;}<br />
}<br />
<br />
public int Margin <br />
{<br />
get {return this.margin;}<br />
set {this.margin = value;}<br />
}<br />
<br />
public Color ColorNormal <br />
{<br />
get {return this.colorNormal;}<br />
set {this.colorNormal = value;}<br />
}<br />
<br />
public Color ColorOver <br />
{<br />
get {return this.colorOver;}<br />
set {this.colorOver = value;}<br />
}<br />
<br />
public Color ColorDown <br />
{<br />
get {return this.colorDown;}<br />
set {this.colorDown = value;}<br />
}<br />
<br />
}<br />
<br />
public class Borders<br />
{<br />
Border left;<br />
Border right;<br />
Border top;<br />
Border bottom;<br />
<br />
public Borders()<br />
{<br />
this.left = new Border();<br />
this.right = new Border();<br />
this.top = new Border();<br />
this.bottom = new Border();<br />
}<br />
<br />
public Border Left <br />
{<br />
get {return this.left;}<br />
set {this.left = value;}<br />
}<br />
<br />
public Border Right <br />
{<br />
get {return this.right;}<br />
set {this.right = value;}<br />
}<br />
<br />
public Border Top<br />
{<br />
get {return this.top;}<br />
set {this.top = value;}<br />
}<br />
<br />
public Border Bottom <br />
{<br />
get {return this.bottom;}<br />
set {this.bottom = value;}<br />
}<br />
<br />
public override string ToString()<br />
{<br />
return "Click to expand...";<br />
}<br />
}<br />
Now i would like to get that "+" sign on the propertygrid next to the Property so i can access all subitems.
Thanx
still
|
|
|
|
|
You need to implement a TypeConverter for those objects. In my screen saver application. I have an example of how to do it. Otherwise you can search MSDN for ExpandableObjectConverter you will find that there is an article with sample code on how to do it.
|
|
|
|
|
Thx will have a look
UPDATE: works great
|
|
|
|
|
You need to create a TypeConverter for your Border class then apply the System.ComponentModel.TypeConverter attribute to it.
If you look in MSDN there is a sample of a TypeConverter for the Point struct (I found it in the help topic for the TypeConverter class). In addition to what the sample implements there are two extra methods you need to implement: GetPropertiesSupported and GetProperties.
Below is the code which implements those two methods for my class Bar which contains two properties; Width and Height.
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes)
{
PropertyDescriptorCollection pdc;
string[] properties;
pdc = TypeDescriptor.GetProperties(typeof(Bar), attributes);
properties = new String[2];
properties[0] = "Width";
properties[1] = "Height";
return pdc.Sort(properties);
} Good luck,
James
[Edit: That should teach me to start replying to a message *then* figure out the exact solution ]
|
|
|
|
|
Hi, no need to go thru all that for 2 properties
Code snippet of how i did it:
UPDATE: add the following line whereever u add the typeconvertor else properties wont be saved by the designer.
<br />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]<br />
My Custom Control Class
...
<br />
[TypeConverter("System.ComponentModel.ExpandableObjectConverter")]<br />
public Borders Borders <br />
{<br />
get {return this.borders;}<br />
set <br />
{<br />
this.borders = value;<br />
}<br />
}<br />
<br />
...<br />
Then for each public Property in my class (iow Left, Right, etc) i added:
<br />
<br />
[TypeConverter("System.ComponentModel.ExpandableObjectConverter")]<br />
Use this till you get to primitive types or have Editors for the Property.
Hope this helps
PS: If you do not want the class name to appear, just override the ToString() function to something better like this:
<br />
public override string ToString()<br />
{<br />
return "Click to expand...";<br />
}<br />
or
<br />
public override string ToString()<br />
{<br />
return "Width: " + width + " Style: " + style.ToString() + " Margin: " + margin;<br />
}<br />
|
|
|
|
|
leppie wrote:
PS: If you do not want the class name to appear, just override the ToString() function to something better like this:
I think this may be the advantage that you get by implementing your own TypeConverter. If you look at many of the .NET types you can edit the one-line string version and have it update the correct values. It doesn't look like you can do that with that particular method.
Sometimes that is a nice feature to have (I commonly use it for Point, Size, and Font types) but other times it may be wasted.
I guess you go for what makes sense to implement; if you don't see the user editing the string version then your method works great; where-as for Point, Size, etc this may be the better deal because of enhanced functionality.
There is no wrong choice either way
James
|
|
|
|
|
Hey Thanx
I was looking for that answer still, gotta lot to learn still. But after reading thru it twice, i understand your point. Thanx. EG perhaps to set common properties in my case
|
|
|
|