Недавно добавленные исходники

•  TDictionary Custom Sort  1 838

•  Fast Watermark Sources  1 870

•  3D Designer  3 289

•  Sik Screen Capture  2 293

•  Patch Maker  2 472

•  Айболит (remote control)  2 293

•  ListBox Drag & Drop  1 891

•  Доска для игры Реверси  69 543

•  Графические эффекты  2 492

•  Рисование по маске  2 026

•  Перетаскивание изображений  1 591

•  Canvas Drawing  1 589

•  Рисование Луны  1 606

•  Поворот изображения  1 224

•  Рисование стержней  1 276

•  Paint on Shape  907

•  Генератор кроссвордов  1 419

•  Головоломка Paletto  1 105

•  Теорема Монжа об окружностях  1 450

•  Пазл Numbrix  1 025

•  Заборы и коммивояжеры  1 301

•  Игра HIP  864

•  Игра Go (Го)  829

•  Симулятор лифта  961

•  Программа укладки плитки  803

•  Генератор лабиринта  963

•  Проверка числового ввода  863

•  HEX View  998

•  Физический маятник  867

•  Задача коммивояжера  918

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Сетка и отображаемый в память файл



unit MapGForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, SyncObjs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, Grids,
  ComCtrls;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure StringGrid1SelectCell(Sender: TObject; Col, Row: Integer;
      var CanSelect: Boolean);
  private
    hMapFile: THandle;
    MapFilePointer: Pointer;
  public
    procedure WmUser(var Msg: TMessage); message wm_user;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
  Address: Pointer;
begin
  hMapFile := CreateFileMapping(
    $FFFFFFFF, // file handle ... or memory
    nil, // security
    Page_ReadWrite, // access rights
    0, // high memory size
    10000, // low memory size
    'DdhMappedFileGraph'); // mapped file name
  if hMapFile <> 0 then
    MapFilePointer := MapViewOfFile(
      hMapFile, // handle returned above
      File_Map_All_Access, // access rights
      0, 0, 0) // access the entire mapped file
  else
    ShowMessage('hMapFile = 0');
  if MapFilePointer = nil then
    ShowMessage('MapFilePointer = nil')
  else
  begin
    // add window to area
    Address := pChar(MapFilePointer) + 400;
    while PInteger(Address)^ <> 0 do
      Address := pChar(Address) + 4;
    PInteger(Address)^ := Handle;
  end;
  // posts an update request to itself
  PostMessage(Handle, wm_user, 0, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnMapViewOfFile(MapFilePointer);
  CloseHandle(hMapFile);
end;

procedure TForm1.WmUser(var Msg: TMessage);
var
  X, Y: Integer;
  Address: Pointer;
begin
  // update the grid
  for X := 0 to 9 do
    for Y := 0 to 9 do
    begin
      Address := pChar(MapFilePointer)
        + (X + Y * 10) * 4;
      StringGrid1.Cells[X, Y] :=
        IntToStr(PInteger(Address)^);
    end;
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject;
  Col, Row: Integer; var CanSelect: Boolean);
var
  Address: Pointer;
begin
  // reset the cell to 0
  Address := pChar(MapFilePointer) + (Col + Row * 10) * 4;
  PInteger(Address)^ := 0;
  // notify all listeners
  Address := pChar(MapFilePointer) + 400;
  while PInteger(Address)^ <> 0 do
  begin
    PostMessage(PInteger(Address)^, wm_user, 0, 0);
    Address := pChar(Address) + 4;
  end;
end;

end.




Похожие по теме исходники

Чтение PSD файлов

Шифратор файлов

Разбиение файла на части

Поиск файлов

 

FileMan (менеджер файлов)

Поиск открытых файлов

Текст внутри файла




Copyright © 2004-2023 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте   Facebook   Ссылка на Twitter   Ссылка на Telegram