void CMainFrame::OnButtonQrcode() { // TODO: 在此添加命令处理程序代码 //CString path = L"http://www.baidu.com"; CString path = L"调拨阿勒,我们可以用二维码聊天了"; int W = 0; int H = 0; string s = UnicodeToAnsi(path); BYTE *lpByte = NULL; lpByte = GenerateBarCode(s.c_str(), &W, &H); if (NULL == lpByte) { return; } SaveBmp("GY.bmp", lpByte, W, H, 32, NULL); ShellExecute(NULL, L"Open", L"GY.bmp", NULL, NULL, SW_SHOW); delete[] lpByte; lpByte = NULL; }
void CModelFrame::OnSaveSpectrBmp() { // TODO: Add your command handler code here //MessageBox("ghghghgh"); SaveBmp(); }
/* save file in selected format, free data received from video decoder */ bool CScreenShot::SaveFile() { bool ret = true; switch (format) { case FORMAT_PNG: ret = SavePng(); break; default: printf("CScreenShot::SaveFile unsupported format %d, using jpeg\n", format); case FORMAT_JPG: ret = SaveJpg(); break; case FORMAT_BMP: ret = SaveBmp(); break; } cs_free_uncached((void *) pixel_data); return ret; }
void CSpectrumFrame::OnSaveSpectrBmp() { // TODO: Add your command handler code here SaveBmp(); }
// // 函数: WndProc(HWND, UINT, WPARAM, LPARAM) // // 目的: 处理主窗口的消息。 // // WM_COMMAND - 处理应用程序菜单 // WM_PAINT - 绘制主窗口 // WM_DESTROY - 发送退出消息并返回 // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; LOGBRUSH brush; brush.lbStyle = BS_NULL; HBRUSH hBrush = CreateBrushIndirect(&brush); LOGPEN pen; POINT penWidth; penWidth.x = 2; penWidth.y = 2; int color[7][3] = { { 254, 67, 101 }, { 217, 104, 49 }, { 250, 227, 113 }, { 131, 175, 155 }, { 69, 137, 148 }, { 1, 77, 103 }, { 89, 61, 67 } }; pen.lopnColor = RGB(color[rown][0], color[rown][1], color[rown][2]); timess = timess + 1; if (timess == TIMESS) { rown = rown + 1; timess = 0; } if (rown == 6) rown = -0; pen.lopnStyle = PS_SOLID; pen.lopnWidth = penWidth; HPEN hPen = CreatePenIndirect(&pen); switch (message) { case WM_TRAY: switch (lParam) { case WM_RBUTTONDOWN: { //获取鼠标坐标 POINT pt; GetCursorPos(&pt); //解决在菜单外单击左键菜单不消失的问题 SetForegroundWindow(hWnd); //使菜单某项变灰 //EnableMenuItem(hMenu, ID_SHOW, MF_GRAYED); //显示并获取选中的菜单 int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, NULL, hWnd, NULL); if (cmd == ID_SHOW) MessageBox(hWnd, L"Win32 API 实现系统托盘程序", L"托盘程序", MB_OK); if (cmd == ID_EXIT) PostMessage(hWnd, WM_DESTROY, NULL, NULL); } break; case WM_LBUTTONDOWN: MessageBox(hWnd, L"Win32 API 实现系统托盘程序", L"托盘程序", MB_OK); break; case WM_LBUTTONDBLCLK: break; } break; case WM_TIMER: ShowTrayMsg(); KillTimer(hWnd, wParam); break; case WM_COPYDATA: if (wParam == -1 && lParam == -1) { GetScreenCapture(); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); } case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // 分析菜单选择: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: //GetScreenCapture(); break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); HDC memDc = CreateCompatibleDC(hdc); HBITMAP bmp = CreateCompatibleBitmap(hdc, screenW, screenH); SelectObject(memDc, bmp); BitBlt(memDc, 0, 0, screenW, screenH, g_grayMemDc, 0, 0, SRCCOPY); SelectObject(memDc, hBrush); SelectObject(memDc, hPen); if (isDrawing || isSelect) { BitBlt(memDc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, g_srcMemDc, rect.left, rect.top, SRCCOPY); Rectangle(memDc, rect.left, rect.top, rect.right, rect.bottom); } BitBlt(hdc, 0, 0, screenW, screenH, memDc, 0, 0, SRCCOPY); DeleteObject(bmp); DeleteObject(memDc); EndPaint(hWnd, &ps); } break; case WM_LBUTTONDOWN: { if (!isSelect) { POINT pt; GetCursorPos(&pt); rect.left = pt.x; rect.top = pt.y; rect.right = pt.x; rect.bottom = pt.y; isDrawing = true; InvalidateRgn(hWnd, 0, false); } } break; case WM_LBUTTONUP: { if (isDrawing && !isSelect) { isDrawing = false; POINT pt; GetCursorPos(&pt); rect.right = pt.x; rect.bottom = pt.y; isSelect = true; InvalidateRgn(hWnd, 0, false); } } break; case WM_MOUSEMOVE: { if (isDrawing&& !isSelect) { POINT pt; GetCursorPos(&pt); rect.right = pt.x; rect.bottom = pt.y; InvalidateRgn(hWnd, 0, false); } } break; case WM_LBUTTONDBLCLK: { if (isSelect) { WriteDatatoClipBoard(); InvalidateRgn(hWnd, 0, false); ShowWindow(hWnd, SW_HIDE); //ShowWindow(hWnd, SW_MINIMIZE); TCHAR MyDir[_MAX_PATH]; SHGetSpecialFolderPath(hWnd, MyDir, CSIDL_DESKTOP, 0); //获取特殊路径,获取桌面路径 CString str; str.Format(_T("%s"), MyDir); CString depart = "\\"; CString lkuohao = "("; CString rkuohao = ")"; CString name = SHOT_NAME; CString cstype = SHOT_TYPE; //cstring to char* CString strPath = str + depart + name + cstype; //char *path = (LPSTR)(LPCTSTR)cstr; //CString strPath = L"C:\\Users\\Wayne\\Desktop\\2015年最新软件进展\\call_log.csv"; int nLength = strPath.GetLength(); int nBytes = WideCharToMultiByte(CP_ACP, 0, strPath, nLength, NULL, 0, NULL, NULL); char* VoicePath = new char[nBytes + 1]; memset(VoicePath, 0, nLength + 1); WideCharToMultiByte(CP_OEMCP, 0, strPath, nLength, VoicePath, nBytes, NULL, NULL); VoicePath[nBytes] = 0; //strPath *VoicePath int woc = 2; CString woca; CString cstrn = strPath; while (_access(VoicePath, 0) == 0) { woca.Format(_T("%d"), woc); cstrn = strPath + lkuohao + woca + rkuohao + cstype; //判断有没有~ int n2Length = cstrn.GetLength(); int n2Bytes = WideCharToMultiByte(CP_ACP, 0, cstrn, n2Length, NULL, 0, NULL, NULL); VoicePath = new char[n2Bytes + 1]; memset(VoicePath, 0, n2Length + 1); WideCharToMultiByte(CP_OEMCP, 0, cstrn, n2Length, VoicePath, n2Bytes, NULL, NULL); VoicePath[n2Bytes] = 0; woc++; } SaveBmp(hBmp, cstrn); //使用下面的函数 } isSelect = false; } break; case WM_DESTROY: {//窗口销毁时删除托盘 Shell_NotifyIcon(NIM_DELETE, &nid); UNINSPROC uninstproc; uninstproc = (UNINSPROC)GetProcAddress(m_hDll, "UnInstallHook"); BOOL bResult = uninstproc(); ::FreeLibrary(m_hDll); m_hDll = NULL; PostQuitMessage(0); break; } default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK captureProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_CREATE: { if( !setTransparentWindow( hwnd, 60 ) ) { MessageBox( NULL, _T( "Set transparent window failed!" ), _T( "Failed" ), MB_OK ); } } return 0; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = ::BeginPaint( hwnd, &ps ); ::EndPaint( hwnd, &ps ); return 0; } case WM_KEYDOWN: { switch( wParam ) { case VK_ESCAPE: lClickNum = 0; SendMessage( capHwnd, WM_DESTROY, wParam, lParam ); break; default: break; } } return 0; case WM_RBUTTONDOWN: { wchar_t bmp_file[] = { ' ', '.', 'b', 'm', 'p', '\0' }; bmp_file[0] = bmp_index++; GetWindowRect( capHwnd, &captureCoord ); if( !SaveBmp( CopyDCToBitmap( GetDC( GetDesktopWindow() ), &captureCoord ), bmp_file ) ) { MessageBox( NULL, _T( "Create bitmap failed!" ), _T( "Failed" ), MB_OK ); } else { MessageBox( NULL, _T( "Create bitmap successfully!" ), _T( "Succeed" ), MB_OK ); } } return 0; case WM_NCHITTEST: { UINT nHitTest; nHitTest = ::DefWindowProc(hwnd,msg,wParam,lParam); //如果鼠标左键按下, GetAsyncKeyState 的返回值小于0 if(nHitTest == HTCLIENT && ::GetAsyncKeyState(MK_LBUTTON) < 0) { nHitTest = HTCAPTION; } return nHitTest; } case WM_DESTROY: { PostQuitMessage( 0 ); } return 0; default: return DefWindowProc( hwnd, msg, wParam, lParam ); } }
// 播放视频流 void CAVPlay::ProcessPlayAV(DWORD dwAVId) { try { int nDeLen = 0; int nPos = sizeof(BLOCKEX); BYTE *pbyData = NULL; DWORD dwTime = 0; PPLAYINFO pPlayInfo = NULL; if (!m_mapPlayAV.Lookup(dwAVId, pPlayInfo)) return; while (NULL != m_hExit) { PPACK pFrame = (PPACK)pPlayInfo->AVList.GetHead(TRUE); if (NULL != pFrame) { if (!pPlayInfo->bPlay) // 不是连接播放 { dwTime = pFrame->dwId - pPlayInfo->dwLastTime; pPlayInfo->bPlay = TRUE; pPlayInfo->dwLastTime = pFrame->dwId; } else { dwTime = (pFrame->dwId) - (pPlayInfo->dwLastTime); if ((dwTime > 100) || (pPlayInfo->AVList.GetCount() > 10)) dwTime = 0; ::Sleep(dwTime); pPlayInfo->dwLastTime = pFrame->dwId; } if (VIDEO == pFrame->wProtoNum) { nDeLen = 0; pbyData = pPlayInfo->H264.Decode(&pFrame->byData[nPos], pFrame->dwDataLen-nPos, nDeLen); ::DrawDibDraw(DRAWH264); // 显示视频 if (pPlayInfo->bShowBigVideo) ::DrawDibDraw(DRAWBIGH264); // 显示大个视频 if (pPlayInfo->bSaveImage) SaveBmp(pPlayInfo, pbyData); // 保存图片 if (pPlayInfo->bSaveAV) SaveAV(VIDEO, &(pPlayInfo->File), dwTime, &pFrame->byData[nPos], pFrame->dwDataLen-nPos);// 保存文件 m_pSubBuffPool->Free(pFrame); } else if (VIDEO_BIG == pFrame->wProtoNum) { pbyData = pPlayInfo->H264.Decode(pFrame->byData, pFrame->dwDataLen, nDeLen); ::DrawDibDraw(DRAWH264); if (pPlayInfo->bShowBigVideo) ::DrawDibDraw(DRAWBIGH264); if (pPlayInfo->bSaveImage) SaveBmp(pPlayInfo, pbyData); if (pPlayInfo->bSaveAV) SaveAV(VIDEO, &(pPlayInfo->File), dwTime, pFrame->byData, pFrame->dwDataLen); m_pBigBuffPool->Free(pFrame); } else { m_G729.Decode((char*)&(pFrame->byData[8]), pFrame->dwDataLen - 8, m_szAudio, &nDeLen); m_WaveOut.Play(m_szAudio, nDeLen); if (pPlayInfo->bSaveAV) SaveAV(AUDIO, &(pPlayInfo->File), dwTime, (PBYTE)&(pFrame->byData[8]), pFrame->dwDataLen-8); m_pSubBuffPool->Free(pFrame); } } else { pPlayInfo->bPlay = FALSE; // 无数据暂时停止播放 ::Sleep(10); } } } catch(...) { TRACE(_T("ProcessPlayAV error:%d\n"), ::GetLastError()); } }