all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
56
Task/Window-creation/Delphi/window-creation-1.delphi
Normal file
56
Task/Window-creation/Delphi/window-creation-1.delphi
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// The project file (Project1.dpr)
|
||||
program Project1;
|
||||
|
||||
uses
|
||||
Forms,
|
||||
// Include file with Window class declaration (see below)
|
||||
Unit0 in 'Unit1.pas' {Form1};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
||||
// The Window class declaration
|
||||
unit Unit1;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Forms;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm} // The window definition resource (see below)
|
||||
|
||||
end.
|
||||
|
||||
// A textual rendition of the Window (form) definition file (Unit1.dfm)
|
||||
object Form1: TForm1
|
||||
Left = 469
|
||||
Top = 142
|
||||
Width = 800
|
||||
Height = 600
|
||||
Caption = 'Form1'
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Shell Dlg 2'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poScreenCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
end
|
||||
63
Task/Window-creation/Delphi/window-creation-2.delphi
Normal file
63
Task/Window-creation/Delphi/window-creation-2.delphi
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
program Project3;
|
||||
|
||||
uses
|
||||
Windows,
|
||||
Messages;
|
||||
|
||||
var
|
||||
WndClass: TWndClass;
|
||||
Msg: TMsg;
|
||||
winT, winL: Integer;
|
||||
|
||||
// Initial height/width of the window
|
||||
const
|
||||
winW: Integer = 800;
|
||||
winH: Integer = 600;
|
||||
|
||||
// Callback function to processes messages sent to the window
|
||||
function WindowProc(hWnd,Msg,wParam,lParam:Integer): Integer; stdcall;
|
||||
begin
|
||||
// Trap the WM_DESTROY message
|
||||
if (Msg = WM_DESTROY) then PostQuitMessage(0);
|
||||
Result := DefWindowProc(hWnd,Msg,wParam,lParam);
|
||||
end;
|
||||
|
||||
begin
|
||||
// Fill the WndClass structure with the window class attributes
|
||||
// to be registered by the RegisterClass function
|
||||
with WndClass do
|
||||
begin
|
||||
lpszClassName:= 'Form1';
|
||||
lpfnWndProc := @WindowProc; // Pointer to our message handling callback
|
||||
style := CS_OWNDC or // Request a unique device context
|
||||
CS_VREDRAW or // Redraw window when resized vertically
|
||||
CS_HREDRAW; // Redraw window when resized horizontally
|
||||
hInstance := hInstance; // The instance that the window procedure of this class is within
|
||||
hbrBackground := HBRUSH(COLOR_BTNFACE+1); // Background colour of the window
|
||||
end;
|
||||
|
||||
// Register the window class for use by CreateWindow
|
||||
RegisterClass(WndClass);
|
||||
|
||||
// Calculate initial top and left positions of the window
|
||||
winT := (GetSystemMetrics(SM_CYFULLSCREEN) - winH) div 2;
|
||||
winL := (GetSystemMetrics(SM_CXFULLSCREEN) - winW) div 2;
|
||||
|
||||
// Create the window
|
||||
CreateWindow(WndClass.lpszClassName, // Class name
|
||||
'Form1', // Window name
|
||||
WS_OVERLAPPEDWINDOW or WS_VISIBLE, // Window style
|
||||
winL, // Horizontal Position (Left)
|
||||
winT, // Vertical Position (Top)
|
||||
winW, // Width
|
||||
winH, // Height
|
||||
0, // Window parent/owner handle
|
||||
0, // Menu handle
|
||||
hInstance, // Handle to application instance
|
||||
nil); // Pointer to window creation data
|
||||
|
||||
// Handle messages
|
||||
while GetMessage(Msg,0,0,0) do
|
||||
DispatchMessage(Msg);
|
||||
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue