disabling right click

[b][red]This message was edited by kgaoza at 2005-6-6 8:10:51[/red][/b][hr]
Hi all

I've developed an application in c++ builder 5. For some of the editboxes I used, the input is limited to integers only. but now my problem is that it is possible for the user to copy and paste into the editboxes and my porgram crushes. I need help with disabling the mouse right button.
Any help will do. (kshakon@yahoo.co.uk)



Comments

  • : [b][red]This message was edited by kgaoza at 2005-6-6 8:10:51[/red][/b][hr]
    : Hi all
    :
    : I've developed an application in c++ builder 5. For some of the editboxes I used, the input is limited to integers only. but now my problem is that it is possible for the user to copy and paste into the editboxes and my porgram crushes. I need help with disabling the mouse right button.
    : Any help will do. (kshakon@yahoo.co.uk)
    :
    :
    :
    :

    I assume you made, that onkeypress if pressed key is not number you don't write it, yeah? Well, i'd make it a little bit different. At event OnChange I'd write something like this:

    AnsiString txt=Edit1->Text;
    int curpos=Edit1->SelStart;
    for(int i=0;i57) {
    txt.Delete(i+1,1);
    curpos--;
    i--;
    }
    }
    Edit1->Text=txt;
    Edit1->SelStart=curpos;

    That way, if entered symbol is not number, it will delete it from field. The deal with curpos is needed, so cursor would stay at position it was.

    And actually, i don't understand why you must let only integers to be written. You can use atoi function to convert text to integer. For example:

    int num=atoi(Edit1->Text.c_str());

    If there will be letters, atoi will return 0.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion