15,979
社区成员
发帖
与我相关
我的任务
分享
#include <windows.h>
#include <stdio.h>
#include<string>
#include <time.h>
using namespace std;
#define WS_EX_LAYERED 0x80000
typedef BOOL (WINAPI*FPT)(HWND,int,BOOL,DWORD);
FPT fp;
LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="Weixin2003";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindowEx(WS_EX_TOPMOST|WS_EX_LAYERED|WS_EX_TOOLWINDOW,"WinSunProc",NULL,WS_POPUP|WS_SYSMENU,
0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
HMODULE hsad=LoadLibrary("user32.dll");
HDC hdc;
char str[]="I love You";
switch(uMsg)
{
case WM_CREATE:
fp=(FPT)GetProcAddress(hsad,"SetLayeredWindowAttributes");
FreeLibrary(hsad);
fp(hwnd,RGB(255,255,255),200,3);
MessageBox(hwnd,"","",MB_OK);
SetTimer(hwnd,1,1000,NULL);
break;
case WM_TIMER:
hdc = GetDC(hwnd);
TextOut(hdc,rand()%SM_CXSCREEN,rand()%SM_CYSCREEN,str,sizeof(str)-1);
break;
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"weixin",0);
break;
case WM_LBUTTONDOWN:
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"计算机编程语言培训",strlen("计算机编程语言培训"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"维新培训",strlen("维新培训"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","weixin",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include<string>
#include <time.h>
using namespace std;
#define WS_EX_LAYERED 0x80000
typedef BOOL (WINAPI*FPT)(HWND,int,BOOL,DWORD);
FPT fp;
LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName= _T("Weixin2003");
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindowEx(WS_EX_TOPMOST|WS_EX_LAYERED|WS_EX_TOOLWINDOW, _T("Weixin2003"),NULL,WS_POPUP|WS_SYSMENU,
0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
HMODULE hsad=LoadLibrary(_T("user32.dll"));
HDC hdc;
TCHAR str[]= _T("I love You");
switch(uMsg)
{
case WM_CREATE:
fp=(FPT)GetProcAddress(hsad,"SetLayeredWindowAttributes");
FreeLibrary(hsad);
fp(hwnd,RGB(255,255,255),200,3);
MessageBox(hwnd,_T(""),_T(""),MB_OK);
SetTimer(hwnd,1,1000,NULL);
break;
case WM_TIMER:
hdc = GetDC(hwnd);
TextOut(hdc,rand()%GetSystemMetrics(SM_CXSCREEN),rand()%GetSystemMetrics(SM_CYSCREEN),str,_tcslen(str));
ReleaseDC(hwnd, hdc);
break;
case WM_CHAR:
TCHAR szChar[20];
_stprintf(szChar, _T("char is %d"),wParam);
MessageBox(hwnd,szChar, _T("weixin"),0);
break;
case WM_LBUTTONDOWN:
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,_T("计算机编程语言培训"),_tcslen(_T("计算机编程语言培训")));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0, _T("维新培训"),_tcslen(_T("维新培训")));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd, _T("是否真的结束?"), _T("weixin"),MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}