|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 freeparty 于 2015-5-18 13:08 编辑
- #include <Windows.h>
- #include <tchar.h>
- #include <string>
- #include <strsafe.h>
- using namespace std;
- LRESULT CALLBACK WndProc(HWND Hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- const TCHAR szWindowClass[] = L"窗口";
- const TCHAR szWindowTite[] = L"标题";
- int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpCmdLine, int nCmdShow)
- {
- WNDCLASSEX wcex = { 0 };
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = (WNDPROC)WndProc;
- wcex.hInstance = hInstance;
- wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- wcex.lpszClassName = szWindowClass;
- RegisterClassEx(&wcex);
- HWND hWnd = CreateWindow(
- szWindowClass,
- szWindowTite,
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- NULL,
- NULL,
- hInstance,
- NULL);
- if (!hWnd)return FALSE;
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- HDC hdc;
- int i;
- PAINTSTRUCT ps;
- size_t iT;
- TCHAR szBuffer[12];
- TEXTMETRIC tm;
- static int cxChar, cyChar;
- switch (msg)
- {
- case WM_CREATE:
- hdc = GetDC(hWnd);
- GetTextMetrics(hdc, &tm);
- cxChar = tm.tmAveCharWidth;
- cyChar = tm.tmHeight + tm.tmExternalLeading;
- ReleaseDC(hWnd, hdc);
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- case WM_PAINT:
- {
- HDC hdc = BeginPaint(hWnd, &ps);
- for (i = 0; i < 10; i++)
- {
- StringCchPrintf(szBuffer, 12, TEXT("%d:%s"), i + 1, TEXT("heheda"));
- StringCchLength(szBuffer, 12, &iT);
- TextOut(hdc, cxChar, i* cyChar, szBuffer, iT);
- }
- EndPaint(hWnd, &ps);
- return 0;
- }
- default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
- }
复制代码
这个调试怎么闪退了呢,看着个甲鱼老师视频上面代码一样的啊。。郁闷了
|
评分
-
查看全部评分
|