设为首页 加入收藏

TOP

MFC、VC++综合作业题(五)
2016-04-27 17:25:25 】 浏览:2679
Tags:MFC 综合 作业
);

break;

case WM_LBUTTONDOWN:

MessageBox(hwnd,"mouse clicked","weixin",0);

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;

}

2、

#include

#include

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(BLACK_BRUSH);

wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);

wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);

wndcls.hInstance=hInstance;

wndcls.lpfnWndProc=WinSunProc;

wndcls.lpszClassName="Computer2009";

wndcls.lpszMenuName=NULL;

wndcls.style=CS_HREDRAW | CS_VREDRAW;

RegisterClass(&wndcls);

HWND hwnd;

hwnd=CreateWindow("Computer2009","桂林电子科技大学应用科技学院",WS_OVERLAPPEDWINDOW,0,0,600,400,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

)

{ switch(uMsg)

{

case WM_CHAR:

char szChar[20];

sprintf(szChar,"char is %d",wParam);

MessageBox(hwnd,szChar,"weixin",0);

break;

case WM_LBUTTONDOWN:

MessageBox(hwnd,"mouse clicked","weixin",0);

HDC hdc;

hdc=GetDC(hwnd);

TextOut(hdc,0,50,"Widows程序设计实验",strlen("Widows程序设计实验"));

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,"是否真的结束?","Compuer",MB_YESNO))

{

DestroyWindow(hwnd);

}

break;

case WM_DESTROY:

PostQuitMessage(0);

break;

default:

return DefWindowProc(hwnd,uMsg,wParam,lParam);

}

return 0;

}

}

3、

#include <windows.h>

#include //sprintf()函数在这个头文件中声明

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,

PSTR szCmdLine, int iCmdShow)

{

static TCHAR szAppName[] = TEXT ("HelloWin") ;

HWND hwnd ;

MSG msg ;

WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;

wndclass.lpfnWndProc = WndProc ;

wndclass.cbClsExtra = 0 ;

wndclass.cbWndExtra = 0 ;

wndclass.hInstance = hInstance ;

wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;

wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;

wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;

wndclass.lpszMenuName = NULL ;

wndclass.lpszClassName = szAppName ;

if (!RegisterClass (&wndclass))

首页 上一页 2 3 4 5 6 下一页 尾页 5/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++学习笔记之四 复合类型1 下一篇LeetCode最常见的面试笔试题总结

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目