Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

goto, editor, ñàìîîáðàçîâàíèå, asm, logic, îïåðàòîð âåòâëåíèÿ, null, ýëåêòðîííûé ðåïåòèòîð, uses, computer, stack, îáðàçîâàíèå, public, ïåðåìåùåíèå ìèíèìàëüíîãî ýëåìåíòà
 

for valuable work you must have JavaScript (allow active content)

Pascal. Pc.4. Nest of tasks. Tasks on recognition. API Windows. Object Windows



Question for tasks of this nest.
Choose number of point suitable for given program. This is:

1. Copying text into clipboard
2. Window with running symbol
3. Timer
4. Window with menu
5. Program with menu and dialog box
6. Program drawing and clearing line, stroke of brush è text
7. Field for game tic-tac-toe 3*3

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.1     Answer


program MyProgram;
uses
    WinCrt, WinDos, Strings, WinProcs, WinTypes, WObjects;
type
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;
type
    txxwindow = object(twindow)
        procedure WMLButtonDown(var Msg: TMessage); virtual wm_First +
wm_LButtonDown;
    end;
PXXWindow = ^TXXWindow;

procedure TXXWindow.WMLButtonDown(var Msg: TMessage);
var
    Mem : THandle;
    PPP : Pointer;
begin
    OpenClipboard(HWindow);
    EmptyClipboard;
    Mem:=GlobalAlloc(gmem_Share,100);
    PPP:=GlobalLock(Mem);
    StrPCopy(PPP,’123456abcd12345’);
    SetClipboardData(cf_OEMText,Mem);
    GlobalUnlock(Mem);
    CloseClipboard;
end;
procedure TMyApplication.InitMainWindow;
begin
    MainWindow := New(PXXWindow, Init(nil, ‘Sample ObjectWindows Program’));
end;

var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘MyProgram’);
    MyApp.Run;
    MyApp.Done;
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.2     Answer


program MyProgram;
uses WObjects, WinProcs, WinTypes, Strings;
const
    id_MyTimer = 101;
type
    TMyWindow = object(TWindow)
        WWidth, HHeight : integer;
        WhereXX, WhereYY : integer;
        constructor Init(AParent: PWindowsObject; ATitle: PChar);
        procedure SetupWindow; virtual;
        procedure WMTimer(var Msg: TMessage); virtual wm_first + wm_Timer;
        procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
virtual;
        procedure WMSize(var Msg: TMessage); virtual wm_First + wm_Size;
    end;
    PMyWindow = ^TMyWindow;
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;

procedure TMyApplication.InitMainWindow;
begin
    MainWindow :=
    New(PMyWindow, Init(nil,’’));
end;

constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
var
    i, j : integer;
begin
    TWindow.Init(AParent,ATitle);
    WhereXX:=50;
    WhereYY:=50;
end;

procedure TMyWindow.SetupWindow;
var
    kkk: integer;
begin
    TWindow.SetupWindow;
    kkk:=SetTimer(HWindow,id_MyTimer,100,nil);
    if kkk = 0 then
        MessageBox(GetFocus,’Îøèáêà óñòàíîâêè òàéìåðà @@@’, ‘Îøèáêà
óñòàíîâêè òàéìåðà ###’,MB_OK);
end;
procedure TMyWindow.WMTimer(var Msg: TMessage);
begin
    WhereXX:=WhereXX+3;
    if WhereXX>400 then WhereXX:=40;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
begin
    TextOut(PaintDC,WhereXX,WhereYY,’*’,1);
end;

procedure TMyWindow.WMSize(var Msg: TMessage);
begin
    WWidth:=Msg.LParamLo;
    HHeight:=Msg.LParamHi;
    TWindow.WMSize(Msg);
end;
var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘’);
    MyApp.Run;
    MyApp.Done;
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.3     Answer


program MyProgram;
uses WObjects, WinProcs, WinTypes, Strings;
const
    id_MyTimer = 101;
type
    TMyWindow = object(TWindow)
        Second : integer;
        constructor Init(AParent: PWindowsObject; ATitle: PChar);
        procedure SetupWindow; virtual;
        procedure WMTimer(var Msg: TMessage); virtual wm_first + wm_Timer;
        procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
virtual;
    end;
    PMyWindow = ^TMyWindow;
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;
procedure TMyApplication.InitMainWindow;
begin
    MainWindow :=
    New(PMyWindow, Init(nil,’’));
end;
constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
begin
    TWindow.Init(AParent,ATitle);
    Second:=0;
end;

procedure TMyWindow.SetupWindow;
var
    kkk: integer;
begin
    TWindow.SetupWindow;
    kkk:=SetTimer(HWindow,id_MyTimer,1000,nil);
    if kkk = 0 then
        MessageBox(GetFocus,’Îøèáêà óñòàíîâêè òàéìåðà @@@’, ‘Îøèáêà
óñòàíîâêè òàéìåðà ###’,MB_OK);
end;
procedure TMyWindow.WMTimer(var Msg: TMessage);
begin
    Second:=Second+1;
    if Second=3600 then Second:=0;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
var
    ss : string[5];
    mm : array[0..9] of char;
    kk : integer;
begin
    str(Second,ss);kk:=length(ss);
    StrPCopy(mm,ss);
    TextOut(PaintDC,50,50,mm,kk);
end;
var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘’);
    MyApp.Run;
    MyApp.Done;
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.4     Answer


program MyProgram;
uses WObjects, WinProcs, WinTypes, Strings;
const
    cmAAAA1 = 101;
    cmAAAA2 = 102;
    cmBBBB1 = 103;

type
    TMyWindow = object(TWindow)
        constructor Init(AParent: PWindowsObject; ATitle: PChar);
    end;
    PMyWindow = ^TMyWindow;
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;

procedure TMyApplication.InitMainWindow;
begin
    MainWindow :=
    New(PMyWindow, Init(nil,’’));
end;
constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
var
    PP, Dest : array[0..99] of char;
    MM, AAAA, BBBB : HMenu;
begin
    TWindow.Init(AParent,ATitle);

    MM:=CreateMenu;
    AAAA:=CreatePopupMenu;
    BBBB:=CreatePopupMenu;

    StrPCopy(PP,’Ëèñà’);
    InsertMenu(AAAA,1,mf_Unchecked,cmAAAA1,PP);
    InsertMenu(AAAA,2,mf_Separator,0,PP);
    StrPCopy(PP,’Ìåäâåäü’);
    InsertMenu(AAAA,3,mf_Unchecked,cmAAAA2,PP);

    StrPCopy(PP,’Ñîâà’);
    InsertMenu(BBBB,1,mf_Unchecked,cmBBBB1,PP);

    StrPCopy(PP,’Çâåðè’);
    InsertMenu(MM,1,mf_Popup,AAAA,PP);
    StrPCopy(PP,’Ïòèöû’);
    InsertMenu(MM,1,mf_Popup,BBBB,PP);

    Attr.Menu:=MM;
end;

var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘’);
    MyApp.Run;
    MyApp.Done;
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.5     Answer


program MyProgram;
uses WObjects, WinProcs, WinTypes, Strings;
const
    cmAAAA1 = 101;
    cmAAAA2 = 102;
    cmBBBB1 = 103;

type
    TMyWindow = object(TWindow)
        constructor Init(AParent: PWindowsObject; ATitle: PChar);
        procedure Fox(Message : TMsg); virtual cm_First+cmAAAA1;
        procedure Bear(Message : TMsg); virtual cm_First+cmAAAA2;
        procedure Owl(Message : TMsg); virtual cm_First+cmBBBB1;
    end;
    PMyWindow = ^TMyWindow;
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;
procedure TMyApplication.InitMainWindow;
begin
    MainWindow :=
    New(PMyWindow, Init(nil,’’));
end;
constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
var
    PP, Dest : array[0..99] of char;
    MM, AAAA, BBBB : HMenu;
begin
    TWindow.Init(AParent,ATitle);

    MM:=CreateMenu;
    AAAA:=CreatePopupMenu;
    BBBB:=CreatePopupMenu;

    StrPCopy(PP,’Ëèñà’);
    InsertMenu(AAAA,1,mf_Unchecked,cmAAAA1,PP);
    InsertMenu(AAAA,2,mf_Separator,0,PP);
    StrPCopy(PP,’Ìåäâåäü’);
    InsertMenu(AAAA,3,mf_Unchecked,cmAAAA2,PP);

    StrPCopy(PP,’Ñîâà’);
    InsertMenu(BBBB,1,mf_Unchecked,cmBBBB1,PP);

    StrPCopy(PP,’Çâåðè’);
    InsertMenu(MM,1,mf_Popup,AAAA,PP);
    StrPCopy(PP,’Ïòèöû’);
    InsertMenu(MM,1,mf_Popup,BBBB,PP);

    Attr.Menu:=MM;
end;

procedure TMyWindow.Fox(Message : TMsg);
var
    P1, P2 : array[0..99] of char;
begin
    StrPCopy(P1,’Ëèñà’);
    StrPCopy(P2,’’);
    MessageBox(HWindow,P1,P2,mb_Ok)
end;

procedure TMyWindow.Bear(Message : TMsg);
var
    P1, P2 : array[0..99] of char;
begin
    StrPCopy(P1,’Ìåäâåäü’);
    StrPCopy(P2,’’);
    MessageBox(HWindow,P1,P2,mb_Ok)
end;

procedure TMyWindow.Owl(Message : TMsg);
var
    P1, P2 : array[0..99] of char;
begin
    StrPCopy(P1,’Ñîâà’);
    StrPCopy(P2,’’);
    MessageBox(HWindow,P1,P2,mb_Ok)
end;

var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘’);
    MyApp.Run;
    MyApp.Done;
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.6     Answer


program MyProgram;
uses WObjects, WinProcs, WinTypes, Strings;
const
    cmAAAA1 = 101;
    cmAAAA2 = 102;
    cmAAAA3 = 103;
    cmBBBB1 = 104;
    cmBBBB2 = 105;
    cmBBBB3 = 106;

type
    TMyWindow = object(TWindow)
        PrizLine : Boolean;    (* ïðèçíàê òîãî, ÷òî íàðèñîâàíà ëèíèÿ *)
        PrizBrush : Boolean;    (* ïðèçíàê òîãî, ÷òî íàðèñîâàíà êèñòü *)
        PrizWord : Boolean;    (* ïðèçíàê òîãî, ÷òî íàðèñîâàíî ñëîâî *)
        constructor Init(AParent: PWindowsObject; ATitle: PChar);
        procedure DrawLine(var Msg: TMessage); virtual cm_First + cmAAAA1;
        procedure DrawBrush(var Msg: TMessage); virtual cm_First +
cmAAAA2;
        procedure DrawWord(var Msg: TMessage); virtual cm_First + cmAAAA3;
        procedure ClearLine(var Msg: TMessage); virtual cm_First +
cmBBBB1;
        procedure ClearBrush(var Msg: TMessage); virtual cm_First +
cmBBBB2;
        procedure ClearWord(var Msg: TMessage); virtual cm_First +
cmBBBB3;
        procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
virtual;
    end;
    PMyWindow = ^TMyWindow;
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;
procedure TMyApplication.InitMainWindow;
var
    PP, Dest : array[0..99] of char;
    MM, AAAA, BBBB : HMenu;
begin
    MainWindow :=
    New(PMyWindow, Init(nil,’’));
    MM:=CreateMenu;
    AAAA:=CreatePopupMenu;
    BBBB:=CreatePopupMenu;

    StrPCopy(PP,’Line’);
    InsertMenu(AAAA,1,mf_Unchecked,cmAAAA1,PP);
    StrPCopy(PP,’Brush’);
    InsertMenu(AAAA,2,mf_Unchecked,cmAAAA2,PP);
    StrPCopy(PP,’Word’);
    InsertMenu(AAAA,3,mf_Unchecked,cmAAAA3,PP);

    StrPCopy(PP,’Line’);
    InsertMenu(BBBB,1,mf_Unchecked,cmBBBB1,PP);
    StrPCopy(PP,’Brush’);
    InsertMenu(BBBB,2,mf_Unchecked,cmBBBB2,PP);
    StrPCopy(PP,’Word’);
    InsertMenu(BBBB,3,mf_Unchecked,cmBBBB3,PP);


    StrPCopy(PP,’Draw’);
    InsertMenu(MM,1,mf_Popup,AAAA,PP);
    StrPCopy(PP,’Clear’);
    InsertMenu(MM,1,mf_Popup,BBBB,PP);

    PMyWindow(MainWindow)^.Attr.Menu:=MM;
end;

constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
begin
    TWindow.Init(AParent,ATitle);
    PrizLine:=false;
    PrizBrush:=false;
    PrizWord:=false;
end;

procedure TMyWindow.DrawLine(var Msg: TMessage);
begin
    PrizLine:=true;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.DrawBrush(var Msg: TMessage);
begin
    PrizBrush:=true;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.DrawWord(var Msg: TMessage);
begin
    PrizWord:=true;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.ClearLine(var Msg: TMessage);
begin
    PrizLine:=false;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.ClearBrush(var Msg: TMessage);
begin
    PrizBrush:=false;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.ClearWord(var Msg: TMessage);
begin
    PrizWord:=false;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
var
    PenSize : integer;
    PenColor : TColorRef;
    ThePen : HPen;
    TheBrush : HBrush;
    TheFont : HFont;
    MyLogFont : TLogFont;
    MyLogBrush : TLogBrush;
    MyRegion : HRgn;
begin
    if PrizLine then begin
        PenSize := 1;
        PenColor:= RGB(0,255,0);
        ThePen := CreatePen(ps_Solid, PenSize, PenColor);
        SelectObject(PaintDC, ThePen);
        MoveTo(PaintDC, 20, 20);
        LineTo(PaintDC, 100,40);
    end
    else begin
        PenSize := 1;
        PenColor:= RGB(255,255,255);
        ThePen := CreatePen(ps_Solid, PenSize, PenColor);
        SelectObject(PaintDC, ThePen);
        MoveTo(PaintDC, 20, 20);
        LineTo(PaintDC, 100,40);
    end;
    DeleteObject(ThePen);
    MyRegion:=CreateRectRgn(150,150,250,250);
    MyLogBrush.lbStyle:=bs_Solid;
    MyLogBrush.lbHatch:=0;
    if PrizBrush then begin
        MyLogBrush.lbColor:=RGB(255,0,0);
        TheBrush:=CreateBrushIndirect(MyLogBrush);
        SelectObject(PaintDC, TheBrush);
        FillRgn(PaintDC,MyRegion,TheBrush);
    end
    else begin
        MyLogBrush.lbColor:=RGB(255,255,255);
        TheBrush:=CreateBrushIndirect(MyLogBrush);
        SelectObject(PaintDC, TheBrush);
        FillRgn(PaintDC,MyRegion,TheBrush);
    end;
    DeleteObject(TheBrush);
    MyLogFont.lfHeight:=16;
    MyLogFont.lfWidth:=16;
    MyLogFont.lfEscapement:=0;
    MyLogFont.lfOrientation:=0;
    MyLogFont.lfWeight:=fw_Medium;
    MyLogFont.lfItalic:=0;
    MyLogFont.lfUnderline:=0;
    MyLogFont.lfStrikeOut:=0;
    MyLogFont.lfCharSet:=ANSI_CharSet;
    MyLogFont.lfOutPrecision:=Out_Character_Precis;
    MyLogFont.lfClipPrecision:=Clip_Default_Precis;
    MyLogFont.lfQuality:=Proof_Quality;
    MyLogFont.lfPitchAndFamily:=Variable_Pitch or ff_Swiss;
    StrCopy(@MyLogFont.lfFaceName,’Courier’);

    TheFont:=CreateFontInDirect(MyLogFont);
    SelectObject(PaintDC,TheFont);

    if PrizWord then begin
        SetTextColor(PaintDC,RGB(0,0,0));
        TextOut(PaintDC,60,60,’Word’,4);
    end
    else begin
        SetTextColor(PaintDC,RGB(255,255,255));
        TextOut(PaintDC,60,60,’Word’,4);
    end;
    DeleteObject(TheFont);
end;
var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘’);
    MyApp.Run;
    MyApp.Done;
end.

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

Pc.4.7     Answer


program MyProgram;
uses WObjects, WinProcs, WinTypes, Strings, WinCrt;
const
    cmAAAA1 = 101;
    cmAAAA2 = 102;
    cmAAAA3 = 103;
    cmBBBB1 = 104;
    cmBBBB2 = 105;
    cmBBBB3 = 106;

type
    Arr = array[1..3] of array[1..3] of (none,circle,cross);
    TMyWindow = object(TWindow)
        Ar : Arr;
        HHeight, WWidth : Word;
        XXX, YYY : array[1..3] of boolean;
        First, Second : boolean;
        constructor Init(AParent: PWindowsObject; ATitle: PChar);
        procedure WMLButtonDown(var Msg: TMessage); virtual wm_First +
wm_LButtonDown;
        procedure WMRButtonDown(var Msg: TMessage); virtual wm_First +
wm_RButtonDown;
        procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
virtual;
        procedure WMSize(var Msg: TMessage); virtual wm_First + wm_Size;
    end;
    PMyWindow = ^TMyWindow;
    TMyApplication = object(TApplication)
        procedure InitMainWindow; virtual;
    end;

procedure TMyApplication.InitMainWindow;
begin
    MainWindow :=
    New(PMyWindow, Init(nil,’’));
end;

constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar);
var
    i, j : integer;
begin
    TWindow.Init(AParent,ATitle);
    for i:=1 to 3 do
        for j:=1 to 3 do Ar[i][j]:=none;
    for i:=1 to 3 do XXX[i]:=false;
    for i:=1 to 3 do YYY[i]:=false;
    First:=false;
    Second:=false;
end;
procedure TMyWindow.WMLButtonDown(var Msg: TMessage);
var
    i, j, n : integer;
begin
    for i:=1 to 3 do
        for j:=1 to 3 do
            if ((WWidth div 3)*(i-1) (Msg.LParamLo<(WWidth div 3)*i) and ((HHeight div 3)*(j-1) (Msg.LParamHi<(HHeight div 3)*j) then begin
                Ar[i][j]:=cross;
                if i=j then First:=(Ar[1][1]=cross) and
(Ar[2][2]=cross) and (Ar[3][3]=cross);
                if 4-i=j then Second:=(Ar[3][1]=cross) and
(Ar[2][2]=cross) and (Ar[1][3]=cross);
                XXX[j]:=true;
                for n:=1 to 3 do
                    XXX[j]:=XXX[j] and (Ar[n][j]=cross);
                YYY[i]:=true;
                for n:=1 to 3 do
                    YYY[i]:=YYY[i] and (Ar[i][n]=cross);
            end;
    InvalidateRect(HWindow, nil, True);
end;
procedure TMyWindow.WMRButtonDown(var Msg: TMessage);
var
    i, j, n : integer;
begin
    for i:=1 to 3 do
        for j:=1 to 3 do
            if ((WWidth div 3)*(i-1) (Msg.LParamLo<(WWidth div 3)*i) and ((HHeight div 3)*(j-1) (Msg.LParamHi<(HHeight div 3)*j) then begin
                Ar[i][j]:=circle;
                if i=j then First:=(Ar[1][1]=circle) and
(Ar[2][2]=circle) and (Ar[3][3]=circle);
                if 4-i=j then Second:=(Ar[3][1]=circle) and
(Ar[2][2]=circle) and (Ar[1][3]=circle);
                XXX[j]:=true;
                for n:=1 to 3 do
                    XXX[j]:=XXX[j] and (Ar[n][j]=circle);
                YYY[i]:=true;
                for n:=1 to 3 do
                    YYY[i]:=YYY[i] and (Ar[i][n]=circle);
            end;
    InvalidateRect(HWindow, nil, True);
end;

procedure TMyWindow.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
var
    PenSize : integer;
    PenColor : TColorRef;
    ThePen : HPen;
    i, j, n : integer;
procedure XXCircle(x,y : integer);
begin
    PenSize := 7;
    PenColor:= RGB(0,0,255);
    ThePen := CreatePen(ps_Solid, PenSize, PenColor);
    SelectObject(PaintDC, ThePen);
    Ellipse(PaintDC,(WWidth div 3)*(x-1), (HHeight div 3)*(y-1), (WWidth div
3)*x, (HHeight div 3)*y);
    DeleteObject(ThePen);
end;
procedure XXCross(x,y : integer);
begin
    PenSize := 7;
    PenColor:= RGB(255,0,0);
    ThePen := CreatePen(ps_Solid, PenSize, PenColor);
    SelectObject(PaintDC, ThePen);
    MoveTo(PaintDC, (WWidth div 3)*(x-1), (HHeight div 3)*(y-1));
    LineTo(PaintDC, (WWidth div 3)*x, (HHeight div 3)*y);
    MoveTo(PaintDC, (WWidth div 3)*(x), (HHeight div 3)*(y-1));
    LineTo(PaintDC, (WWidth div 3)*(x-1), (HHeight div 3)*y);
    DeleteObject(ThePen);
end;
begin
    PenSize := 3;
    PenColor:= RGB(0,255,0);
    ThePen := CreatePen(ps_Solid, PenSize, PenColor);
    SelectObject(PaintDC, ThePen);
    MoveTo(PaintDC, WWidth div 3, 0);
    LineTo(PaintDC, WWidth div 3, HHeight);
    MoveTo(PaintDC, 2*(WWidth div 3), 0);
    LineTo(PaintDC, 2*(WWidth div 3), HHeight);
    MoveTo(PaintDC, 0, HHeight div 3);
    LineTo(PaintDC, WWidth, HHeight div 3);
    MoveTo(PaintDC, 0, 2*(HHeight div 3));
    LineTo(PaintDC, WWidth, 2*(HHeight div 3));
    DeleteObject(ThePen);
    for i:=1 to 3 do
        for j:=1 to 3 do
            if Ar[i][j]=circle then XXCircle(i,j)
            else
                If Ar[i][j]=cross then XXCross(i,j);
    PenSize := 15;
    PenColor:= RGB(0,100,100);
    ThePen := CreatePen(ps_Solid, PenSize, PenColor);
    SelectObject(PaintDC, ThePen);
    if First then begin
        MoveTo(PaintDC, 0, 0);
        LineTo(PaintDC, WWidth, HHeight);
    end;
    if Second then begin
        MoveTo(PaintDC, WWidth,0);
        LineTo(PaintDC, 0, HHeight);
    end;
    for n:=1 to 3 do begin
        if XXX[n] then begin
            MoveTo(PaintDC, 0, (n-1)*(HHeight div 3)+(HHeight div 6));
            LineTo(PaintDC, WWidth, (n-1)*(HHeight div 3)+(HHeight div
6));
        end;
        if YYY[n] then begin
            MoveTo(PaintDC, (n-1)*(WWidth div 3)+(WWidth div 6), 0);
            LineTo(PaintDC, (n-1)*(WWidth div 3)+(WWidth div 6),
HHeight);
        end;
    end;
end;

procedure TMyWindow.WMSize(var Msg: TMessage);
begin
    WWidth:=Msg.LParamLo;
    HHeight:=Msg.LParamHi;
    TWindow.WMSize(Msg);
end;
var
    MyApp: TMyApplication;
begin
    MyApp.Init(‘’);
    MyApp.Run;
    MyApp.Done;
end.

 

©   Aliaksandr Prykhodzka    1993 - 2007