|
Awsome.. thank you for the reply.
This wizard is being created to giude users throught the complex process of creating a Bill OF Material or Assembly.
I have a Windows Form all ready setup to allow for the basic functionality
Enter the Top Level Number
if Not Exists
Create New Part
else
Get the Parts Record Number
Add Components to the Bill Of Material by using a TreeView and Context Menu
Bill Of Material -- Component Status
Bill Of Material -- Component Effectivity
.... ect ..
I am just thinking that I would like the process to be more (hand held) then it is now. That is why I have choosen to create a Wizard type of interface. This way I can give a very easy to use Navigation system to get through the process..
well thank you again
Will
|
|
|
|
|
anyone know the easiest way to play a wav file with direct x maybe a link to a tutorial or summet?
|
|
|
|
|
Hi,
I need to hold a string, int and a boolean in a class or struct. However I want to override the ToString() method and use it in a listbox. As Listbox Items are objects if I use a struct a lot of boxing and unboxing will be involved.
As I only have 3 vairables and accessor methods plus ToString I swing towards a struct, but would a class be better to avoid all the boxing and unboxing operations?
Thanks.
|
|
|
|
|
How many properties you have and whether or not you override ToString should not be a deciding factory for using a struct or a class.
Here are some of the factors:- Will it be short-lived? (y: struct, n: class)
- Must the item be instantiated quickly (y: struct (alloc'd on the stack), n: class (alloc'd on the heap))
- Will a lot of boxing/unboxing be required? (y: class, n: struct - which you obviously already know)
- Are small in size (.NET Framework recommends 16 bytes) (y: struct, n: class)
This is by no means a comprehensive list, but it does contain the things you should consider. Both classes and struct can define fields, properties, and methods, and both can implement interfaces. Classes can extend another class and define events. Both can also contain nested types.
If you feel you'll incur a big performance penalty from boxing and unboxing, then use a class. But if your structs are seldomly accessed as struct (i.e., you read in a bunch of structs once and don't deal with them again in your ListView or whatever), then I wouldn't worry about it.
If you want to take advantage of the fact that structs can be destroyed and memory on the stack can be reused ASAP, I would use the disposable pattern and implement IDisposable on a class. While instantiate does take only slightly longer (negligible in most cases), it probably won't affect you any.
So, here are some of the things you have to ask yourself. You know the scenario so you're really the only one that can answer them. More information is needed in order for anyone that doesn't already understand your project to draw any decent conclusion.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a treeview which I'm loading with various types of nodes, some with long text strings. If the last node to be loaded has a long string, the treeview scrolls horizontally to the right, so you can't see any of the nodes.
Is there any way to scroll the treeview back to the left in code, or can you think of any other way around this situation?
Thanks,
---Selden McCabe
|
|
|
|
|
You need to P/Invoke SetScrollInfo (user32.dll) to set the scrollbar positon.
In case you need further assistance, please revert back.
Regards,
Jay.
|
|
|
|
|
I have a VSS setup project that will copy files into a remote web server location.
In the View/UI I added a textbox dialog for the 3 key folders that can be created. The first is the path to the server. default is C:\Inetpub\wwwroot\yourwebsitedir and what I typed in was D:\Junk. The variable name (Property Name) was WEBSITEDIR.
In my View..FileSystem my ApplicationFolder is set to the property of [WEBSITEDIR] so it should pick up whatever is typed into the box.
When I type in D:\Junk and then do the setup, all files get sent to the C:\... directory instead of the overridden name (D:\Junk). I am stumped and cannot figure out why it is not setting the property to the new EditValue.
|
|
|
|
|
Hi all,
I got a problem with Return key in my C++/C# application.
On CView dilalog I put my C# control. This C# control has couple
other controls nested. I have problem with RichTextBox control which
is at the bottom of my control hierarchy. It does not process
VK_RETURN key down. So I can not create new line. All other keys work
in RichTextBox. Of course I made it Multiline. I used Spy++ tool to
figure out what is going on. I managed to see that RichTextBox window
receives ON_KEYDOWN message with VK_RETURN. But there is no WM_CHAR message which normally should follow WM_KEYDOWN. As a result no new line is created in RichTextBox.
Tried to catch WM_KEYDOWN in WndProc and OnKeyDown. But they are hit for all keys except of RETURN
I would greatly appreciate any hints.
Thanks in advance,
Roman
Roman
|
|
|
|
|
I over came this problem by using the ASCII value for the return key (13). Here's how it works in code:
<br />
private void YouCallBackMethod(object sender, System.Windows.Forms.KeyPressEventArgs e)<br />
{<br />
if (e.KeyChar == (char)13)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
}<br />
Hope this helped...
|
|
|
|
|
Peter Vertes wrote:
if (e.KeyChar == (char)13)
You could also do the following:
if(e.KeyChar == Keys.Return)
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks guys for the reply.
But my problem is a little deeper.
I can't hit WndProc or OnKeyPressed method at all when I press Return.
For other keys I can hit methods. Of course everething works fine if I put .Net control on c# Windows.Form. But if I reside .Net control on C++ CView form something goes wrong. System messaging works differently in these two cases. In Spy++ I can see that C# RichTextbox got message WM_KEYDOWN for VK_RETURN and then WM_KEYUP.
Normally WM_CHAR should follow WM_KEYDOWN which I can see when work in C# environment. Looks like ::TranslateMessage(msg) failed.
Roman
|
|
|
|
|
Is it a CFormView ? CFormView calls IsDialogMessage , which assumes that you're trying to press the default button on the form, or raises WM_COMMAND for IDOK if there is no default.
IsDialogMessage first probes the control with focus to see if it wants to handle this character. It does this by sending the control the WM_GETDLGCODE message. IIRC, the control has to return a code including the flag DLGC_WANTALLKEYS or DLGC_WANTMESSAGE in order to swallow the RETURN keypress. You'll need to experiment a little.
In your C# code, you'll probably have to override WndProc . The reason it works on a C# form is that the C# form manager doesn't use the pre-existing Windows dialog manager code - it's a new implementation.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks Mike for attention to the problem.
Actually I managed to catch pressing Enter key in WindowProc overriden method in CFormView with WM_COMMAND message for IDOK. Then I simplify my testing project and put C# control on CDialog. Same thing. On C# side I cannot catch Enter in overriden WndProc. No messages at all when pressing Enter. Probably message could not reach C# control on its way. So I need to do all necessary message calls on C++ side in WindowPoc. I tried to call TranslateMessage(msg) with hwnd of my RichTextBox to get WM_CHAR in textbox. This call was not successful and returned 0. When I did the same call against CEdit control it worked and message was translated. Now the question for me is : which kind of message should I send to RichTextBox ? Maybe it is IsDialogMessage(RichTextBox_HWND, WM_KEYDOWN_MSG) if I understood your comment correctly. I hope RichTextBox will swallow Return keypress. But I need to know hwnd of RichTextBox. For testing app it was not difficult. But in real app will not be so easy to get it on surface. Any idea how to avoid knowing RichTextBox hwnd ?
Thanks a lot
Roman
|
|
|
|
|
Finally solution was found
I had to override WndProc in the derived class of RichEditBox,
catch pressing Enter key and do my job.
protected override void WndProc(ref Message m)
{
int WM_GETDLGCODE = 0x0087;
int VK_RETURN = 0x0D;
if (m.Msg == WM_GETDLGCODE)
{
if (m.WParam.ToInt32() == VK_RETURN)
{
base.SelectedText = "\n";
return ;
}
}
base.WndProc (ref m);
}
|
|
|
|
|
aloa
okay buddies =D my idea is to develop an ip-blocker. the user defines a set of ips that are blocked from the system.
my question is now: is this in c# actually possible or do i have to switch to c++?
regards
|
|
|
|
|
As discussed before, .NET is too high level for such a task at this time. There is a lot of native APIs and interfaces to both implement and consume. You should download and read the networking sections of the Microsoft Platform SDK[^]. There's a lot to understand. A firewall is a very low-level application and requires that you understand how the Microsoft networking protocols work together and with the network interface cards (NICs).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
please introduce me a way to notify user that a process
request a socket in c#
koosha
|
|
|
|
|
.NET is too high-level for this sort of operation. This requires very low-level APIs and implementations with the Microsoft networking protocols, which also requires extremely efficient code with a small footprint - another reason not to use .NET.
There are already several commercial (typically free for home use) applications that do this already.
This has been discussed in the forums before. If you want to see how that thread progressed (to the same conclusion), please click "Search comments" directly above the message board.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
is there any messsage to notify user that a process
request a socket in c# or by win apis
koosha
|
|
|
|
|
Hi~
Lei wrote
"I have 2 forms, form1 contains a ListView. What I want to do is, when
clicking an item in the ListView, hide form1 and show form2. Code for
ListView's SelectedIndexChanged: { form2.Show(); this.Hide(); }. When I
click the item, form2 shows with form1's title and menu. I noticed that when mouse down, the SelectedIndexChanged event was triggered and bring form2 to front. But when mouse up, system redrawed the selected item and bring title and menu back to form1's. I tried to handle MouseDown and MouseUp event of ListView but they were never triggered. Now I used a tricky way to solve the problem: start a thread and use Control.Invoke to switch forms. It is not good, I think there must be a better solution. Thanks."
I am facing the same problem. Someone solve it with setting timer. However, is there any other way to solve it?
Thanks~
|
|
|
|
|
Don't use the SelectedIndexChanged event. It won't tell you if the user clicks on the currently selected item, either. Also, if the user is trying to use the direction pad or scroll wheel, the event will fire as they're scrolling between items; you probably want it to fire only when they press the Action button.
What you should do is set the Activation property to ItemActivation.OneClick, and handle the ItemActivate event. This also gives you keyboard/keypad interaction for free.
Don't you just love the complete, comprehensive nature of the documentation? In response to your post, I tried this out on both .NET CF 1.0 SP3 and on 2.0 Beta 1. At least 2.0 Beta 1 gives you a compiler warning. I've raised the issue on the Compact Framework newsgroup, and I hope that will encourage clearer documentation.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
It works!
Thank you very much!
|
|
|
|
|
How about treeview?
treeview got that same problem
there is no activation event handler in compact framework
|
|
|
|
|
Hi gurus,
I have 2 questions:
1) How can I attach a hwnd to a graphics?
When I do Graphics gr=new Graphics(m.HWnd) , I have the message "System.Drawing.Graphics.Graphics(System.IntPtr) is inaccessible due to its protection level"
2) What is the equivalent of the GetSystemMetrics() API in C#?
Best regards.
Thanks.
There is no spoon.
|
|
|
|
|
Graphics gr = Graphics.FromHwnd( m.HWnd ) If the HWnd is coming from a Windows Forms control, use ctl.CreateGraphics() instead.
As for GetSystemMetrics, that depends on what values you want. The simplest thing to do is often to use P/Invoke.
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int GetSystemMetrics( int metric );
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|