标签:des style class blog tar ext
#include "stdafx.h" #include "TestGidPlus.h" LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); WNDCLASSEX wcApp; wcApp.lpszClassName = TEXT("Test_Window"); wcApp.cbSize = sizeof(wcApp); wcApp.style = CS_HREDRAW | CS_VREDRAW; wcApp.hInstance = hInstance; wcApp.cbWndExtra = 0; wcApp.cbClsExtra = 0; wcApp.hCursor = LoadCursor(NULL,IDC_ARROW); wcApp.hIcon = LoadIcon(NULL,IDI_APPLICATION); wcApp.lpfnWndProc = WndProc; wcApp.hCursor = LoadCursor(NULL,IDC_ARROW); wcApp.hbrBackground = (HBRUSH)(COLOR_WINDOW); wcApp.lpszMenuName = NULL; wcApp.hIconSm = NULL; RegisterClassExW(&wcApp); HWND hwnd = CreateWindowExW (NULL, TEXT("Test_Window"), TEXT(""), WS_OVERLAPPEDWINDOW, 100, 100, 600, 400, NULL, NULL, hInstance, NULL); ShowWindow(hwnd,SW_NORMAL); UpdateWindow(hwnd); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } GdiplusShutdown(gdiplusToken); return msg.lParam; } LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT b; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_CREATE: //SendMessage(hwnd,WM_PAINT,0,0); break; case WM_PAINT: { ///////////////////Gdiplus与Gdi混合实现双缓冲//////////////////// //HDC hMemDC = CreateCompatibleDC(m_hDC); //HBITMAP hMemBitmap = CreateCompatibleBitmap(m_hDC, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT); //SelectObject(hMemDC, hMemBitmap); //Graphics *memGraphics = new Graphics(hMemDC); //Pen pen(Color(192, 192, 192)); //SolidBrush brush(Color(255, 255, 255)); //memGraphics->FillRectangle(&brush, xPos, yPos, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT); //memGraphics->DrawRectangle(&pen, xPos, yPos, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT); //for (int i = 0; i < SMALL_IMAGE_COUNT; i++) //{ // DrawImageFromId(memGraphics, imgID[i], imgXPos[i], imgYPos[i]); //} //DeleteObject(hMemBitmap); //BitBlt(m_hDC, xPos, yPos, DEFAULT_STATUS_WIDTH, DEFAULT_STATUS_HEIGHT, hMemDC, 0, 0, SRCCOPY); //DeleteDC(hMemDC); //delete memGraphics; hdc = BeginPaint(hwnd, &ps); Graphics graphics(hdc); Pen pen(Color(255, 0, 0)); graphics.DrawLine(&pen, 0, 0, 0, 500); EndPaint(hwnd, &ps); break; } case WM_NCHITTEST: { POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); RECT rcClient; GetClientRect(hwnd, &rcClient); b = DefWindowProc(hwnd,message,wParam,lParam); switch(b) { case HTCLIENT: SetWindowText(hwnd,TEXT("点击的是客户区")); return b; case HTCAPTION: SetWindowText(hwnd,TEXT("点击的是标题栏")); return b; case HTBOTTOM: SetWindowText(hwnd,TEXT("点击的是下边框")); return b; case HTBOTTOMLEFT: SetWindowText(hwnd,TEXT("点击的是左下边框")); return b; return b; case HTCLOSE: SetWindowText(hwnd,TEXT("点击的是关闭按钮")); return b; case HTLEFT: SetWindowText(hwnd,TEXT("点击的是左边框")); return b; case HTMAXBUTTON: SetWindowText(hwnd,TEXT("点击的是最大化按钮")); return b; case HTMINBUTTON: SetWindowText(hwnd,TEXT("点击的是最小化按钮")); return b; case HTRIGHT: SetWindowText(hwnd,TEXT("点击的是右边框")); return b; case HTSYSMENU: SetWindowText(hwnd,TEXT("点击的是系统菜单")); return b; case HTTOP: SetWindowText(hwnd,TEXT("点击的是上边框")); return b; case HTBOTTOMRIGHT: SetWindowText(hwnd,TEXT("点击的是右下边框")); return b; case HTTOPRIGHT: SetWindowText(hwnd,TEXT("点击的是右上边框")); return b; case HTTOPLEFT: SetWindowText(hwnd,TEXT("点击的是左上边框")); return b; default: return b; } } case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
Win32 CreateWindow GdiPlus,布布扣,bubuko.com
标签:des style class blog tar ext
原文地址:http://www.cnblogs.com/d3inc/p/3799701.html