Research Article

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

Algorithm 3

The source file main.cpp containing the entry point to the program: function WinMain.
  1.3#include<windows.h>
  2.3#include<iostream>
  3.3#include"resource.h"
  4.3#include"particle.h"
  5.3#include"field.h"
  6.3#include<CommCtrl.h>
  7.3#pragma comment(lib, "comctl32.lib")
  8.3using namespace  std;
  9.3
10.3HWND hModalDlg, hModelessDlg = 0;
11.3INT_PTR nResult;
12.3HANDLE hThread;
13.3bool  pause  =  true; // a control to make the pause in execution
14.3int  sleep = 0; //a control affecting the rate of running
15.3const double  my = 200./0.06, mz = my, kzy = 0.004;
16.3const int  height = 200, height2 = (int)(height*0.5),
17.3                 width=(int)(height*28./15.);
18.3const int  zLeft = 80, yTop = 70; //coordinates of the drawing area
19.3vector<Particle> vpp; //container keeping the set of particles
20.3int  particleModelessBox = -1;
21.3int  particleListBox = -1;
22.3char  bufListBox180;
23.3
24.3int  CALLBACK ModalDlgProc(HWND, UINT, WPARAM, LPARAM);
25.3int  CALLBACK ModelessDlgProc(HWND, UINT, WPARAM, LPARAM);
26.3DWORD CALLBACK ThreadProc(LPVOID);
27.3void  DrawEquipotentialLines(HDC, HFONT, LOGFONT, HPEN, Field*);
28.3
29.3int  WINAPI WinMain(HINSTANCE hI, HINSTANCE hI2, LPSTR p,  int  n)
30.3  MSG msg;
31.3  Particle::pF = new Field();
32.3  nResult = DialogBox(NULL, "MYDIALOG", 0, (DLGPROC)ModalDlgProc);
33.3  while(GetMessage(&msg, NULL, 0, 0) > 0)
34.3   if(hModelessDlg == 0 || !IsDialogMessage(hModelessDialog, &msg))
35.3   TranslateMessage(&msg);
36.3   DispatchMessage(&msg);
37.3   
38.3  
39.3  delete Particle::pF;
40.3  return  msg.wParam;
41.3