BOOL CALLBACK DlgProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { switch( message ) { case WM_INITDIALOG: return OnInitDlg( hDlg ); case WM_CLOSE: { OnCloseDialog( hDlg, wParam ); } break; } return FALSE; }
INT_PTR Dialog::DlgWndProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return OnInitDlg(wParam, lParam); case WM_COMMAND: return OnCommand(wParam, lParam); case WM_NOTIFY: return OnNotify(wParam, lParam); case WM_TIMER: return OnTimer(wParam, lParam); case WM_CLOSE: return OnClose(wParam, lParam); case WM_DESTROY: return OnDestroy(wParam, lParam); case WM_SIZE: return OnSize(wParam, lParam); case WM_GETMINMAXINFO: return OnGetMinMaxInfo(wParam, lParam); } return (INT_PTR)FALSE; }
BOOL CALLBACK MainDlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: OnInitDlg(hwnd); return TRUE; case WM_RECORD_BEG: OnRecordBeg(hwnd, lParam); return TRUE; case WM_RECORD_END: OnRecordEnd(hwnd); return TRUE; case WM_BUILD_GMM: // 建立GMM及生成识别阈值 // 先结束录音 OnStopVoice(hwnd); OnBuildGMM(hwnd); DelVoiceFile(); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_VOICE_STOP: OnStopVoice(hwnd); DelVoiceFile(); return TRUE; case IDC_CLEAR_TEXT: OnClearBtn(hwnd); return TRUE; case IDC_RESET: OnResetBtn(hwnd); return TRUE; case IDC_IMPORT_GMM: OnImportGMMBtn(hwnd); return TRUE; case IDC_EXPORT_GMM: OnExportGMMBtn(hwnd); return TRUE; case IDC_BUILD_GMM: // 提取声纹按钮 UpdateDlg(hwnd, IDC_BUILD_GMM); OnBuildBtn(hwnd); return TRUE; case IDC_IDENTIFY: // 身份验证 UpdateDlg(hwnd, IDC_IDENTIFY); OnIdentifyBtn(hwnd); return TRUE; case IDCANCEL: // 关闭对话框 g_buildGMM = FALSE; my_voiceprint.voice_mdl.gmm.f_FreeGMM(&my_voiceprint.voice_mdl.gmm); QuitMyWindow(); return TRUE; } // switch (LOWORD(wParam)) break; case WM_SYSCOMMAND: switch (LOWORD(wParam)) { case SC_CLOSE: SendMessage(hwnd, WM_COMMAND, IDCANCEL, 0); return TRUE; } break; } return FALSE; }
// Message handler for Dialog INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { if (message == RegisterWindowMessage(L"TaskbarCreated") && !IsWindowVisible(hDlg)) { Minimize(hDlg); return (INT_PTR)TRUE; } TCHAR buffer[MAX_LOADSTRING]; INT tmp; switch (message) { case WM_INITDIALOG: OnInitDlg(hDlg); InstallCtrlMouseHook(hDlg); InstallHook_Draw(hDlg); SetNumTimeReplay(REPLAYTIME); //Set Icon for Dialog SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1))); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1))); return (INT_PTR)TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: DestroyWindow(hDlg); return (INT_PTR)TRUE; case IDC_BUTTONAPPLY: UpdateData(DIRECTION, BUTTON, SPEED); SetNumTimeReplay(REPLAYTIME); EnableWindow(GetDlgItem(hMainDlg, IDC_BUTTONAPPLY), FALSE); Minimize(hDlg); SaveSettings(); return (INT_PTR)TRUE; case IDC_AUTORUN: if (Button_GetCheck(GetDlgItem(hDlg, IDC_AUTORUN))) SetAutoRun(), AUTORUN = 1, SaveSettings(); else OffAutoRun(), AUTORUN = 0, SaveSettings(); break; case IDC_EDITSPEED: if (HIWORD(wParam) != EN_CHANGE) break; Edit_GetText(GetDlgItem(hDlg, IDC_EDITSPEED), buffer, MAX_LOADSTRING); tmp = _wtoi(buffer); if (tmp > 0 && tmp <= 10000000) EnableWindow(GetDlgItem(hMainDlg, IDC_BUTTONAPPLY), TRUE), SPEED = tmp; else EnableWindow(GetDlgItem(hMainDlg, IDC_BUTTONAPPLY), FALSE); return (INT_PTR)TRUE; case IDC_EDITREPLAY: if (HIWORD(wParam) != EN_CHANGE) break; Edit_GetText(GetDlgItem(hDlg, IDC_EDITREPLAY), buffer, MAX_LOADSTRING); tmp = _wtoi(buffer); if (tmp > 0 && tmp <= 10000000) EnableWindow(GetDlgItem(hMainDlg, IDC_BUTTONAPPLY), TRUE), REPLAYTIME = tmp; else EnableWindow(GetDlgItem(hMainDlg, IDC_BUTTONAPPLY), FALSE); } break; case WM_KEYDOWN: if (wParam == VK_CONTROL && active) if (!draw) { hWndDraw = CreateWindow(L"WindowDraw", NULL, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL); SetWindowPos(hWndDraw, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); draw = TRUE; GetHWND(hWndDraw); SetWindowLong(hWndDraw, GWL_EXSTYLE, GetWindowLong(hWndDraw, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(hWndDraw, 0, 255, LWA_ALPHA); RECT rect; SetWindowPos(hWndDraw, NULL, 0, 0, GetDeviceCaps(GetDC(NULL), HORZRES), GetDeviceCaps(GetDC(NULL), VERTRES), SWP_FRAMECHANGED); GetWindowRect(hWndDraw, &rect); HRGN hrgn; hrgn = CreateRectRgn(0, 32, GetDeviceCaps(GetDC(NULL), HORZRES), GetDeviceCaps(GetDC(NULL), VERTRES) - 32); SetWindowRgn(hWndDraw, hrgn, true); ShowWindow(hWndDraw, SW_MAXIMIZE); } else { ShowWindow(hWndDraw, SW_HIDE); draw = FALSE; hWndDraw = NULL; } break; case WM_CLOSE: Minimize(hDlg); active = TRUE; return (INT_PTR)TRUE; case WM_TRAYICON: if (wParam == TRAY_ICON_ID && lParam == WM_LBUTTONUP){ Restore(hDlg); active = FALSE; } return (INT_PTR)TRUE; case WM_DESTROY: UninstallCtrlMouseHook(); UninstallHook_Draw(); PostQuitMessage(0); return (INT_PTR)TRUE; } return (INT_PTR)FALSE; }