Delphi Design Photoshop pop-up Menu

Source: Internet
Author: User

As we all know, using Delphi's Tpopupmenu widget can make pop-up menus. But how can we create a pop-up menu that resembles the various styles in Photoshop? (for example, Photoshop's Brush shape selection menu, see figure)

The production method is as follows:

1. Open Delphi and place a TButton widget in the Form1.

2. Create a new form and use the default name Form2.

3. Set the Form2 BorderStyle property to Bsnone, which will remove the form's title bar and border.

4. Add the Tpanel widget Panel1 to the Form2, set the Panel1 Bevelinner and Bevelouter properties to bvraised, and set the Align property to alclient. Use a Panel1 border as a border for the menu form.

5. Add Unit2 to the uses of the implementation section of UNIT1.

6. Double-click the button widget Button1 in Form 1 to add the following code:

procedure TForm1.Button1ClickSender TObject
var
  ShowingPoint TPoint
begin
  GetCursorPosShowingPoint // 得到光标的当前坐标
  Form2.Left = ShowingPoint.X // 让Form2在当前光标处显示
  Form2.Top = ShowingPoint.Y
  Form2.Show
end

7. Add the following code under the Form2 ondeactivate event:

procedure TForm2.FormDeactivateSender TObject
begin
  Close // 当窗体失去焦点后,关闭自己。
end

8. Press F9 to run the program, double-click Button1, Form2 will be like pop-up menu display, click Form1 any place, Form2 will automatically close. Next, friends will be able to design their own pop-up menu on the Form2.

The above program is tested in Windows + Delphi 5.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.