nested forms - Modeless dialog created by modal dialog in Compact Framework -


i working on compact framework application. particular hardware implementation has touchscreen, soft input panel has buttons small useful. there more 1 form typed input required, created form buttons laid out keypad. forms use "keypad" form modal dialogs. when dialog requiring "keypad" loads, load "keypad" form modeless:

    private void cardinputform_load(object sender, eventargs e)     {         ...         keypadform = new keypadform();         keypadform.owner = this;         keypadform.setcallback(keyhandler);         keypadform.show();     } 

the setcallback method tells "keypad" form send keystrokes (as delegate). problem i'm having modeless "keypad" form not take input. displayed expect, beep when press of buttons, , caption grayed-out. seems modal dialog blocking it. i've read other posts on forum says modal dialogs can create & use modeless dialogs. can shed light on situation? there problem implementation?

i found answer: set keypad form's parent property, not owner property, form instance wanting keystrokes. keypad dialog's title bar stays grayed out, form active.

    private void cardinputform_load(object sender, eventargs e)     {         // (do other work)         keypadform = new keypadform();         keypadform.parent = this;         keypadform.top = 190;         // set appropriate         keypadform.show();     } 

be sure clean when done parent form. can in parent's closing or closed events.

    private void cardinputform_closing(object sender, canceleventargs e)     {         // (do other work)         keypadform.close();         keypadform.dispose();     } 

there 2 panels on keypad form, 1 numerals , 1 letters , punctuation want. there area not on panel common both, containing buttons clear, backspace, enter/ok, , cancel. each panel has button hide , unhide counterpart ('abc', '123', example). have buttons input on keypadform fire common event. send button instance parent. parent responsible determining action or keystroke desired. in case named buttons "btna", "btnb", "btn0", "btn1", "btncancel", etc. keystrokes, parent form takes last character of name determine key desired. bit messy works. form wishing use keypad form inherits base class, defining method callback.

    public partial class timeclockbase : form     {         public timeclockbase()         {             initializecomponent();         }          // (other implementation-specific base class functionality)          public virtual void keycallback(button button)         {         }     } 

the click event on keypad form looks this.

    private void btnkey_click(object sender, eventargs e)     {         // play click sound if supported         (parent timeclockbase).keycallback(sender button);     } 

the method in parent form looks this.

    public override void keycallback(button button)     {         switch (button.name)         {             case "btncancel":                 // setting result cause form close                 dialogresult = dialogresult.cancel;                 break;             case "btnclear":                 txtcardid.text = string.empty;                 break;             // (handle other cases)         }     } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -