Visualization of C Language Course Design by [GUI] [easyX]

Posted by php_dev_101 on Mon, 03 Jan 2022 09:25:21 +0100

Is it easy for me to whistle all the time?
Not enough flowers? Up Ah Brothers Working Together

The console interface is too hard to accept.

Want to be available to anyone who uses Windows

This received activity (course design) is the KTV track library information query system.

Download the extension library on easyX's official website (create the file with a cpp suffix)

I little interesting

For C Language Visualization
I surf the Internet and an EasyX pops up in the waves.
After all, this is the first time and I am not very skilled.

Window Design

Drawing on the UI style set by win11, I created a 1024X768 window
The left and right rounded rectangles divide the menu bar and the function bar.

Then add a circle in the upper left corner to break the balance between horizontal and vertical, to offset the visual center of gravity, which improves the look and feel
(Bullshit)
This is the start page

Some effects

Four sizes of fonts have been designed
Microsoft Yahei Medium Thickness Three Thickness Heights 20-27
For buttons you want to achieve a mouse hover and click with a different color effect


(Yes, turn off the red button)
Name Praise for QQ, ctrl+alt+A for color, lazy (me) ecstasy

Up to the time of writing (2022-1-1) function development has not been completely completed, background data operations to teammates
(They must have learned structure ordering (confident) (escaping) in three days)
With a lot of privacy about this program, no screenshots will be taken

Paste code

The meaning of the function refers to the technical documentation available on easyX's website (well received)
You can also go to Definition View in VS.
It will be updated later

Do you know how I've been doing these days?
Finish when you can't bear it
After all, for the first time, modularization through functions is not very skilled
Directly blocking without special effects buttons and poorly produced code is really TM big
I even crashed several times
Also
If you can run, run, or run on BUG.
Never, never try to refactor code (!!!!!!)

#include<stdio.h>
#include<graphics.h>

#define textsml settextstyle(20, 0,'Microsoft Yahei', 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0)
#define textmid settextstyle(23, 0,'Microsoft Yahei', 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0)
#define textlrg settextstyle(27, 0,'Microsoft Yahei', 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0)
#define textElrg settextstyle(35, 0,'Microsoft Yahei', 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ANTIALIASED_QUALITY, 0)

#define Checkpos checkpos(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, msg.x, msg.y)

struct buttonbox {
	int lx, ly, rx, ry;
	int ava=false;
}butt[1000];

struct MusicInfo {
	char Title[100], Album[100], Author[50];
	int AlbumNum, LibNum;
};

char menu[6][20] = { "Track Query","Track Browsing","Track Operation","Guide to Use","About this program" };
int step = 45, ButtNum, ClickFlag = -1;

void home();
void Click(int num);

int checkpos(int lx, int ly, int rx, int ry, int nowx, int nowy) {
	if (nowx >= lx && nowy >= ly && nowx <= rx && nowy <= ry)
		return true;
	else return false;
}

void SetButton(int lx, int ly, int rx, int ry, int num,int r,int g,int b) {
	
	textmid;
	setfillcolor(RGB(r,g,b));
	solidroundrect(lx, ly, rx, ry, 15, 15);
	setbkmode(TRANSPARENT);
	
	int ty = (ly + ly + (ry-ly) - textheight(menu[num])) / 2;
	outtextxy(lx+10, ty, menu[num]);

	return;
}

/*
void ButtonOperationClick(int lx, int ly, int rx, int ry, int i, ExMessage msg) {
	int tmp = true;
	//button-click-effect
	setfillcolor(RGB(47, 41, 41));
	solidroundrect(310, 15, 1014, 750, 15, 15);
	//check lb status
	while(1) {
		if (!msg.lbutton) {
			Click(i);
			break;
		}
		peekmessage(&msg, EM_MOUSE);
	}
	return;
}
*/

void ButtonOperationGen2() {
	//initialize data
	ExMessage msg;
	int OperationFlag = 0;
	int lx, ly, rx, ry;
	//go
	while (1) {
		//check which button is the mouse on
		for (int i = 0; i <= ButtNum; i++) {

			if (butt[i].ava == false) continue;
			lx = butt[i].lx, ly = butt[i].ly, rx = butt[i].rx, ry = butt[i].ry;

			//get check-messages
			peekmessage(&msg, EM_MOUSE);
			OperationFlag = Checkpos;

			//check hover on button_i
			if (OperationFlag) {

				//button-hover-effect
				SetButton(lx, ly, rx, ry, i, 50, 50, 50);

				//check hover on button_i
				do {
					//check click
					if (msg.lbutton) {
						SetButton(lx, ly, rx, ry, i, 196, 43, 28);
						//ButtonOperationClick(lx, ly, rx, ry, i, msg);
						//button-click-effect
						setfillcolor(RGB(43, 43, 45));
						solidroundrect(310, 15, 1014, 750, 15, 15);
						//check lb status
						while (1) {
							if (!msg.lbutton) {
								Click(i);
								break;
							}
							peekmessage(&msg, EM_MOUSE);
						}
						break;
					}
					//renew check-messages
					peekmessage(&msg, EM_MOUSE);
					OperationFlag = Checkpos;
				} while (OperationFlag);
				
				//button-default-effect
				SetButton(lx, ly, rx, ry, i, 43, 43, 45);
			}
		}
	}
		
}


int main() {
	home();
	return 0;
}

void home() {
	
	initgraph(1024,768,EW_NOMINIMIZE);
	
	setbkcolor(RGB(36, 30, 30));
	cleardevice();
	
	setfillcolor(RGB(43, 43, 45));
	solidroundrect(10, 15, 300, 750, 20, 20);
	solidroundrect(310, 15, 1014, 750, 20, 20);
	
	//account 10,25,370,125
	setfillcolor(RGB(149, 229, 149));
	solidcircle(66, 66, 36);//startx = 30

	setbkmode(TRANSPARENT);
	textlrg;
	outtextxy(120, 45, "Quku Background");
	textsml;
	outtextxy(120, 70, "Admin@outlook.com");
	
	Click(3);
	//menu-function classify 
	textmid;
	for (ButtNum = 0; ButtNum <= 4; ButtNum++) {

		butt[ButtNum].ava = true;

		butt[ButtNum].lx = 30;
		butt[ButtNum].ly = 130 + step * ButtNum;
		butt[ButtNum].rx = butt[ButtNum].lx + 250;
		butt[ButtNum].ry = butt[ButtNum].ly + 40;

		SetButton(butt[ButtNum].lx, butt[ButtNum].ly, butt[ButtNum].rx, butt[ButtNum].ry, ButtNum, 43, 43, 45);

	}
	//button operation
	ButtonOperationGen2();

	return;
}

void Click(int num) {
	switch (num)
	{
	case 0: {
		textElrg;
		outtextxy(360, 60, menu[num]);
		return;
	}
	case 1: {
		textElrg;
		outtextxy(360, 60, menu[num]);
		return;
	}
	case 2: {
		textElrg;
		outtextxy(360, 60, menu[num]);
		return;
	}
	case 3: {
		int txts = 130;
		textElrg;
		outtextxy(360, 60, menu[num]);
		textmid;
		outtextxy(400, txts, "This program operates with mouse and keyboard");
		outtextxy(400, txts += 65, "Use the mouse to click on the corresponding button in the left menu bar to enter the function interface");
		outtextxy(400, txts += 35, "Use the mouse to click on the desired function button in the function interface");
		outtextxy(400, txts += 35, "Click the button as prompted or enter the required information in the dialog box");
		outtextxy(400, txts += 65, "Click after the information is entered   -Update Information File-   Update information and support queries");
		outtextxy(400, txts += 65, "Users with poor hardware configuration or incomplete operating environment");
		outtextxy(400, txts += 35, "We provide a version of the console operating interface");
		outtextxy(400, txts += 65, "Wishing you a pleasant time");
		return;
	}
	case 4: {
		int txts = 130;
		textElrg;
		outtextxy(360, 60, menu[num]);
		textmid;
		outtextxy(400, txts, "This program is level 2021 C Language Course Design Display Program");
		outtextxy(400, txts += 55, "Producer:Chao Hu Sheng Gao Pu Zheng Gao Wan Qing (names are sorted by school number)");
		outtextxy(400, txts += 55, "The main functions of this program are:");
		textsml;
		outtextxy(400 + 20, txts += 35, "Song information entry, modification, deletion function");
		outtextxy(400 + 20, txts += 35, "Song sorting browsing function");
		outtextxy(400 + 20, txts += 35, "Query by song name, by singer, etc.");
		textmid;
		outtextxy(400, txts += 55, "The main division of work for the team is as follows:");
		textsml;
		outtextxy(400 + 20, txts += 35, "Chao Husheng: Song information input, modification, deletion function");
		outtextxy(400 + 20, txts += 35, "KO: File read and write operations, and main functions");
		outtextxy(400 + 20, txts += 35, "High euphemism: song information sorting, browsing, query functions");
		return;
	}
	default:
		break;
	}
	return;
}
//bad attempt
/*
void ButtonOperation() {
	ExMessage msg;
	int HoverFlag = false;//avoid over-refreshing when hovering
	int PressFlag = false;//avoid over-refreshing when pressing
	int ClickNum = -1;
	while (1) {
		int i;
		for (i = 0; i <= ButtNum; i++) {
			peekmessage(&msg, EM_MOUSE);
			//hover-effect
			if (checkpos(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, msg.x, msg.y) && HoverFlag == false) {
				SetButton(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, i, 50, 50, 50);
				HoverFlag = true;
				//if mouse is still on
				while (1) {
					peekmessage(&msg, EM_MOUSE);
					//cancel hover-effect
					if (checkpos(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, msg.x, msg.y) == false) {
						SetButton(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, i, 47, 41, 41);
						HoverFlag = false;
						break;
					}
					//click effect
					if (msg.lbutton) {
						PressFlag = true;
						ClickNum = i;
						SetButton(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, i, 232, 17, 35);
						//if lb is still down
						while (1) {
							setfillcolor(RGB(47, 41, 41));
							solidroundrect(310, 15, 1014, 750, 15, 15);
							peekmessage(&msg, EM_MOUSE);
							if (!checkpos(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, msg.x, msg.y) && HoverFlag) {
								PressFlag = false;
								HoverFlag = false;
								SetButton(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, i, 50, 50, 50);

							}
							if (msg.lbutton == 0) {
								PressFlag = false;
								if (ClickNum == i) {
									break;
								}
								SetButton(butt[i].lx, butt[i].ly, butt[i].rx, butt[i].ry, i, 50, 50, 50);
								break;
							}

						}//if lb is still down
						Click(i);
					}//click effect

				}//if mouse is still on

			}//hover-effect

		}
		Sleep(20);
	}
	return;
}
*/

Topics: Project GUI