30 likes | 131 Vues
Modul 13 Bekerja Dengan Form & Options The Border Style Dalam modul kali ini akan diperlihatkan bagaimana bekerja dengan form terutama pada pilihan border form , menu border style form dapat anda langsung pilih bagian properti , dan pilih
E N D
Modul 13 Bekerja Dengan Form & Options The Border Style Dalam modul kali ini akan diperlihatkan bagaimana bekerja dengan form terutama pada pilihan border form , menu border style form dapat anda langsung pilih bagian properti , dan pilih border style yang digunakan . Pada aplikasi dibawah ini sengaja digunakan agar dapat memahami perintah dari radiogroup . Langsung saja , dapat anda kerjakan langsung . Object -object yang diperlukan http://www.mercubuana.ac.id Bahasa 4gl - Multitier , Hal 1 Yasin
procedure TForm1.FormPaint(Sender: TObject); var X1, Y1: Integer; begin X1 := HorzScrollBar.Position; Y1 := VertScrollBar.Position; // draw a yellow line Canvas.Pen.Width := 30; Canvas.Pen.Color := clYellow; Canvas.MoveTo (30-X1, 30-Y1); Canvas.LineTo (1970-X1, 1970-Y1); Getting Input Mouse The Parameters of the Mouse Events All the lower-level mouse events have the same parameters: the usual Sender parameter, a Button parameter indicating which of the three mouse buttons has been clicked (mbRight, mbLeft, or mbCenter), the Shift parameter indicating which of the mouse-related virtual keys (the shift-state modifiers Alt, Ctrl, and Shift, plus the three mouse buttons) was pressed when the event occurred; and the x and y coordinates of the position of the mouse in client area coordinates of the current window. Using this information, it is simple to draw a small circle in the position of a left mouse button– down event: procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbLeft then Canvas.Ellipse (X-10, Y-10, X+10, Y+10); end; http://www.mercubuana.ac.id Bahasa 4gl - Multitier , Hal 3 Yasin
Saat Keluar Dari Form When you close the form using the Close method or by the usual means (AltF4, the system menu, or the Close button), the OnCloseQuery event is called. In this event, you can ask the user to confirm the action, particularly if there is unsaved data in the form. Here is an example of the code you can write: procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if MessageDlg ('Are you sure you want to exit?', mtConfirmation, [mbYes, mbNo], 0) = mrNo then CanClose := False; end; If OnCloseQuery indicates that the form should still be closed, the OnClose event is called. The third step is to call the OnDestroy event, which is the opposite of the OnCreate event and is generally used to de-allocate objects related to the form and free the corresponding memory. Trik Menghibur ? Tambahkan sebuah Button pada form dan ketik perintah dibawah ini procedure TForm1.Button4Click(Sender: TObject); var i:integer; begin for i:= 100 to 240 do form1.width:=i; end; http://www.mercubuana.ac.id Bahasa 4gl - Multitier , Hal 5 Yasin