他是中国航天之父,两弹一星功臣.一代伟人就这样去世,默哀啊
小时候就很钦佩他.
...
他是中国航天之父,两弹一星功臣.一代伟人就这样去世,默哀啊
小时候就很钦佩他.
...
#include "stdafx.h" LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstatnce, LPSTR lpstrCmdLine, int nCmdShow = SW_SHOW) { MSG msg; WNDCLASS ws; ws.style = 0; ws.lpfnWndProc = (WNDPROC)MainWndProc; ws.cbClsExtra = 0; ws.cbWndExtra = 0; ws.hInstance = hInstance; ws.hIcon = LoadIcon(NULL, IDI_APPLICATION); ws.hCursor = LoadIcon(NULL, IDC_ARROW); ws.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); ws.lpszClassName = L"my"; ws.lpszMenuName = NULL; if(!RegisterClass(&ws)) return FALSE; HWND hWndMain; hWndMain = CreateWindow( L"my", L"显示window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); if(!hWndMain) return FALSE; ShowWindow(hWndMain,nCmdShow); while(GetMessage(&msg, NULL, 0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HDC hDc; static LPPAINTSTRUCT pt; HICON ghIcon = NULL; HBITMAP ghbmMask = NULL; HBITMAP ghbmColor = NULL; RECT rt ={0,0,100,20}; static HDC dc; HPEN hPen; static int i = -10; switch (uMsg) { case WM_PAINT: PAINTSTRUCT ps; HDC hdc; COLORREF crTxt, crBk; hDc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_ERASEBKGND: dc = ::GetDC(hWnd); ::FillRect(dc,&rt,(HBRUSH)::GetStockObject(BLACK_BRUSH)); ::DrawText(dc,L"文字显示 ", -1, &rt, DT_VCENTER|DT_CENTER); ::ReleaseDC(hWnd,dc); break; case WM_LBUTTONDOWN: i += 10; rt.top += 3*i; rt.bottom = rt.top + 20; hPen=CreatePen(PS_INSIDEFRAME,1,RGB(0,255,255)); dc = ::GetDC(hWnd); SelectObject(dc,hPen); ::DrawText(dc,L"文字显示 ", -1, &rt, DT_VCENTER|DT_CENTER); MoveToEx(dc,0,i, NULL); LineTo(dc,800,i); ::ReleaseDC(hWnd,dc); //MessageBox(NULL,L"OK",NULL,NULL); break; case WM_RBUTTONDOWN: //MessageBox(NULL,L"right OK",NULL,NULL); break; case WM_DESTROY: PostQuitMessage(0);break; default: return (DefWindowProc(hWnd, uMsg, wParam, lParam)); } return 0; }
...
error LNK2001: unresolved external symbol _WinMain@16
debug/main.exe:fatal error LNK 1120:1 unresolved externals
error executing link.exe;
1, 你用vc建了一个控制台程序,它的入口函数应该是main, 而你使用了WinMain.
...2009-10-21
1,win OnPaint 与 OnEraseBkgnd :在OnPaint 函数当中,CPaintDC会发送WM_ERASEBKGND消息,这也好理解,屏幕重画了,背景也需要重新再画一次。
2,CRect 中的DeflateRect是缩进矩形区域中的值,具体参数可以参看MSDN文档.
3.c++ include :C++编译器编译的文件是cpp文件,用#include 是把include进的文件代码展开到当前文件中来。
...