求一个简单的win32贴图的完整的小程序。。。
求帮忙,为下面的简单程序贴一个图#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<Windows.h>
#include<stdio.h>
using namespace std;
LRESULT CALLBACK WinProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrewInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wndclass;//定义窗口类对象
//WNDPROC
static LPCTSTR szAppName = (LPCTSTR)"weixin";
wndclass.hbrBackground
= (HBRUSH)GetStockObject(DKGRAY_BRUSH);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WinProc;
wndclass.lpszClassName = szAppName;
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
RegisterClass(&wndclass);
HWND hwnd;
hwnd = CreateWindow(szAppName,
L"窗口标题", WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
hInstance,
NULL);
ShowWindow(hwnd, SW_SHOWNORMAL );
UpdateWindow(hwnd);
//消息循环
MSG msg;
while (GetMessage(&msg,NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return static_cast<int>(msg.wParam);
}
//消息处理函数,窗口过程函数
LRESULT CALLBACK WinProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
break;
case WM_CLOSE:
if(IDYES == MessageBox(hwnd, L"你是否退出程序?", L"winxin", MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
[此贴子已经被作者于2017-6-1 15:44编辑过]