DIALOG.CPP
上传用户:wtrl82617
上传日期:2007-01-07
资源大小:187k
文件大小:2k
源码类别:

界面编程

开发平台:

DOS

  1. // 1993 (c) ALL RIGHTS RESERVED
  2. // AUTHOR  BY XuYongYong
  3. /*  dialog.cpp
  4. */
  5. #include "dialog.h"
  6. #include "applicat.h"
  7. dialog_class::dialog_class(int ID,char *title,int left,int top,int width,int height)
  8. :win_class(ID,title,DIALOG_WIN,'2',left,top,width,height)
  9. { int width1=width-2*LINE_WIDTH;
  10.   int height1=height-bar_height-2*LINE_WIDTH;
  11.   int hbar=0.5*bar_height;
  12.   int vbar=1.5*bar_height;
  13. strcpy (ok_string,"&OK");
  14. strcpy (cancel_string,"&Cancel");
  15. ok_button =new Tbutton (OK_ID,ok_string,hbar,height1-2*vbar,
  16. width1/2 -2*hbar, vbar);
  17. cancel_button =new Tbutton (CANCEL_ID,cancel_string,width1 /2+hbar,height1-2*vbar,
  18. width1/2 -2*hbar, vbar);
  19. insert_control (cancel_button);
  20. insert_control (ok_button);
  21. // pcontrol_current_selected =ok_button;
  22. }
  23. //dialog_class::~dialog_class()
  24. //{
  25. // delete (ok_button);
  26. // delete  (cancel_button);
  27. //}
  28. int dialog_class::msg_handler (MSG& message)
  29. {
  30. switch (message.Action){
  31. case KeyPressedMSG:
  32. // if  (pcurrent_selected_win->type & DIALOG_WIN ) {   //dialog
  33.   int ret_val;
  34. ret_val=win_class::msg_handler (message);
  35. if (ret_val!=FALSE) return ret_val;
  36. if (key_code==ESCKEY) {thequeue.SendMessage(CANCEL_ID,
  37. ButtonPushedMSG,ok_button);return TRUE;} else
  38. if (key_code==ENTERKEY) {thequeue.SendMessage(OK_ID,
  39. ButtonPushedMSG,cancel_button); return TRUE;}
  40. break;
  41. case ButtonPushedMSG:
  42. switch (message.ID ) {
  43. case OK_ID:
  44. // case ok_button:
  45. if (! (canclose||func_canclose()) ) return FALSE;
  46. canclose =TRUE;
  47. thequeue.SendMessage(pcurrent_selected_win->ID,
  48. WinSysCloseMSG,pcurrent_selected_win);
  49. thequeue.SendMessage(pcurrent_selected_win->ID,
  50. DlgOkedMSG,pcurrent_selected_win);
  51. break;
  52. case CANCEL_ID:
  53. // case cancel_button:
  54. canclose =TRUE; // must quit
  55. thequeue.SendMessage(pcurrent_selected_win->ID,
  56. WinSysCloseMSG,pcurrent_selected_win);
  57. thequeue.SendMessage(pcurrent_selected_win->ID,
  58. DlgCanceledMSG,pcurrent_selected_win);
  59. break;
  60. }
  61. return TRUE;
  62. }
  63. return win_class::msg_handler (message);
  64. }