|
Put in something like this:
Message msg = Message.Create(this.Handle, WM_KEYDOWN, new IntPtr((int)e.KeyCode), IntPtr.Zero);
base.WndProc(ref msg);
e.Handled = true;
DLLImport User32.DLL and declare WM_KEYDOWN message as:
public readonly static int WM_KEYDOWN = 0x0100;
Let me know if you got that!
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
Arjun "Mjolnir" Bahree, you rock.
It works perfectly, except that I had to take out the DllImport line because the compiler (just csc.exe) was giving me:
error CS0592: Attribute 'System.Runtime.InteropServices.DllImport' is
not valid on this declaration type. It is valid on 'method' declarations only.
However, I do have one little question... since I'm sending it a WM_KEYDOWN message, do I have to send it a keyup message as well? Will it think I'm holding down the pagedown key if I don't send it a keyup message?
(I just shortened the pre text so that it wouldn't stretch the browser window out)
-- modified at 16:16 Saturday 9th September, 2006
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Ohhh! The DLLImport line was for some more tasks that you could have achieved but I did not mentione for brevity's sake. And ideally it is meant to import user32.dll.
Yes you need to send keyup message. Else it will keep on sending the pagedown messages to the control.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
I wasn't sure if I should send it a keyup message as well (so it won't think I'm holding the key down), so I added it (WM_KEYUP, 0x0101).
By the way, a little while ago I found a list of windows messages (Googling "list of windows messages"), but didn't know how to use them.
Thank you, Arjun "Mjolnir" Bahree!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Super work on starting with windows messages.....Read Petzold! Awesome work! Bible for a programmer! You will find the mechanics of Win Messages there at least to start with. Also I suggest you to have a look at Windows.h and maybe that will give you some surprise info? )
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
I thought Windows.h was only a C++ thing (I used to do C++)...
I thought that once I'd seen the light and converted to C#, I wouldn't need to hassle with header files anymore...
How would having a look at Windows.h help me out?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Well windows.h will give you an insight onto the #define for the numerous messages that windows throws.
Using the same stuff, as in WM_KEYDOWN and the likes, you can code trapping of the rest messages. That's the most comprehensive message list you can get for a Win platform.
Yes its a C++ thing and that is still the game beneath C#, after all its all the win messages that get raised, which are beautifully wrapped by .NET system events.
That's just for learning and reference purposes. You do not have to hassle with header files anymore, but for interacting with native mechanism this info is important.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
is there a winform label control that can support HTML tags?
I dont want to use richtextbox.
I have no special talents, I am only passionately curious.Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted"
-(Albert Einstein)
|
|
|
|
|
From what i understand, you need a label control and not a textbox.
There is no inbuilt control for that for winforms as such.
However, on similar lines, you can use this one by Palomraz
http://www.codeproject.com/vb/net/rtflabelcp.asp
Doe that solve your purpose, or am I not near your question?
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
thanks for the reply
i have already seen that solution and it seems you have to call an .rtf file to display as the label content.
what i wanted is a simple label control that can support HTML tag so when i do this for example:
The total transaction for this account is <b>100,000.00</b>, please be notified.
so by doing this i can only select the portion of the sentence to be bold or colored.
I have no special talents, I am only passionately curious.Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted"
-(Albert Einstein)
|
|
|
|
|
OK now i understand.
So for this you can override the label control, and use the EmbedHTML/MapHTML script display inline HTML, which is what RichTextBox uses internally.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
can you please point me to a link or a demo sample on how to do this?
or by using the EmbedHTML/MapHTML script display inline HTML for richtextbox.
thanks a lot
|
|
|
|
|
OK. The way I did it was by hosting an .htc inside my custom control.
This HTc did the trick of acting like a label.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
hi,
i'm not expert in C# i have small question is there any tool in
C# like RMI package in Java
Regards,
Charbel Asmar
|
|
|
|
|
The equivalent for RMI in .NET is remoting. Search and checkout the articles on this website to get an idea of what it is and how you can start building with it.
WM.
What about weapons of mass-construction?
|
|
|
|
|
RMI in Java is same as Remoting in .NET
Dependency on similar technology at bothe the ends and an elaborate and sophisticated RPC mechanism. I suggest read the book by Ingo Rammer, the best one in the market.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
I use VS 2005 and C# for only two weeks and I'm desperate in this problem. My program, (screenshot), has two columns with the same content - buttons and textboxes. I really don't know, how to create some simple code usable for both of them. These textboxes and buttons has similar names, like:
textBoxAInput, textBoxAIV, textBoxAIV2, richTextBoxARunda1IVBin; textBoxBInput, textBoxBIV, textBoxBIV2, richTextBoxBRunda1IVBin;
and there are buttons like: buttonTextA, buttonTextB
There is about 20 textBoxes in both colomns.
What can you recommend me to use: I want to have just one general program capable opperate with both columns? ...some delegates, or special classes, some universal usercontrol, maybe interface? I'm begginer in C# and I don't know well these special purpose "things".
The best idea I have is, if possible, using strings as names: pseudocode
void printsomething(char ID)
{
//ID is A or B
string nameIV1 = new string("textBox" + ID + "IV1");
nameIV1.Text = "something"; //any idea, how to use "string as object name"?
}
I don't wanna use unsafe code, so there's no way using references, like:
if (sender.Equals(buttonTextA))
textBoxIV = &textBoxAIV;
else
textBoxIV = &textBoxBIV;
//or is something like that possible in "non-unsafe" code?
any idea, how to do this?
thank a lot for any help.
Source code and further informations about the program - here
|
|
|
|
|
Hello
I hope i got you right. Two things to mention:
1- If you want to access control by name like you stated use this.Controls["MyControlName"]
2- If you want to make a sinle event handler for several controls, select them all in the designer, then in the PropertyGrid write the name of the method you wish to handle the event in that event's field.
Or in the code write this:
MyButtonA.Click += new EventHandler(MyHandler);
MyButtonB.Click += new EventHandler(MyHandler);
Then MyHandler will handle the Click event in both buttons.
If you need more similar help, or if I missed something, please post more details of what you need.
Regards
|
|
|
|
|
Re 1: this.Controls["MyControlName"] : I've tested this way now, but it doesn't work. It throws an exception: "Additional information: Object reference not set to an instance of an object." I'm not sure, where's the problem:
String vstup1Hex = "richTextBox" + id + "1Hex"; //id is A
Controls[vstup1Hex].Text = Radix.Stream2Hex(Input, 16, 4); // doesn't work
Re 2: I use one handler for every pair of buttons for some time. But still, in this MyHandler function I have to determine, which textboxes I have to work with richTextBoxA1Bin or richTextBoxB1Bin, etc.
|
|
|
|
|
Hello
This exception means that the control with this name is not a memebr of the controls of the form. Two possible problems:
1- What is th id part?? is it a string? Check you casing because names are case sensitive in C#.
2- You've put your control in a container control, eg. GroupBox, Panel, etc... If this is the case use MyGroupBox.Controls[ControlName] instead because the button is a member of the groupBox's controls not the form's controls.
PS.
Don't forget to cast the control into the type that you want if you need to, eg.
if(Controls["MyButton"] is a Button)
{
((Button)Controls["MyButton"]).PerformClick();
}
-- modified at 17:45 Saturday 9th September, 2006
BTW:
The screenshot link is working now, and I took a look at your form. It's number two. You have to access the control by the GroupBox name.
Regards
|
|
|
|
|
Yes, I have specified the GroupBox names and now, it works. Thanx a lot!
|
|
|
|
|
Does anyone know how to retreive the command line arguments for an existing external process ? StartInfo.Arguments does not contain it.
|
|
|
|
|
Hello
Why, I wonder?? Arguments should be in that property!! Try using the ProcessStartInfo.Verbs property instead.
Regards
|
|
|
|
|
Verbs does not contain any command line args at all. It purpose of use is very different. it indicates the actions that the system can apply to the file indicated by the FileName property of ProcessStartInfo class.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
Well do i assume that the external process is a managed app?
Anyways, any process started with command line arguments, has them stored in the process primary stack, since they are in scope of the entry point. You need to write a generic unmanaged code piece to access the string array passed into the entry point by the c runtime in an unmanaged process. For a managed app you need to get the pointer location of the entrypoint and then in contigous to the it would be the command line arguments passed in. you can see where the arguments finish by wrapping your search before any instruction address or jmp instruction appears.
Does that make something clear here?
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|