a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
msg.cpp
gehe zur Dokumentation dieser Datei
1 // msg.cpp: MessageBox f.d. FLEX-Befehl Mes
2 // macht eine countdown-Messagebox links oben
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 #include "stdafx.h"
6 #include "ca99.h"
7 #include "a99.h"
8 #include "resource.h"
9 #include "msg.h"
10 
11 #ifdef _DEBUG
12 #define new DEBUG_NEW
13 #undef THIS_FILE
14 static char THIS_FILE[] = __FILE__;
15 #endif
16 
17 /////////////////////////////////////////////////////////////////////////////
18 // Dialogfeld Msg
19 
20 
21 Msg::Msg(CWnd* pParent /*=NULL*/,int md)
22  : CDialog(Msg::IDD, pParent)
23 {
24  //{{AFX_DATA_INIT(Msg)
25  //}}AFX_DATA_INIT
26 }
27 
28 void Msg::DoDataExchange(CDataExchange* pDX)
29 {
31  //{{AFX_DATA_MAP(Msg)
32  DDX_Control(pDX, IDC_MSG, m_msg);
33  //}}AFX_DATA_MAP
34 }
35 
36 BEGIN_MESSAGE_MAP(Msg, CDialog)
37  //{{AFX_MSG_MAP(Msg)
38  //}}AFX_MSG_MAP
39 END_MESSAGE_MAP()
40 
41 /////////////////////////////////////////////////////////////////////////////
42 
43 int Msg::DoModal()
44 {
45 
46  return CDialog::DoModal();
47 }
48 
49 int Msg::msg(char *mss,int sec)
50 { // leider umstaendlich, aber sonst kommt ask nicht rueber!
51  strcpy(mSS,mss);
52  sek=sec;
53  return CDialog::DoModal();
54 }
55 
56 
57 
59 {
60  int r,t=0;
61  extern a99 *dlg;
62  extern int answ;
64 
65 // SetWindowText("..."); // keine Titelzeile!
66  m_msg.SetWindowText(mSS);
67  ShowWindow(SW_SHOW);
68  RedrawWindow();
69 // Jeweils nach 1 Sekunde Tastatuer pruefen
70  while(sek>=0)
71  {
72  _sleep(1000); sprintf(Aerror,"%s\r\n\r\n %d sec.",mSS,sek--); m_msg.SetWindowText(Aerror);
73  RedrawWindow(); // m_msg.RedrawWindow();
74  if(!(r=Peek())) { answ=IDYES; ++sek; break; }
75  if(r==-1) { answ=IDNO; ++sek; break; }
76  if(r!=1) { if(r!=t) { sek+=r; t=r; } else t=1; }
77  else t=1;
78  }
79  if(sek<0) answ=IDYES;
80  *Aerror=0;
81  OnCancel();
82  return sek;
83 }
84 
85 int Msg::Peek() // irgendeine Taste gedrückt? Enter, Esc, +, -
86 {
87  MSG msg; int k;
88  while(::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
89  {
90  ::TranslateMessage(&msg);
91  k=msg.wParam;
92  if(msg.message==WM_CHAR && k==13) return 0;
93  if(msg.message==WM_CHAR && k==27) return -1;
94  if(msg.message==WM_CHAR && (k==' ' || k=='+')) { ::GetMessage(&msg,NULL,0,0); return 11; }
95  if(msg.message==WM_CHAR && k=='-') { ::GetMessage(&msg,NULL,0,0); return -9; }
96  if(!AfxGetApp()->PumpMessage())
97  { ::PostQuitMessage(0);
98  return(0);
99  }
100  }
101  long l=0;
102  while(AfxGetApp()->OnIdle(l++));
103  return 1;
104 }
105 
106 void Msg::OnOK()
107 {
108  CDialog::OnOK();
109 }
110 
112 {
114 }
115 
116 
117 /*
118  Copyright 2011 Universitätsbibliothek Braunschweig
119 
120  Licensed under the Apache License, Version 2.0 (the "License");
121  you may not use this file except in compliance with the License.
122  You may obtain a copy of the License at
123 
124  http://www.apache.org/licenses/LICENSE-2.0
125 
126  Unless required by applicable law or agreed to in writing, software
127  distributed under the License is distributed on an "AS IS" BASIS,
128  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129  See the License for the specific language governing permissions and
130  limitations under the License.
131 */
132