|
can't think of any pitfalls.
use tab orders, key press events and suchlike. it isn't too hard to do.
surgeproof
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
Make sure that the tab order of the controls is logical. i.e. the tabs move through the controls in one logical group before jumping to the next.
.
. +--------+ +--------+ +--------+ +--------+
. | Ctrl1A | | Ctrl1B | | Ctrl2A | | Ctrl2B |
. +--------+ +--------+ +--------+ +--------+
.
. +--------+ +--------+ +--------+ +--------+
. | Ctrl1C | | Ctrl1D | | Ctrl2C | | Ctrl2D |
. +--------+ +--------+ +--------+ +--------+
So, in this example, you'd tab from 1A to 1B to 1C to 1D rather than go for a Left-To-Right-Top-To-Bottom reading order approach.
This is just the first thought that popped in my head. There was a thread in the lounge today on bad-design (Some of it was quite funny) so the second thought is: As you test the system with your nice handy mouse beside you - resist the temptation to use it!
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Also, assigning shortcut keys to menu items is easy enough. To handle function keys or even simple key strokes you can handle the various Mouse* events (or override the various OnMouse* handlers in derived classes for more efficient and controllable code). If you need to respond to keys pressed at any time while any window is open, see the Application.AddMessageFilter method and the corresponding IMessageFilter interface which you'd implement and handle the keys trokes you want (in which case the values match up with the Keys enumeration to make things easier) by handling the various keyboard notification messages (see the Platform SDK for values).
Finally, to have a form handle key strokes while any control has the focus, see the Form.KeyPreview property documentation.
Using all that, who needs a mouse?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, everyone
I am using a dll developped in VC6. There are some functions I don't know how to wrap it in C#.
1. one function's parameter use self defined type, type definition is like this:
#ifndef LPLONG
typedef long far *LPLONG; /* 32 bit */
#endif
2. one function's parameter use 'BOOL *'
3. one function's parameter use 'char *'
4. one function's return value use 'char *'
5. one function's parameter use a structure
6. one function's parameter use a structure *
How shall I deal with these?
Thanks in advance.
|
|
|
|
|
1. ref int
2. ref bool
3. [MarshalAs(UnmanagedType.LPStr)]string
4. [return: MarshalAs(UnmanagedType.LPStr)]string
5. Just pass the struct, but see the docs for the StructLayoutAttribute
6. ref YourStruct
All these - escept for 3 and 4 - are value types so you use ref or out (the latter if you don't need to pass any initial value to your functions). Don't use ref or out with a string because it is already a reference type. Both char* and char[] are strings since a string is only an array of characters. Since you're using char and not wchar_t (or TCHAR ), you must marshal them as ANSI strings.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How about void *? Thanks.
|
|
|
|
|
|
Hello,
I'm trying to create a property sheet in C#. My idea is:
Create several user controls (derived from UserControl class) that represents my property pages.
Create a windows form that contains one Panel object to use like a placeholder for the pages created above.
The problem is that I don't know how to add a UserControl to a Panel object. (perhaps it's not possible...)
If someone has any idea on how to do this please reply
Thanks in advance
Pedro
|
|
|
|
|
Add a TabControl to a form with a few Button s under it. Add your UserControl s to each tab. After compiling your project, the UserControl s should be available in the Toolbox. If not, add them manually by adding a private field for each Type and instantiate them and initialize them in the InitializeComponent method that the Windows Forms designers use. It's not difficult and the designers aren't magic. Knowing how to add this stuff without a designer is essential in good development skills.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Thanks for your post!
The solution you gave works well, but I was looking for something like CPropertySheet and CProperyPage in MFC.
Is there any control that we can use as placeholder for other controls?
Thanks again.
By the way, I like programming with the keyboard, not with the mouse
|
|
|
|
|
That's not really what you asked for, though.
If you want a good implementation, see the IPropertySheet documentation in the Platform SDK on http://msdn.microsoft.com[^]. For example, I use a implementation similar to the following in our application:
public interface IPropertyPage
{
string Title { get; }
void Save();
void Cancel();
event PropertyChangedEventHandler PropertyChanged;
} Implement this type of interface on your control. Then create a PropertySheet class that allows you to add IPropertyPage implementations to it. When you call ShowDialog on your PropertySheet (should derive from Form ) it has all the pages in a TabControl . When the event is fired, enable the Apply button. When Apply or Save is clicked, call Save on each IPropertyPage in your collection and close the dialog if Save was clicked (it annoys me to no end when people click Apply then OK since OK is supposed to apply changes and close and - with all Microsoft implementations - does).
This is very similar to how MFC and the Windows Shell interfaces do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello again!
That's exactly what I was looking for!
Thanks for your time
Pedro
|
|
|
|
|
Hi All,
I have a Windows Forms app with a treeview control. I'm trying to add a 'Rename' command to the context menu. The event handler for the context menu looks like the following:
private void cmMTRename_Click(object sender, System.EventArgs e)
{
if (tvModelTree.SelectedNode != null)
tvModelTree.SelectedNode.BeginEdit();
}
The node goes into edit mode but the context menu stays visible. Is there a way to hide the context menu prior to putting the node into edit mode?
Thanks,
Chris
|
|
|
|
|
I was outsmarted by the tree control.
I was handling the MouseUp event to display the context menu. It seems the treeview already does this for me so I was displaying it a second time.
Thanks.
Chris
|
|
|
|
|
I've created an MSI installer with VS.NET 2003 which runs great. I've created two file type associations. The association is made, but when I right click on the associated file and view the proerites I notice something strange. The "File Type" information is correct = "My Prog File"
but the "Opens with:" data is not correct, it just shows the program icon and not the name. I've tracked it down to a registry entry:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\MUICache]
There is a registry string in there called:
"C:\Program Files\MyCompany\MyProgram Folder\MyProgram.exe"
the value for this string is blank. When I assign the value of "MyProgram.exe" to the entry, the associated file property page now reflect both the program icon and name in the "Opens with:" area.
Does anyone how this getts filled in ? Am I missing some kind of description property in my assemby ?
Any thoughts on how to fix this would be very much appreciated.
|
|
|
|
|
I figured it out...I was filling inthe AssembyInfo.cs attribute sections.
|
|
|
|
|
glad you sorted it! :p
-------------------------------------------------------
looking for hosting? ithium is good.
|
|
|
|
|
Absolutely *love* the name
You should see my office at home...I've got damn near the whole collection of the old-style Guinness posters up.
|
|
|
|
|
Everyone loves a Guinness, or should.
|
|
|
|
|
Hi'
i'm using a graphical list view name 'GlacialList' and its realy very good.
i need to put an image on my scroll bar, does anyone know how can i do it?
did someone take care the scroll bar events by itself?
|
|
|
|
|
|
Hello,
I am creating a toolbar for IE, almost like google toolbar. I want to give options for websearching, save current web page, and it should cofigurable from XML. I created a toolbar and it is visible in my IE, but I am struck in websearching part. Anybody please help me or give me the tips, how google and yahoo searches the web from its toolbar,and how can I implement it. please help me.
Thanks in advance for your time.
|
|
|
|
|
Are you asking about how to make the toolbar work? Or, what URL to send searches to? The latter is very easy: Just go to the search engine you want, type in something simple like "test". Then, after that gets submitted, copy the URL and replace the value you used with the search query. For instance, Google's would be: "http://www.google.com/search?q={0}".
Michael Flanakin
Web Log
|
|
|
|
|
how can i convert code from VB to C#:
( i am new to c#)
Public Function GetHiWord(ByRef lparam As Integer) As Integer
' This is the HIWORD of the lParam:
GetHiWord = lparam \ &H10000 And &HFFFF
End Function
Public Function GetLoWord(ByRef lparam As Integer) As Integer
' This is the LOWORD of the lParam:
GetLoWord = lparam And &HFFFF
End Function
Thanks
|
|
|
|
|
I believe this is right:
public int GetHiWord( int lparam )
{
return lparam \ (0x10000 & 0xFFFF)
}
public int GetLoWord( int lparam )
{
return lparam & 0xFFFF
} Michael Flanakin
Web Log
|
|
|
|