
这没办法给你把代码全贴上来,你自己用VC建一下吧很容易的。
打开VC->File菜单->New->Project下的选中Win32 Application,Project Name中输入5471,下一步->选中A typical “Hello World!”Application点完成。把我下面的代码复制到你的5471cpp 文件里面去替换原来5471。cpp文件里的所有内容。
// 5471cpp : Defines the entry point for the application
//
#include "stdafxh"
#include "resourceh"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
void DrawPixel(HWND hWnd);
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_MY5471, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY5471);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msghwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msgwParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95 It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcexcbSize = sizeof(WNDCLASSEX);
wcexstyle = CS_HREDRAW | CS_VREDRAW;
wcexlpfnWndProc = (WNDPROC)WndProc;
wcexcbClsExtra = 0;
wcexcbWndExtra = 0;
wcexhInstance = hInstance;
wcexhIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY5471);
wcexhCursor = LoadCursor(NULL, IDC_ARROW);
wcexhbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcexlpszMenuName = (LPCSTR)IDC_MY5471;
wcexlpszClassName = szWindowClass;
wcexhIconSm = LoadIcon(wcexhInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
DrawPixel(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
void DrawPixel(HWND hWnd)
{
// 获取一个可供画图的DC,我这里就直接用桌面算了
HDC hdc = GetWindowDC( hWnd );
// 创建红色1像素宽度的实线画笔
HPEN hpen1 = CreatePen( PS_SOLID, 1, RGB(255,0,0) );
// 创建绿色5像素宽度的破折画笔,如果你想创建其他种类的画笔请参阅MSDN
HPEN hpen2 = CreatePen( PS_DASH, 5, RGB(0,255,0) );
// 创建一个实体蓝色画刷
HBRUSH hbrush1 = CreateSolidBrush( RGB(0,0,255) );
// 创造一个透明的画刷,如果你想创建其他种类的画刷请参阅MSDN
HBRUSH hbrush2 = (HBRUSH)GetStockObject( NULL_BRUSH );
// 将hpen1和hbrush1选进HDC,并保存HDC原来的画笔和画刷
HPEN hpen_old = (HPEN)SelectObject( hdc, hpen1 );
HBRUSH hbrush_old = (HBRUSH)SelectObject( hdc, hbrush1 );
// 在(40,30)处画一个宽200像素,高50像素的矩形
Rectangle( hdc, 40, 30, 40+200, 30+50 );
// 换hpen1和hbrush1,然后在(40,100)处也画一个矩形,看看有何差别
SelectObject( hdc, hpen2 );
SelectObject( hdc, hbrush2 );
Rectangle( hdc, 40, 100, 40+200, 100+50 );
// 画个椭圆看看
Ellipse( hdc, 40, 200, 40+200, 200+50 );
// 画个(0,600)到(800,0)的直线看看
MoveToEx( hdc, 0, 600, NULL );
LineTo( hdc, 800, 0 );
// 在(700,500)处画个黄点,不过这个点只有一像素大小,你细细的看才能找到
SetPixel( hdc, 700, 500, RGB(255,255,0) );
// 恢复原来的画笔和画刷
SelectObject( hdc, hpen_old );
SelectObject( hdc, hbrush_old );
ReleaseDC(hWnd,hdc);
}
DWORD GetClassLong(HWND hWnd,int nIndex )返回参数HWND hWnd指定的窗口类(具体说是用窗口类实例化的对象)的一些信息。窗口是一个很复杂的类,包含很多信息,如:背景画刷(指定客户区背景色)、左上角图标、光标等。究竟返回哪一种信息,则由int nIndex指定:如想得到背景画刷的信息,可以让参数nIndex=GCL_HBRBACKGROUND ,GetClassLong(hWnd,GCL_HBRBACKGROUND)则返回由hWnd指定窗口的背景画刷的句柄;如想获得窗口类的风格样式,则可这样调用GetClassLong(hWnd,GCL_STYLE);如想获得hWnd指定窗口的窗口函数的地址,则用GetClassLong(hWnd,GCL_WNDRPOC)。。。 当然,想要理解我上面所说的,你必须有一些基础知识,如GetClassLong中的Class对应RegisterClass函数注册的类,这个注册的窗口类之后用CreateWindows创建窗口,并返回窗口句柄hWnd。。。这些是Windows编程的基础知识,可找一些相关的书看看或加我Q。
Alt+PrintScreen组合键可以截取当前活动窗口,PrintScreen可以截取全屏。
这是Windows本身的屏幕截图功能,就是“打印屏幕系统请求”(通常是PrintScreen;或者PrintScreenSYSRQ、PrtScn、Print Scrn、Prnt Scrn、Prt Scr、PrtSc)键。
扩展资料:
常用截图方法:
1、Windows截图
2、浏览器截图
遨游浏览器高级版本自带截图功能,免去了抓图需要启动相关软件的麻烦。
TT浏览器屏幕截图一直是深受大家喜爱的功能,新版本对这个功能进行了升级,截图后编辑时插入的方框等可以选择线条粗细,还可以使用小画刷,自由涂抹。
3、播放软件截图
一些播放软件或游戏模拟器也提供截图功能,如PowerDVD、超级解霸、金山影霸等都有抓图功能。 *** 作一般为单击控件,截图就会被保存至软件默认的文件夹。
4、聊天工具截图
用聊天软件QQ就可以截图。QQ截图可以在聊天过程中选择聊天窗口下面的一个小显示器加小剪刀图标,然后拖动鼠标出现小框选择要截取的屏幕部分。之后双击鼠标就可以把要截取的部分粘贴到聊天窗口里。
还有一种方法是QQ软件开着,但是不管有没有聊天窗口可以按CTRL+ALT+A键,同样可以截取,截取之后的内容想用的时候在任何可以粘贴的软件中按粘贴即可。或者按快捷键CTRL+V也可以实现粘贴。两种方法在想取消截屏时按鼠标右键都可以取消。
微信小程序:网页全截图。
百度hi聊天软件截图按键是shift+alt+a。
5、专业截图工具
用专门的截图软件(比如HyperSnap-DX)截图。(注意一定要是支持DirectX的DX系列版本,如果是太老的版本,需要升级。)
以上就是关于cwindows应用程序的唯一入口点是全部的内容,包括:cwindows应用程序的唯一入口点是、WTL 怎样用画刷绘制子窗口背景,急的、急问C++如何创建新窗口用来画图!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)