#include <windows.h> #include <commctrl.h> #include "tchar.h" LRESULT CALLBACK xiaoxichuli(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND hwndButton; HWND hAnmate; //按钮的句柄 switch (message) { case WM_CREATE: /****************************创建控件的部分**************************************/ //创建窗口的时候要做的事情 hwndButton = CreateWindow(TEXT("BUTTON"), TEXT("喵"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 10, 10, 100, 30, hwnd, (HMENU)1/*给按钮一个ID为1*/, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
//CreateWindow(TEXT("static"),TEXT("Sta1111111111"),WS_CHILD|WS_VISIBLE|SS_CENTER,100,100,300,200,hwnd,(HMENU)2, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL); //SetWindowText(hwndButton, TEXT("NEW"));
hAnmate = CreateWindow(ANIMATE_CLASS,TEXT("AC"),WS_CHILD|WS_VISIBLE|ACS_CENTER|ACS_AUTOPLAY,30,50,300,300,hwnd,(HMENU)3, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL); SendMessageA(hAnmate, ACM_OPEN, NULL, (LPARAM)L"G:\\CPro\\Project1\\Debug\\IMG_0013.avi"); break; /****************************处理事件消息部分*************************************/ case WM_COMMAND: if (LOWORD(wParam) == 1) //响应ID为1的消息 { MessageBox(hwnd, TEXT("来戳我吖!"), TEXT("喵吖喵"), MB_OK);//跳一个卖萌的消息框出来 } break; /********************************************************************************/ case WM_DESTROY: // 在消息队列中插入一个[退出程序]消息 PostQuitMessage(0); break; default:return DefWindowProc(hwnd, message, wParam, lParam); } // 执行内定的消息处理 return 0; } int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static char szAppName[] = TEXT("喵"); HWND hwnd; MSG msg; WNDCLASS wndclass; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = xiaoxichuli; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);// 加载 图标供程序使用 IDI-图示ID wndclass.hCursor = LoadCursor(NULL, IDC_SIZENWSE);// 加载 鼠标光标供程序使用 IDC-游标ID wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); //GetStockObject 取得一个图形对象(此例中是取得窗口背景的画刷对象) wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szAppName; // 注册窗口 if (!RegisterClass(&wndclass)) //如果程序类没法注册的话 { MessageBox(NULL, TEXT("程序无法运行"), szAppName, MB_ICONERROR); return 0; } //根据窗口类别 WndClass 建立一个窗口 hwnd = CreateWindow(szAppName, TEXT("喵~"), WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, hInstance, NULL); // 在屏幕上显示窗口 ShowWindow(hwnd, iCmdShow); // 指示窗口自我更新 UpdateWindow(hwnd); // 从消息队列中取得消息 while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }