الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أكواد للفورم

مغلق
بدأه حسين طي في 7 سبتمبر 2007 · 7 رد · 936 مشاهدة · في لغة Delphi
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

هذه مجموعة من الأكواد التي عثرت عليها وأحببت مشاركتكم بها

هذا كود لإنشاء فورم بزوايا مستديرة

procedure TForm1.FormCreate(Sender: TObject);
var
  rgn: HRGN;
begin
  Form1.Borderstyle := bsNone;
  rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
	0,			// y-coordinate of the region's upper-left corner
	ClientWidth,  // x-coordinate of the region's lower-right corner
	ClientHeight, // y-coordinate of the region's lower-right corner
	40,		   // height of ellipse for rounded corners
	40);		  // width of ellipse for rounded corners
  SetWindowRgn(Handle, rgn, True);
end;

وهذا كود لعمل فتحة مضلعة في الفورم

type
  PtsType = array [0..15, 0..1] of Integer;</P> 
const
  Pts: PtsType = ((0, 0), (800, 0), (800, 600),
	(200, 600), (200, 220), (300, 280),
	(265, 205), (350, 117), (205, 170),
	(120, 90), (130, 200), (60, 350), (200, 220),
	(200, 600), (0, 600), (0, 0));</P> 

procedure TForm1.Button1Click(Sender: TObject);
var
  HRegion1: THandle;
begin
  HRegion1 := CreatePolygonRgn(Pts, SizeOf(Pts) div 8, alternate);
  SetWindowRgn(Handle, HRegion1, True);
end;

وهذا كود لتلوين الخلفية في تطبيق MDI

private
	{ Private declarations }
	 FClientInstance: TFarProc;
	FPrevClientProc: TFarProc;
	BkBrush: HBRUSH;
	procedure ClientWndProc(var Message: TMessage);</P> 
  public
	{ Public declarations }
	  constructor Create(AOwner: TComponent); override;
	destructor Destroy; override;

ثم 
constructor TForm1.Create(AOwner: TComponent);
begin
  inherited;
  BkBrush := CreateSolidBrush(clblue);
  FClientInstance := Classes.MakeObjectInstance(ClientWndProc);
  FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
  SetWindowLong(ClientHandle, GWL_WNDPROC, Longint(FClientInstance));
end;</P> 
destructor TForm1.Destroy;
begin
  DeleteObject(BkBrush);
  inherited;
end;</P> 
procedure TForm1.ClientWndProc(var Message: TMessage);
var
  DC: HDC;
  BrushOld: HBRUSH;
begin
  with Message do 
  begin
	case Msg of
	  WM_ERASEBKGND:
		begin
		  DC := TWMEraseBkGnd(Message).DC;
		  BrushOld := SelectObject(DC, BkBrush);
		  FillRect(DC, ClientRect, BkBrush);
		  SelectObject(DC, BrushOld);
		  Result := 1;
		end;
	  else
		Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
	end;
  end;
end;

وهذا كود لعد مكونات من صنف واحد على الفورم

Function EditCount : Integer;
var
I , Y : Integer;
begin
Y := 0;
for I := 0 to Form1.ComponentCount -1 do
if Form1.Components is TEdit then
Y := Y+1;
result := Y;
end;</P> 
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := 'Count of Edit is'+' '+InttoStr(EditCount)
end;

وهذا كود مشابه ولكن لمعرفة اقام تسلسليةلمكون ما ضمن باقي المكونات

Function gotSeriatingNumber:Integer;
var
I : Integer;
begin
for I := 0 to Form1.ComponentCount -1 do
 if Form1.Components is TEdit then
ShowMessage(IntToStr(I));
end;</P> 
procedure TForm1.Button1Click(Sender: TObject);
begin
gotSeriatingNumber;
end;
#2

هذه مجموعة من الأكواد التي عثرت عليها وأحببت مشاركتكم بها

هذا كود لإنشاء فورم بزوايا مستديرة

procedure TForm1.FormCreate(Sender: TObject);
var
  rgn: HRGN;
begin
  Form1.Borderstyle := bsNone;
  rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
	0,			// y-coordinate of the region's upper-left corner
	ClientWidth,  // x-coordinate of the region's lower-right corner
	ClientHeight, // y-coordinate of the region's lower-right corner
	40,		   // height of ellipse for rounded corners
	40);		  // width of ellipse for rounded corners
  SetWindowRgn(Handle, rgn, True);
end;

وهذا كود لعمل فتحة مضلعة في الفورم

type
  PtsType = array [0..15, 0..1] of Integer;

const
  Pts: PtsType = ((0, 0), (800, 0), (800, 600),
	(200, 600), (200, 220), (300, 280),
	(265, 205), (350, 117), (205, 170),
	(120, 90), (130, 200), (60, 350), (200, 220),
	(200, 600), (0, 600), (0, 0));


procedure TForm1.Button1Click(Sender: TObject);
var
  HRegion1: THandle;
begin
  HRegion1 := CreatePolygonRgn(Pts, SizeOf(Pts) div 8, alternate);
  SetWindowRgn(Handle, HRegion1, True);
end;

وهذا كود لتلوين الخلفية في تطبيق MDI

private
	{ Private declarations }
	 FClientInstance: TFarProc;
	FPrevClientProc: TFarProc;
	BkBrush: HBRUSH;
	procedure ClientWndProc(var Message: TMessage);

  public
	{ Public declarations }
	  constructor Create(AOwner: TComponent); override;
	destructor Destroy; override;

  end;
ثم
constructor TForm1.Create(AOwner: TComponent);
begin
  inherited;
  BkBrush := CreateSolidBrush(clblue);
  FClientInstance := Classes.MakeObjectInstance(ClientWndProc);
  FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
  SetWindowLong(ClientHandle, GWL_WNDPROC, Longint(FClientInstance));
end;

destructor TForm1.Destroy;
begin
  DeleteObject(BkBrush);
  inherited;
end;

procedure TForm1.ClientWndProc(var Message: TMessage);
var
  DC: HDC;
  BrushOld: HBRUSH;
begin
  with Message do 
  begin
	case Msg of
	  WM_ERASEBKGND:
		begin
		  DC := TWMEraseBkGnd(Message).DC;
		  BrushOld := SelectObject(DC, BkBrush);
		  FillRect(DC, ClientRect, BkBrush);
		  SelectObject(DC, BrushOld);
		  Result := 1;
		end;
	  else
		Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
	end;
  end;
end;

وهذا كود لعد مكونات من صنف واحد على الفورم

Function EditCount : Integer;
var
I , Y : Integer;
begin
Y := 0;
for I := 0 to Form1.ComponentCount -1 do
if Form1.Components is TEdit then
Y := Y+1;
result := Y;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := 'Count of Edit is'+' '+InttoStr(EditCount)
end;

وهذا كود مشابه ولكن لمعرفة اقام تسلسليةلمكون ما ضمن باقي المكونات

Function gotSeriatingNumber:Integer;
var
I : Integer;
begin
for I := 0 to Form1.ComponentCount -1 do
 if Form1.Components is TEdit then
ShowMessage(IntToStr(I));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
gotSeriatingNumber;
end;

ملاحظةأرجو عدمالعتبعلى الخطأ الذيحصل في الأعلى لأنها مشاركتي الأولى أولا

ثم العالم يجعل الأشياء أفضل والجاهل يجعلها أسوء

#3

بسم الله الرحمن الرحيم

:)

بارك الله فيك

1141068814.gif

It doesn't matter how slow you go, as long as you don't stop

#4

بسم الله الرحمن الرحيم

هدا كود ضعه في Edit

اقتباس
procedure TForm1.Edit1Enter(Sender: TObject);

begin

LoadKeyboardLayout('00000401', KLF_ACTIVATE);

Application.BiDiKeyboard := '00000401';

end;

اقتباس
procedure TForm1.Edit1Exit(Sender: TObject);

begin

LoadKeyboardLayout('0000040c', KLF_ACTIVATE);

Application.BiDiKeyboard := '0000040c';

end;

التيجة التي تحصل عليها انك كلما دخلت edit يعني الامر setfocus

تحول Keyboard الى اللغة العربية وكلما خرجت منه تحول الى الفرنسية

نصف العلم *** البحث الجيد

#5

أخي أنت أكيد مشكور كتير على الفكرة والله أنك خير ... بس ممكن توضح كيف يمكن صنع فورم على كيف المبرمج بالشكل والتصميم

#6

بسم الله الرحمن الرحيم

جرب هدا المكنون هو يعطي الفورم شكل الصورة التي تريد

ان شاء الله فيدك

Splash_Scrinne.rar

نصف العلم *** البحث الجيد

#7

شكرا لك بلال

اللهم علمنا ما ينفعنا وانفعنا بما علمتنا وانفع الناس بنا واغفر لنا وارحمنا

#8
اقتباس
أخي أنت أكيد مشكور كتير على الفكرة والله أنك خير ... بس ممكن توضح كيف يمكن صنع فورم على كيف المبرمج بالشكل والتصميم

عذرا أخي إنت ماحددة هدفك بس إذا كان سؤالك يعني نصنع فورم مستدير أو بيضوي غير القيم مثلا ليصبح الفورم بيضوي

 

procedure TForm1.FormCreate(Sender: TObject);
var
  rgn: HRGN;
begin
  Form1.Borderstyle := bsNone;
  rgn := CreateRoundRectRgn(0,// x-coordinate of the region's upper-left corner
	50,			// y-coordinate of the region's upper-left corner
	ClientWidth,  // x-coordinate of the region's lower-right corner
	ClientHeight, // y-coordinate of the region's lower-right corner
	500,		   // height of ellipse for rounded corners
	500);		  // width of ellipse for rounded corners
  SetWindowRgn(Handle, rgn, True);
end;

أما إذا متل ماقال الأخ بلال صورة ممكن تصنع فورم شفاف وتضع عليه صورة وبغض النظر عن حجم الفورم وحجم الصورة راح يتم المطلوب وحتى تخلي الفوم شفاف بس إضبط الخصائص التالية

procedure TForm1.FormCreate(Sender: TObject);
begin
with form1 do
 begin
 Color := clblack;
 transparentcolor:=true;
 transparentcolorvalue:= clblack;
 end;
end;

بس لازم تتأكد من أن الخاصية color و transparentcolorvalue لهما نفس القيمة

ضع الصورة التي تريد وسوف ترى ذلك أو ضع Label وأكتب عليها إسم الفريق العربي للبرمجة مثلا ولاحظ كيف سوف تظهر الكتابة فقط

TransportForm.rar

هذا الموضوع مغلق.

مواضيع مشابهة