|
Some of the .net controls are drawn directly by windows and bypass the .net events. Override the WndProc function and handle thw WM_whatever you need there. Make sure you pass any messages you don't want to the base WndProc function. I had to do this on a toolbar.
|
|
|
|
|
I have various custom controls derived from UserControl that appear in modal forms. Within Dialogs the arrow keys are an alternate form of tab control i.e they move to the next control in the direction of the arrow within the current container ( this is standard windows behaviour I think ).
The trouble is I want to be able to respond to arrow keys in one of these controls. No key event is generated ( or sent to me ). Even overriding WndProc and checking for WM_ messages that way doesn't work.
I notice that list boxes etc are able to get these key events.
Any ideas ?
-Duncan
dmeech AT riverdeep DOT net
|
|
|
|
|
Hi Everyone,
Question: How would I test if someone was holding control while they pressed enter in a textbox?
I'm currently doing this:
int nReturn = Keys::Return;
int nControl = Keys::Control;
int nData = nReturn + nControl;
if (e->KeyData == nData) Now this code works, but you have to press enter twice while you're holding down control. Does anyone know why? Am I doing something wrong in the code? Another quick question, how would I do all code in one if condition? I tried:
if (e->KeyValue == Keys::Return & Keys::Control) but get this warning:
warning C4806: '&' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant if I put brackets around Keys::Return & Keys::Control it gets rid of the waring, but it still doesn't execute the code in the if block.
I know my code is in MC++, but if you could help (just give your response in C#) it would be very appreciated.
Thanks!
- monrobot13
|
|
|
|
|
Use the BitWise OR operator ('|') not AND ('&')
<a TITLE="See my user info" href=http:
|
|
|
|
|
Now that I think about it that makes a lot more sense. It works now, but I still have to press enter twice for it to actually go into the correct block. Any idea's on that?
Thanks!
- monrobot13
|
|
|
|
|
How do I convert a double value to an byte array (byte[8]) and the reverse from byte array till a double value?
In C++ we may take a memcpy to an char array and cast the array to a float!
|
|
|
|
|
Take a look at Convert class, especially ChangeType method.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Look at the BitCOnverter class rather
<a TITLE="See my user info" href=http:
|
|
|
|
|
Hello Gurus,
I've been searching for the common icons such as CLOSE, CANCEL, SAVE, CLEAR, NEW, DELETE, Etc... But no luck. Do you know where I can find them?
Thanks again
Khang Nguyen
|
|
|
|
|
They are not stored as icons, but are stored as bitmaps.
You can create a simple single or multiple document project using the wizard and then copy them from the toolbar resouce.
OR TRY
C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps
Where there are bitmaps for the items you listed in more than 1 directory.
Trust in the code Luke. Yea right!
|
|
|
|
|
That's very helpful! Thank you very much, John.
Khang
|
|
|
|
|
I am looking for a simple alert box to simply display an error message. I was wondering if there was a C# equivlent to AfxMessageBox Thanks if you have any advice.
Matt Newman
Post best viewed with lynx
|
|
|
|
|
Matt Newman wrote:
C# equivlent to AfxMessageBox
MessageBox.Show (message, title, buttons, icon);
- monrobot13
|
|
|
|
|
Too easy
Matt Newman
Post best viewed with lynx
|
|
|
|
|
|
Kant wrote:
Just remove the Afx.
Too easy, I would have never thought of that
Matt Newman
Post best viewed with lynx
|
|
|
|
|
Hi All,
Question: Is it possible to get the size of the main application? Here's my problem, I have a class that needs to know the size of the main form, but it's buried deep in a class heirarchy so it doesn't have direct access to the forms properties. Is there a function to get the main form?
Thanks!
- monrobot13
|
|
|
|
|
monrobot13 wrote:
it's buried deep in a class heirarchy so it doesn't have direct access to the forms properties
That is nonsense! The root is most buried, all specializations are leafs.
There is the ParentForm property, you can call that continuously.
<a TITLE="See my user info" href=http:
|
|
|
|
|
Fisrt thanks,
Second, my class is derived from Panel which doesn't appear to inherit from ContainerControl which is where the ParentForm propery is. Any other way that you know of to solve the problem?
- monrobot13
|
|
|
|
|
Control.TopLevelControl Property
Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.
<a TITLE="See my user info" href=http:
|
|
|
|
|
That worked beautifully. Thanks!
- monrobot13
|
|
|
|
|
I think I found a bug in C#'s Rectangle. At least, it seems like an
inconsistency.
A Rectangle is defined as a combination of a Point (the top-left corner)
and a Size.
Let's say I have a Rectangle at (0,0) with a Size of 100x100.
If I call Rectangle.Top, it returns the Y-coordinate of the top of
the rectangle. Likewise, for Rectangle.Bottom, Rectangle.Left, and
Rectangle.Right. So, for this Rectangle, Top = 0, Left = 0, Bottom = 100,
and Right = 100. At least, according to the Rectangle class. But
if I call Rectangle.Contains(new Point(100,100)), this returns false.
Technically, it seems that Rectangle.Contains() is behaving correctly.
Logically, the rectangle's true bounds are (0,0) to (99,99). So
(100,100) isn't really in that rectangle. But I would argue that
Rectangle.Bottom and Rectangle.Right shouldn't be returning 100, either,
if they are returning the coordinate of the corresponding edge.
Either Rectangle.Contains() needs to be fixed, or Bottom and Right need to be fixed. I think the latter is more appropriate. Until then, I guess we need to deduct 1 from those properties.
|
|
|
|
|
Think Zero based Array (vector)!
<a TITLE="See my user info" href=http:
|
|
|
|
|
What about it? If you're suggesting that I have an off-by-one error in my head, I don't think so -- it would appear that Microsoft does. In fact, someone at Microsoft agrees:
Arun-
Thanks for your feedback!
You are right, the Rectangle version of these descriptions and the
Control version are both a little bit off in different ways.
I have passed your message on to a member of the test team for further
inquiry; he is investigating the behavior and will open a bug (or bugs)
based on what he finds.
Thanks again reporting this, and please continue to send us mail, should
you encounter behavior that seems curious (or other problems).
Seth Grossman
Microsoft Corp.
|
|
|
|
|
Note:
A rectangle under windows does not draw at the right or bottom of the rectangle. Therefore the bottom and right are not with in the rectangle (Bottom and Right are limits).
This is by design on the part of Microsoft and it does not matter if you are programing in C, C++, C#, VB, etc...
Trust in the code Luke. Yea right!
|
|
|
|