⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 这是一个非常好的教师和学生沟通用的电子教室!
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    except
    end;
  end;

  inherited;
end;


procedure TForm1.GetHotSpot(var HotSpot: TPoint); //截取鼠标坐标
var
  pIconInfo: _iconinfo;
begin
  GetIconInfo(GetCursor(), pIconInfo);
  HotSpot.x := pIconInfo.xHotspot;
  HotSpot.y := pIconInfo.yHotspot;
end;

procedure TForm1.GetCursorIcon(var Cursor: TIcon); //截取鼠标图象
var
  hld: hwnd;
  Threadld: dword;
  mp: tpoint;
begin
  getcursorpos(mp);
  hld := WindowFromPoint(mp);
  Threadld := GetWindowThreadProcessId(hld, nil);
  AttachThreadInput(GetCurrentThreadId, Threadld, True);
  Cursor.Handle := Getcursor();
  AttachThreadInput(GetCurrentThreadId, threadld, False);
end;

procedure TForm1.GetScreen(var bmp1: TBitmap; screenx: integer; screeny: integer; screenr: integer; screenb: integer);
var
  dc: integer;
  c: TCanvas;
  R, R1: TRect;
begin
  bmp1 := TBitmap.Create;

  dc := GetWindowDC(0);
  try
    c := TCanvas.Create;
    c.Handle := dc;
    R := Rect(screenx, screeny, Screenr, Screenb);
    bmp1.Width := R.Right - R.Left; ;
    bmp1.Height := R.Bottom - R.Top;
    R1 := Rect(0, 0, bmp1.Width, bmp1.Height);
    bmp1.Canvas.CopyRect(R1, c, R);
    c.Handle := 0;
    c.Free;
  finally
    ReleaseDC(0, dc);
  end;
end;


procedure TForm1.FormActivate(Sender: TObject);
//var
 /// v_wsh1, v_wsh2, wsh_caption: string;
 /// i: integer;
 /// wsh_char: array[0..50] of char;
begin
  if wsh_first <> true then exit;
  wsh_first := false;
  if closeflag = true then close;
  //LMDTrayIcon1.Active := true;

     //听登陆消息,0是固定IP
  if guding_ip = '0' then
  begin
    N13Click(sender);
    sleep(500);
  end;

 if auto_login='1' then
  begin
  n48.Checked:=true;
  if LWSocket.State <> wsclosed then LWSocket.close;
  LWSocket.Proto := 'udp';
  LWSocket.Addr := '0.0.0.0';
  LWSocket.MultiCast := true;
  LWSocket.ReuseAddr := true;
  LWSocket.Port := '1525';
  LWSocket.MultiCastAddrStr := '225.1.2.8'; // or whatever
  LWSocket.Listen;
  end;

end;

procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  accept := source is TListView;
end;

procedure TForm1.FormShow(Sender: TObject);
var
  inifile: Tinifile;
  inifilename: string;
  i: smallint;
  ///defaultstr, s_password: string;
 /// okflag: boolean;
begin
  //读取学生文件
  inifilename := ExtractFilePath(Application.EXEName) + 'teacher.ini';
  inifile := Tinifile.create(inifilename);
  school_name := inifile.ReadString('CLASS', 'School_name', '网络教室');
  Teacher_name := inifile.ReadString('CLASS', 'Teacher_name', '');
  Class_name := inifile.ReadString('CLASS', 'Class_name', '一班');
  Course_name := inifile.ReadString('CLASS', 'Course_name', '计算机应用基础');
  student_time := inifile.ReadInteger('CLASS', 'StudentTime', 2);
  l_key:=inifile.ReadString ('class','key','');
  guding_ip := inifile.Readstring('CLASS', 'IP', '0');
  auto_login:= inifile.Readstring('CLASS', 'autologin', '0');

  panel1.Caption := school_name;
  panel2.Caption := Teacher_name;
  Panel3.Caption := Class_name;
  Panel4.Caption := Course_name;
  rxlabel1.Width:=449;
  rxlabel1.Caption:=school_name+' 班级: '+class_name+' 授课教师: '+teacher_name+' 课程: '+course_name;


  student_count := inifile.ReadInteger('CLASS', 'student_count', -1);
  s_repeattime := inifile.ReadInteger('CLASS', 'RepeatTime', 5);
  l_lie := inifile.ReadInteger('ClASS', 'Llie', 7);
  l_kuan := inifile.ReadInteger('ClASS', 'Lkuan', 68);
  l_jian1 := inifile.ReadInteger('ClASS', 'Ljian1', 12);
  l_jian2 := inifile.ReadInteger('ClASS', 'Ljian2', 10);

  if l_key =reg.CalculateCode(school_name) then
    begin
     label5.Caption :='';
    end
    else
    begin
     label5.Caption :='1.0 未注册';
     student_count :=10;
    end;

  if school_name ='' then
    begin
     label5.Caption :='1.0 未注册';
     student_count :=10;
    end;

  if student_count > 75 then
  begin
    showmessage('学生数不能超过75!');
    close;
  end;

  if (student_count = -1) or (student_count > 75) then
  begin
    inifile.Free;
    showmessage('读学生文件发生错误!请关闭程序!');
    exit;
  end;
  for i := 0 to student_count - 1 do
  begin
    computer_name[i] := inifile.ReadString('STUDENT', 'computer' + inttostr(i + 1), 'computer' + inttostr(i + 1));
    computer_ip[i] := inifile.ReadString('STUDENT', 'IP' + inttostr(i + 1), '');
    student_name[i] := inifile.ReadString('STUDENT', 'student' + inttostr(i + 1), '学生' + inttostr(i + 1));
    student_memo[i] := inifile.ReadString('STUDENT', 'memo' + inttostr(i + 1), '备注' + inttostr(i + 1));
  end;
  inifile.Free;

  //产生计算机图标
  ListView1.Items.Clear;
  for i := 0 to student_count - 1 do
  begin
    with ListView1.Items.Add do
    begin
      caption := student_name[i];
      ImageIndex := 0;
    end;
  end;
  N9Click(sender);
  n13click(sender);
   about.ShowModal;
   if about.Label2.Caption = '127.0.0.1' then
    showmessage('请查看教师机网卡是否已接通,或着未设置IP地址.');
end;

procedure TForm1.FormCreate(Sender: TObject);
var
 /// regallfile: file of integer; //完全注册用
  ///i, cool, geshu: integer;
  ///w_char: array[0..100] of char;
  nNameSize: Cardinal;
  chName: array[0..MAX_COMPUTERNAME_LENGTH] of char;
begin
  xieyi := 0;
  image_index := 0;
  wsh_first := true;
  draw_ok := true;
  zhuce := true;
  zhuceall := true;
  LongTimeFormat := 'hh:mm:ss';
//  timer1.Enabled := true;

  //得到计算机名称
  s_computername := '';
  nNameSize := MAX_COMPUTERNAME_LENGTH + 1;
  FillMemory(@chName, nNameSize, $00);
  GetComputerName(chName, nNameSize);
  s_computername := chName;

  panel1.Caption := '';
  panel2.Caption := '';
  panel3.Caption := '';
  panel4.Caption := '';
  wsh_socket[0] := WSocket1;
  wsh_socket[1] := WSocket2;
  wsh_socket[2] := WSocket3;
  wsh_socket[3] := WSocket4;
  wsh_socket[4] := WSocket5;
  wsh_socket[5] := WSocket6;
  wsh_socket[6] := WSocket7;
  wsh_socket[7] := WSocket8;
  wsh_socket[8] := WSocket9;
  wsh_socket[9] := WSocket10;
  wsh_socket[10] := WSocket11;
  wsh_socket[11] := WSocket12;
  wsh_socket[12] := WSocket13;
  wsh_socket[13] := WSocket14;
  wsh_socket[14] := WSocket15;
  wsh_socket[15] := WSocket16;
  wsh_socket[16] := WSocket17;
  wsh_socket[17] := WSocket18;
  wsh_socket[18] := WSocket19;
  wsh_socket[19] := WSocket20;
  wsh_socket[20] := WSocket21;
  wsh_socket[21] := WSocket22;
  wsh_socket[22] := WSocket23;
  wsh_socket[23] := WSocket24;
  wsh_socket[24] := WSocket25;
  wsh_socket[25] := WSocket26;
  wsh_socket[26] := WSocket27;
  wsh_socket[27] := WSocket28;
  wsh_socket[28] := WSocket29;
  wsh_socket[29] := WSocket30;
  wsh_socket[30] := WSocket31;
  wsh_socket[31] := WSocket32;
  wsh_socket[32] := WSocket33;
  wsh_socket[33] := WSocket34;
  wsh_socket[34] := WSocket35;
  wsh_socket[35] := WSocket36;
  wsh_socket[36] := WSocket37;
  wsh_socket[37] := WSocket38;
  wsh_socket[38] := WSocket39;
  wsh_socket[39] := WSocket40;
  wsh_socket[40] := WSocket41;
  wsh_socket[41] := WSocket42;
  wsh_socket[42] := WSocket43;
  wsh_socket[43] := WSocket44;
  wsh_socket[44] := WSocket45;
  wsh_socket[45] := WSocket46;
  wsh_socket[46] := WSocket47;
  wsh_socket[47] := WSocket48;
  wsh_socket[48] := WSocket49;
  wsh_socket[49] := WSocket50;
  wsh_socket[50] := WSocket51;
  wsh_socket[51] := WSocket52;
  wsh_socket[52] := WSocket53;
  wsh_socket[53] := WSocket54;
  wsh_socket[54] := WSocket55;
  wsh_socket[55] := WSocket56;
  wsh_socket[56] := WSocket57;
  wsh_socket[57] := WSocket58;
  wsh_socket[58] := WSocket59;
  wsh_socket[59] := WSocket60;
  wsh_socket[60] := WSocket61;
  wsh_socket[61] := WSocket62;
  wsh_socket[62] := WSocket63;
  wsh_socket[63] := WSocket64;
  wsh_socket[64] := WSocket65;
  wsh_socket[65] := WSocket66;
  wsh_socket[66] := WSocket67;
  wsh_socket[67] := WSocket68;
  wsh_socket[68] := WSocket69;
  wsh_socket[69] := WSocket70;
  wsh_socket[70] := WSocket71;
  wsh_socket[71] := WSocket72;
  wsh_socket[72] := WSocket73;
  wsh_socket[73] := WSocket74;
  wsh_socket[74] := WSocket75;
end;

procedure TForm1.N1Click(Sender: TObject);
begin
  Wsockethook.Close;
   //  打开自己的UDP协议,发送数据
  WSockethook.Proto := 'udp';
  WSockethook.Addr := '255.255.255.255';
  WSockethook.Port := '999';
  WSockethook.LocalPort := '7516';
  WSockethook.Connect;
  wsockethook.SendStr('紧急照会');
  Wsockethook.Close;
end;

procedure TForm1.WSocket1SessionClosed(Sender: TObject; Error: Word);
var
  i: smallint;
begin
  TWsocket(sender).tag := 1976;
  for i := 0 to student_count - 1 do
  begin
    if wsh_socket[i].Tag = 1976 then
    begin
      wsh_socket[i].Tag := 0;
      Listview1.Items[i].imageindex := 0;
    end;
  end;
end;

procedure TForm1.N8Click(Sender: TObject);
begin
  ListView1.arrange(arSnapToGrid);
end;

procedure TForm1.N4Click(Sender: TObject);
begin
  ListView1.arrange(arAlignBottom);
end;

procedure TForm1.N5Click(Sender: TObject);
begin
  ListView1.arrange(arAlignLeft);
end;

procedure TForm1.N6Click(Sender: TObject);
begin
  ListView1.arrange(arAlignRight);
end;

procedure TForm1.N7Click(Sender: TObject);
begin
  ListView1.arrange(arAlignTop);
end;

procedure TForm1.N9Click(Sender: TObject);
var
  i, j, k: smallint;
  ok: boolean;
begin
  j := 0;
  k := 0;
  ok := false;
  while ok = false do
  begin
    if screen.Width = 640 then
    begin
      for i := 0 to 7 do
      begin
        Listview1.Items[j].Left := 62 * i + 12;
        LIstview1.Items[j].top := k;
        j := j + 1;
        if j = student_count then
        begin
          ok := true;
          break;
        end;
      end;
      k := k + 50;
    end
    else
    begin
      for i := 0 to l_lie - 1 do
      begin
        Listview1.Items[j].Left := l_kuan * i + l_jian1;
        LIstview1.Items[j].top := k + l_jian2;
        j := j + 1;
        if j = student_count then
        begin
          ok := true;
          break;
        end;
      end;
      k := k + 60;
    end;
  end;
end;

procedure TForm1.N11Click(Sender: TObject);
begin
  ListView1DblClick(sender);
end;

procedure TForm1.ListView1DblClick(Sender: TObject);
var
  Sxinxif: TSxinxif;
  i: smallint;
begin
  if ListView1.SelCount = 1 then
    for i := 0 to student_count - 1 do
      if listView1.Items[i].Selected = true then
      begin
        s_selected := i;
        Sxinxif := TSxinxif.create(self);
        Sxinxif.edit1.text := inttostr(i + 1);
        Sxinxif.edit2.text := computer_name[i];
        Sxinxif.edit3.text := Listview1.Selected.Caption;
        Sxinxif.edit4.text := computer_ip[i];
        Sxinxif.memo1.lines.add(student_memo[i]);

        Sxinxif.showmodal;
        if w_shuaxing = true then
          N13click(sender); //刷新速度太慢
      end;

end;

procedure TForm1.WSocket1SessionConnected(Sender: TObject; Error: Word);
var
  i: smallint;
  sendstate: string;
begin
  TWsocket(sender).tag := 1977;
  for i := 0 to student_count - 1 do
  begin
   //  showmessage(inttostr(wsh_socket[i].Tag));
    if wsh_socket[i].Tag = 1977 then
    begin
      wsh_socket[i].Tag := 0;
      Listview1.Items[i].imageindex := 1;
    //  ListView1.Refresh;

      if (pingmu_state = '屏幕广播') and (listView1.Items[i].Selected = true) then
      begin
        PingmuTImer.Enabled := false;
          //发送屏幕广播消息
        wsh_socket[i].SendStr('/*csh*/:' + #13 + #10 + '屏幕广播');
        sleep(100);

        sendstate := '开始屏幕';
        if not draw_mouse then // 判断是否发送鼠标状态
          sendstate := sendstate + 'nomouse';
        if xieyi = 0 then //判断是否TCP协议
          sendstate := sendstate + 'tcp'
        else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -