Implement a beautiful Chinese character window with Delphi7.0

xiaoxiao2021-03-05  103

In the era of visual development, the form is the core of the most applications, but developers may have bored the Windows complementary square form. In fact, the form of a Chinese character shape can be realized using the API function. A form of three Chinese characters as a profile will be displayed after the instance of this article. Of course, you can also use this approach to realize more personal Chinese character windows.

Design ideas

1 Use the BeginPath and EndPath functions to define the path to the form.

2 Convert the path to Region data with Pathtoregion.

3: Call SetWindowRGN Press the path to draw the form.

4 Due to the irregular form without the system menu, the code must be closed in the program.

Implementation steps

Start Delphi7, create a new project. The aforementioned API function can be called directly in Delphi, so the user does not need to declare, and can directly enter the following control event code.

// Form Create Event Procedure TFORM1.FORMCREATETENDER  TOBJECT Var RGN hrgnbegin // Set text color is red Form1.color = CLRED  // Start setting path, refer to API function declaration 1 BeginPathcanvas .Handle   // Setting the background for transparency, refer to the API function declaration 2 setBkmode canvas.handleTranspa Rent  // Set font canvas.font.name  = 'Song'  // set the font size canvas.font.size  = 100  // Set the Chinese character "Computer News" to the form shape path Canvas.Textout1515 'computer newspaper'                                                                Endpathcanvas.Handle  // Convert the path to the area, refer to the API function declaration 4, complete design ideas (2) RGN = pathtoregion canvas.handle  // Change the form shape, refer to the API function declaration 5, Completion Design Idea (3) SetwindowRgnhandlergntrue  End // Mouse Press Event to Complete Design Idea (4) Procedure TFORM1.FORMMOUSEDOWN SENDER  TOBJECT  Button  TMOUSEBUTTON SHIFT  TshiftState x  Y Integer  Begin // If the user clicks right, end the program run if button = mbright the closeend

转载请注明原文地址:https://www.9cbs.com/read-36364.html

New Post(0)