Research Article

Development of the Object-Oriented Dynamic Simulation Models Using Visual C++ Freeware

Algorithm 5

Modal dialog box: function ModalDlgProc (part 1).
  1.5int  CALLBACK ModalDlgProc(HWND hwnd, UINT message,
  2.5             WPARAM wParam, LPARAM lParam)
  3.5static  HDC hDC;
  4.5PAINTSTRUCT psPaint;
  5.5RECT rect;
  6.5static  HBRUSH hBlackBrush=(HBRUSH)GetStockObject(BLACK_BRUSH),
  7.5g_hbrBackground = CreateSolidBrush(RGB(255, 255, 255));
  8.5static  HPEN hBlackPen = (HPEN)GetStockObject(BLACK_PEN),
  9.5hBlackThickPen = CreatePen(PS_SOLID, 5, RGB(0,0,0)),
10.5hWhitePen = CreatePen(PS_SOLID,  (int)0.5, RGB(255, 255, 255)),
11.5hGreyPen = CreatePen(PS_SOLID,  (int)0.5, RGB(200, 200, 200)),
12.5hPinkPen = CreatePen(PS_SOLID,  (int)0.5, RGB(255, 150, 150)),
13.5hBluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
14.5static  HFONT fontPotential, fontCaption;
15.5static  LOGFONT lf, lf2;
16.5strcpy_s(lf.lfFaceName, "MS Sans Serif");
17.5lf.lfHeight = 8;
18.5strcpy_s(lf2.lfFaceName, "Century");
19.5lf2.lfHeight = 18;
20.5lf2.lfWeight = FW_MEDIUM;
21.5char  caption = "A simulation model of the motion of charged
22.5particles in the electrostatic field of an immersion lens";
23.5char  bufferLB3, buffer500;
24.5Particle temp;
25.5switch(message)
26.5case  WM_INITDIALOG:
27.5   hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)
28.5            &ThreadProc, NULL, CREATE_SUSPENDED, 0);
29.5   if(hThread == NULL)
30.5  MessageBox(0,"Error Creating Thread","Message",MB_OK);
31.5   return  1;
32.5  
33.5   hModalDlg = hwnd;
34.5   hModelessDlg = CreateDialog(0, "MODELESS_DIALOG", 0,
35.5                   (DLGPROC)ModelessDlgProc);
36.5   SendMessage(GetDlgItem(hwnd, IDC_UpDown), UDM_SETBUDDY,
37.5   (WPARAM)GetDlgItem(hwnd,IDC_EDIT_ParticleModelessBox), 0);
38.5   SendMessage(GetDlgItem(hwnd,IDC_UpDown),
39.5                      UDM_SETRANGE, 0, 100);
40.5   SendMessage(GetDlgItem(hwnd, IDC_UpDown),UDM_SETPOS,0, 0);
41.5   int  pLB;
42.5   sprintf_s(buffer, "%.2f", temp.W0);
43.5   SetDlgItemText(hwnd, IDC_EDIT_W0, buffer);
44.5   sprintf_s(buffer, "%.2f", temp.kVy);
45.5   SetDlgItemText(hwnd, IDC_EDIT_kVy, buffer);
46.5   sprintf_s(buffer, "%d", 0);
47.5   SetDlgItemText(hwnd, IDC_EDIT_PartNum, buffer);
48.5   SendMessage(GetDlgItem(hwnd, IDC_Trackbar), TBM_SETRANGE,
49.5                    TRUE, MAKELONG(0, 1000));
50.5   SendMessage(GetDlgItem(hwnd, IDC_Trackbar), TBM_SETPOS,
51.5                           TRUE, 200);
52.5   sleep = SendMessage(GetDlgItem(hwnd, IDC_Trackbar),
53.5                        TBM_GETPOS, 0, 0);
54.5   sprintf_s(buffer, "%d", sleep);
55.5   SetDlgItemText(hwnd, IDC_EDIT_Sleep, buffer);
56.5   break;