当前位置:网站首页>EasyX realizes button effect
EasyX realizes button effect
2022-07-25 01:24:00 【Cap07】
#undef UNICODE // To add , otherwise outtextxy Report errors
#include <stdio.h>
#include <graphics.h>
int main() {
ABC:;
MOUSEMSG m;
initgraph(600, 600); // Set the length and width of the window ( Along the x Shaft length , Along the y Shaft length )
setbkcolor(GREEN); // Set the window background to green
cleardevice(); // Refresh once Slightly equal to that system(cls), Be sure to add , Otherwise, the background color is set but cannot be updated
setfillcolor(LIGHTBLUE); // Set the window fill color to blue , That is, the color of the rectangle below
// Distance window On the left 30 above 300 On the left 100 high 330 A rectangle surrounded
fillrectangle(30, 300, 100, 330);
fillrectangle(110, 300, 180, 330);
fillrectangle(190, 300, 260, 330);
settextstyle(17, 0, " Song style ");// Format text ( Text size , Text vertical compression , typeface )
setbkmode(TRANSPARENT);// Remove the text background , Otherwise, the text in the rectangle will also have a green shadow
// Distance window On the left 30 above 310
outtextxy(40, 310, " Button 1");
outtextxy(120, 310, " Button 2");
outtextxy(200, 310, " Refresh ");
while (1) { // Be careful while loop , In this way, you can keep getting the position of the mouse , So as to update the corresponding operation
m = GetMouseMsg(); // Get mouse object
if (m.x >= 30 && m.x <= 100 && m.y >= 300 && m.y <= 330) {
setlinecolor(RED);
// Draw a rectangle , Larger than the original rectangle 5
rectangle(25, 295, 105, 335);
settextstyle(50, 0, " Song style ");// Format text ( Text size , Text vertical compression , typeface )
settextcolor(BLACK); // Set the font color to black
if (m.uMsg == WM_LBUTTONDOWN) {
outtextxy(200, 200, " Ah Wei is your father ");
}
}
else if (m.x >= 110 && m.x <= 180 && m.y >= 300 && m.y <= 330) {
setlinecolor(RED);
// Draw a rectangle , Larger than the original rectangle 5
rectangle(105, 295, 185, 335);
settextstyle(50, 0, " Song style ");// Format text ( Text size , Text vertical compression , typeface )
settextcolor(BLACK); // Set the font color to black
if (m.uMsg == WM_LBUTTONDOWN) {
outtextxy(200, 200, " PigHead ");
}
}
else if (m.x >= 190 && m.x <= 260 && m.y >= 300 && m.y <= 330) {
setlinecolor(RED);
// Draw a rectangle , Larger than the original rectangle 5
rectangle(185, 295, 265, 335);
settextstyle(50, 0, " Song style ");// Format text ( Text size , Text vertical compression , typeface )
settextcolor(BLACK); // Set the font color to black
if (m.uMsg == WM_LBUTTONDOWN) {
cleardevice();
goto ABC;
}
}
else {
setlinecolor(WHITE); // When the mouse focus is not on the button , Reset the border to white , Only by combining the following can you successfully set
rectangle(25, 295, 105, 335); // Button 1 Frame
rectangle(105, 295, 185, 335); // Button 2 Frame
rectangle(185, 295, 265, 335); // Refresh border
}
}
return 0;
}effect :

边栏推荐
- MySQL series | log module
- What is iftmcs indicating contract status message?
- 7.15 - daily question - 408
- Detailed explanation of the usage of vector, queue and stack
- [summer daily question] Luogu p1605 maze
- Three possible scenarios for SAP Spartacus server-side rendering
- PG Optimization -- execution plan
- Codeworks round 649 (Div. 2) ABC problem solution
- About the difference between for... In and for... Of and object. Keys()
- Six stones Management: the process is only convenient to shirk responsibility, but not helpful to solve problems
猜你喜欢

7.18 - daily question - 408

Synchronization primitive: lock

Document the use of anti shake in packaged components and projects

Top priority of dry goods: common indicators and terms in data analysis!

The most complete summary of MySQL data types in history - (first)

Turn: emotional internal friction is the biggest source of inefficiency in your life

Game partner topic: the cooperation between breederdao and monkeyleague kicked off

Custom type
![[29. DFS depth is preferred]](/img/f1/f0c4302a1f7c14c206ff0bdf2eed5c.png)
[29. DFS depth is preferred]

Why is the exclude or include attribute setting of the < keep alive > component invalid
随机推荐
Take the first place in the International Olympic Games in mathematics, physics and chemistry, and win all the gold medals. Netizen: the Chinese team is too good
Musk responded whether he would upload his brain to the cloud: already did it!
If in ython__ name__ == ‘__ main__‘: Function and principle of
Chapter III kernel development
Implementing DDD based on ABP -- domain logic and application logic
How to create an index
The two supply chain centers of HEMA launched the "background" of innovative research and development of multi format commodities
[FAQ of waiting insurance] can the waiting insurance evaluation organization help with the waiting insurance rectification?
Take C language from 0 to 1 - program structure and use examples
VC hesitates to invest in Henan
Unity image control and rawimage
How SAP Spartacus redefines login component
DotNetCore. Cap notes
[27. Expression evaluation (infix expression)]
WhatsApp web for usability testing of software testing technology
Breederdao's first proposal was released: the constitution of the Dao organization
Director of Shanghai Bureau of culture and Tourism: safety is the lifeline of culture and tourism, and we are seizing the new track of yuancosmos
Service address dynamic awareness of Nacos registry
unresolved external symbol [email protected] resolvent
MySQL series | log module