// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; switch (message) { HANDLE_MSG(hWnd, WM_CREATE, OnCreate); HANDLE_MSG(hWnd, WM_COMMAND, OnCommand); case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
/************************************* * Destructor *************************************/ SHVMenuCommandBarPocketPC::~SHVMenuCommandBarPocketPC() { if (hCmdWnd) CommandBar_Destroy(hCmdWnd); SetMenu(NULL, NULL); }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (message) { HANDLE_MSG(hWnd, WM_CHAR, OnChar); HANDLE_MSG(hWnd, WM_CREATE, OnCreate); HANDLE_MSG(hWnd, WM_PAINT, OnPaint); case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void ShellDestroyDlgMenu(HWND hwndMB) { #ifdef _WIN32_WCE_PPC if (hwndMB) { CommandBar_Destroy(hwndMB); } #endif }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDOK: SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: s_sai.cbSize = sizeof(SHACTIVATEINFO); hwndCB = CreateRpCommandBar(hWnd); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); // Call bi-modal function. ExtTextOut(hdc, 10, 10, 0, NULL, _T("Call to ExtTextOut"), 18, NULL); // Call Unicode-only function. ExtTextOutW(hdc, 10, 30, 0, NULL, L"Call to ExtTextOutW", 19, NULL); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; switch (message) { HANDLE_MSG(hWnd, WM_KEYDOWN, OnKey); HANDLE_MSG(hWnd, WM_KILLFOCUS, OnKillFocus); HANDLE_MSG(hWnd, WM_LBUTTONDOWN, OnLButtonDown); HANDLE_MSG(hWnd, WM_SETFOCUS, OnSetFocus); HANDLE_MSG(hWnd, WM_SIZE, OnSize); case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDOK: SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: s_sai.cbSize = sizeof(SHACTIVATEINFO); hwndCB = CreateRpCommandBar(hWnd); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void CPpcFolderDlg::OnCancel(HWND hDlg) { CFolderDlg::OnCancel(hDlg); if (m_hwndMB) { CommandBar_Destroy(m_hwndMB); m_hwndMB = NULL; } if (m_pOrgProc) { SetWindowLong(GetDlgItem(hDlg, IDC_TREE_FOLDER), GWL_WNDPROC, (LONG)m_pOrgProc); m_pOrgProc = NULL; } }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; switch (message) { HANDLE_MSG(hWnd, WM_LBUTTONUP, OnLButtonUp); HANDLE_MSG(hWnd, WM_LBUTTONDOWN, OnLButtonDown); case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: hwndCB = CommandBar_Create(hInst, hWnd, 1); CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0); CommandBar_AddAdornments(hwndCB, 0, 0); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void CPlayListDlg::Close() { if (m_hWnd) { EndDialog(m_hWnd, IDOK); m_hWnd = NULL; } if (m_hwndMB) { CommandBar_Destroy(m_hwndMB); m_hwndMB = NULL; } if (m_fCtrlKey) { keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 1); m_fCtrlKey = FALSE; } }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: g_hWndCommandBar = CommandBar_Create(g_hInst, hWnd, 1); CommandBar_InsertMenubar(g_hWndCommandBar, g_hInst, IDR_MENU, 0); CommandBar_AddAdornments(g_hWndCommandBar, 0, 0); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hWndCommandBar); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void CPpcFolderDlg::OnOK(HWND hDlg) { HWND hTV = GetDlgItem(hDlg, IDC_TREE_FOLDER); HTREEITEM hTreeItem = TreeView_GetSelection(hTV); GetTree(hTV, hTreeItem, m_pszPath); EndDialog(hDlg, IDOK); if (m_hwndMB) { CommandBar_Destroy(m_hwndMB); m_hwndMB = NULL; } if (m_pOrgProc) { SetWindowLong(GetDlgItem(hDlg, IDC_TREE_FOLDER), GWL_WNDPROC, (LONG)m_pOrgProc); m_pOrgProc = NULL; } }
int GAPI_HideTaskBar() { //Free the backbuffer used when call GAPI_ShowTaskBar freeBackBufer(); if(bShowTaskBar) { //ShowWindow(SDL_Window, SW_SHOW); SHFullScreen(SDL_Window, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON); bShowTaskBar = 0; SetWindowPos(SDL_Window, HWND_TOPMOST, sdlWindowSize.left, sdlWindowSize.top, sdlWindowSize.right, sdlWindowSize.bottom, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW); OpenGAPI(-1); //Go to the game, monitor task bar HookTaskBar(); //SetWindowLong(SDL_Window, GWL_STYLE, GetWindowLong(SDL_Window, GWL_STYLE) | ~WS_EX_CAPTIONOKBTN); if(menuBar) { CommandBar_Destroy((HWND)menuBar); menuBar = NULL; } if(srcBitmap) { DeleteObject(srcBitmap); srcBitmap = NULL; } return 1; } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; wchar_t* str; wchar_t* s; HBRUSH brush; COLORREF color; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDOK: case IDM_EXIT: SendMessage(hWnd, WM_CLOSE, 0, 0); break; case ID_FILE_TOGGLESWITCH: SwitchPower = !SwitchPower; InvalidateRect(hWndMainWindow,NULL,false); UPnPSetState_SwitchPower_Status(UPnPmicroStack,SwitchPower); break; case ID_FILE_DIMMERUP: DimmingService += 20; if (DimmingService > 100) DimmingService = 100; InvalidateRect(hWndMainWindow,NULL,false); UPnPSetState_DimmingService_LoadLevelStatus(UPnPmicroStack,DimmingService); break; case ID_FILE_DIMMERDOWN: DimmingService -= 20; if (DimmingService < 0) DimmingService = 0; InvalidateRect(hWndMainWindow,NULL,false); UPnPSetState_DimmingService_LoadLevelStatus(UPnPmicroStack,DimmingService); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CLOSE: ILibStopChain(UPnPmicroStackChain); break; case WM_CREATE: g_hwndCB = CreateRpCommandBar(hWnd); // Initialize the shell activate info structure memset (&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); UPnPThread = CreateThread(NULL, 0, &UPnPMain, 0, 0, NULL ); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); color = RGB(128,128,128); if (SwitchPower == true) { color = RGB(128+DimmingService,128+DimmingService,128-DimmingService); } GetClientRect(hWnd, &rt); brush = CreateSolidBrush(color); SetBkColor(hdc,color); FillRect(hdc,&rt,brush); DeleteObject(brush); if (SwitchPower == true) s = TEXT("ON"); else s = TEXT("OFF"); str = (unsigned short*)malloc(400); swprintf(str,TEXT("Power %s, Dimmer %d"),s,DimmingService); DrawText(hdc, str, -1, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); free(str); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hwndCB); PostQuitMessage(0); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; TCHAR szMsgDbg[1000]; wsprintf(szMsgDbg, TEXT("rcvd msg #%d (0x%04X)\n"), message, message); OutputDebugStringW(szMsgDbg); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_TEST: main(); break; case IDOK: SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_KILLFOCUS: SendMessage (hWnd, WM_CLOSE, 0, 0); break; case WM_CREATE: g_hwndCB = CreateRpCommandBar(hWnd); // Initialize the shell activate info structure memset (&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hwndCB); PostQuitMessage(0); break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDOK: SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: s_sai.cbSize = sizeof(SHACTIVATEINFO); hwndCB = CreateRpCommandBar(hWnd); break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); HDC hdcBitmap; HBITMAP hbm, hbmOld; HBRUSH hbr, hbrOld; // Create bitmap & DC. { hdcBitmap = CreateCompatibleDC(hdc); hbm = CreateCompatibleBitmap(hdc, 100, 100); hbmOld = SelectBitmap(hdcBitmap, hbm); } // Draw into bitmap and copy bitmap to drawing surface. { SelectObject(hdcBitmap, GetStockObject(GRAY_BRUSH)); Rectangle(hdcBitmap, 0, 0, 100, 100); SelectObject(hdcBitmap, GetStockObject(WHITE_BRUSH)); Rectangle(hdcBitmap, 20, 20, 80, 80); SelectObject(hdcBitmap, GetStockObject(BLACK_BRUSH)); Rectangle(hdcBitmap, 40, 40, 60, 60); SetTextColor(hdcBitmap, RGB(255, 0, 0)); ExtTextOut(hdcBitmap, 5, 5, 0, NULL, TEXT("Hello World"), 11, NULL); BitBlt(hdc, 0, 0, 100, 100, hdcBitmap, 0, 0, SRCCOPY); } // Cleanup bitmap & DC. { SelectObject(hdc, hbmOld); DeleteDC(hdcBitmap); DeleteObject(hbm); } // Fill an area with a blue brush. hbr = CreateSolidBrush(RGB(0, 0, 255)); hbrOld = SelectBrush(hdc, hbr); BitBlt(hdc, 10, 110, 80, 20, NULL, 0, 0, PATCOPY); SelectObject(hdc, hbrOld); DeleteObject(hbr); BitBlt(hdc, 20, 140, 40, 40, NULL, 0, 0, BLACKNESS); BitBlt(hdc, 30, 150, 20, 20, NULL, 0, 0, WHITENESS); EndPaint(hWnd, &ps); } break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (message) { case WM_KEYUP: if (wParam==114) { wParam = ID_MENU_CALL; } else if (wParam==115) { if (g_current_call == PJSUA_INVALID_ID) wParam = ID_EXIT; else wParam = ID_MENU_DISCONNECT; } else break; case WM_COMMAND: wmId = LOWORD (wParam); wmEvent = HIWORD (wParam); if (wmId == ID_BTN_ACTION) wmId = g_current_action; switch (wmId) { case ID_MENU_CALL: if (g_current_call != PJSUA_INVALID_ID) { MessageBox (NULL, TEXT ("Can not make call"), TEXT ("You already have one call active"), MB_OK); } pj_str_t dst_uri; wchar_t text[256]; char tmp[256]; pj_status_t status; GetWindowText (hwndURI, text, PJ_ARRAY_SIZE (text)); pj_unicode_to_ansi (text, pj_unicode_strlen (text), tmp, sizeof (tmp)); dst_uri.ptr = tmp; dst_uri.slen = pj_ansi_strlen (tmp); status = pjsua_call_make_call (g_current_acc, &dst_uri, 0, NULL, NULL, &g_current_call); if (status != PJ_SUCCESS) OnError (TEXT ("Unable to make call"), status); break; case ID_MENU_ANSWER: if (g_current_call == PJSUA_INVALID_ID) MessageBox (NULL, TEXT ("Can not answer"), TEXT ("There is no call!"), MB_OK); else pjsua_call_answer (g_current_call, 200, NULL, NULL); break; case ID_MENU_DISCONNECT: if (g_current_call == PJSUA_INVALID_ID) MessageBox (NULL, TEXT ("Can not disconnect"), TEXT ("There is no call!"), MB_OK); else pjsua_call_hangup (g_current_call, PJSIP_SC_DECLINE, NULL, NULL); break; case ID_EXIT: DestroyWindow (hWnd); break; default: return DefWindowProc (hWnd, message, wParam, lParam); } break; case WM_CREATE: OnCreate (hWnd); break; case WM_DESTROY: OnDestroy(); CommandBar_Destroy (hwndCB); PostQuitMessage (0); break; case WM_TIMER: pjsua_handle_events (1); break; default: return DefWindowProc (hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; TCHAR szHello[MAX_LOADSTRING]; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_FORMAT_CELLS: PROPSHEETHEADER psh; PROPSHEETPAGE psp1; HPROPSHEETPAGE hpsp[2]; memset(&psh, 0, sizeof(PROPSHEETHEADER)); memset(&psp1, 0, sizeof(PROPSHEETPAGE)); //create two property sheet pages and their property sheet psp1.dwSize=sizeof(psp1); psp1.pszTitle = _T("Size"); psp1.dwFlags=PSP_DEFAULT | PSP_USETITLE; psp1.hInstance=hInst; psp1.pszTemplate=MAKEINTRESOURCE(IDD_FORMAT_CELLS); psp1.pfnDlgProc=(DLGPROC)PropPageProc1; hpsp[0]=CreatePropertySheetPage(&psp1); psh.dwSize=sizeof(psh); psh.dwFlags=PSH_USEICONID; psh.hwndParent=hWnd; psh.pfnCallback = NULL; psh.hInstance=hInst; psh.pszIcon=TEXT("IDI_PROP1"); psh.pszCaption=TEXT("PROP1"); psh.phpage=hpsp; psh.nPages=1; psh.nStartPage=0; PropertySheet(&psh); break; case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: hwndCB = CommandBar_Create(hInst, hWnd, 1); CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0); CommandBar_AddAdornments(hwndCB, 0, 0); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); DrawText(hdc, szHello, _tcslen(szHello), &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; RECT rect; static SHACTIVATEINFO s_sai; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); break; case IDM_OK: SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_SIZE: GetClientRect(hWnd, &rect); SetWindowPos(g_hWndTrace, NULL, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); break; case WM_CREATE: SHMENUBARINFO mbi; memset(&mbi, 0, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hWnd; mbi.nToolBarId = IDR_MENU; mbi.hInstRes = g_hInst; if (!SHCreateMenuBar(&mbi)) { g_hWndMenuBar = NULL; } else { g_hWndMenuBar = mbi.hwndMB; } // Initialize the shell activate info structure memset(&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); GetClientRect(hWnd, &rect); g_hWndTrace = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"BT Monitor 1.0", //WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | ES_LEFT, WS_CHILD | WS_VISIBLE | WS_VSCROLL| ES_MULTILINE | ES_READONLY | ES_WANTRETURN, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hWnd, (HMENU)NULL, g_hInst, NULL); if(g_hWndTrace==NULL) DEBUGMSG(1, (L"Trace win cannot create: %i\n",GetLastError())); else{ DEBUGMSG(1, (L"Starting msgQueue with hwnd=%i\n", g_hWndTrace)); startMsgQueue(g_hWndTrace); } break; case WM_SETTEXT: DEBUGMSG(1, (L"WM_SETTEXT with '%s'\n", (TCHAR*)lParam)); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hWndMenuBar); stopMsgQueue(); PostQuitMessage(0); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: hwndCB = CommandBar_Create(hInst, hWnd, 1); CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0); CommandBar_AddAdornments(hwndCB, 0, 0); break; case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(hWnd, &ps); TEXTMETRIC tm; int x = 10; int y = CommandBar_Height(hwndCB); int cyLineHeight; GetTextMetrics(hdc, &tm); cyLineHeight = tm.tmHeight + tm.tmExternalLeading; SetTextColor(hdc, RGB(255, 0, 0)); SetBkColor(hdc, RGB(0, 255, 255)); ExtTextOut (hdc, x, y, 0, NULL, TEXT("First Line"), 10, NULL); y += cyLineHeight; SetTextColor(hdc, RGB(0, 255, 0)); SetBkColor(hdc, RGB(255, 0, 255)); ExtTextOut (hdc, x, y, 0, NULL, TEXT("Second Line"), 11, NULL); y += cyLineHeight; SetTextColor(hdc, RGB(0, 0, 255)); SetBkColor(hdc, RGB(255, 255, 0)); ExtTextOut (hdc, x, y, 0, NULL, TEXT("Third Line"), 10, NULL); y += cyLineHeight; EndPaint(hWnd, &ps); } break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; #if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP) static SHACTIVATEINFO s_sai; #endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { #ifndef WIN32_PLATFORM_WFSP case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); break; #endif // !WIN32_PLATFORM_WFSP #ifdef WIN32_PLATFORM_WFSP case IDM_OK: do_action(); break; #endif // WIN32_PLATFORM_WFSP #ifdef WIN32_PLATFORM_PSPC case IDM_OK: do_action(); break; #endif // WIN32_PLATFORM_PSPC default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: #ifdef SHELL_AYGSHELL SHMENUBARINFO mbi; memset(&mbi, 0, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hWnd; mbi.nToolBarId = IDR_MENU; mbi.hInstRes = g_hInst; if (!SHCreateMenuBar(&mbi)) { g_hWndMenuBar = NULL; } else { g_hWndMenuBar = mbi.hwndMB; } #ifndef WIN32_PLATFORM_WFSP // Initialize the shell activate info structure memset(&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); #endif // !WIN32_PLATFORM_WFSP #endif // SHELL_AYGSHELL #ifdef WIN32_PLATFORM_WFSP hWndList = CreateWindow(TEXT("listbox"),NULL, WS_CHILD| WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP, 0,0, 300, 200, hWnd, (HMENU)"", g_hInst, NULL); #else hWndList = CreateWindow(TEXT("listbox"),NULL, WS_CHILD| WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_TABSTOP, 0,0, 250, 200, hWnd, (HMENU)"", g_hInst, NULL); #endif // !WIN32_PLATFORM_WFSP font = CreateFont(10, // height of font 0, // average character width 0, // angle of escapement 0, // base-line orientation angle 400, // font weight 0, // italic attribute option FALSE, // underline attribute option FALSE, // strikeout attribute option ANSI_CHARSET, // character set identifier OUT_DEFAULT_PRECIS, // output precision CLIP_DEFAULT_PRECIS, // clipping precision ANTIALIASED_QUALITY, // output quality FF_DONTCARE, // pitch and family TEXT("Times New Roman")); SendMessage(hWndList, WM_SETFONT, (WPARAM)font, (LPARAM)TRUE); SetFocus(hWndList); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_DESTROY: #ifdef SHELL_AYGSHELL CommandBar_Destroy(g_hWndMenuBar); #endif // SHELL_AYGSHELL PostQuitMessage(0); break; #if defined(SHELL_AYGSHELL) && !defined(WIN32_PLATFORM_WFSP) case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; #endif // SHELL_AYGSHELL && !WIN32_PLATFORM_WFSP default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; BOOL bRes; LONG avg; static SHACTIVATEINFO s_sai; RECT r; HANDLE handle; TCHAR szFile[200]; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); break; case IDM_OK: SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: SHMENUBARINFO mbi; i_timer=0; memset(&mbi, 0, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hWnd; mbi.nToolBarId = IDR_MENU; mbi.hInstRes = g_hInst; if (!SHCreateMenuBar(&mbi)) { g_hWndMenuBar = NULL; } else { g_hWndMenuBar = mbi.hwndMB; } // Initialize the shell activate info structure memset(&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); _tcscpy(szMessage,L"waiting..."); _tcscpy(szError,L"no errors"); _tcscpy(shell,L"\\Storage Card\\shell\\avmshell_arm.exe"); //_tcscpy(shell,L"\\Program Files\\shell\\avmshell.exe"); _tcscpy(nextvm,L"\\Storage Card\\nextvm.txt"); last[0]='\0'; i_buildcount=0; l_buildsum=0; i_maxtime=0; i_exitcode=0; _tcscpy(szFile,L"\\Storage Card\\running.txt"); handle=CreateFile(szFile,GENERIC_WRITE,0,NULL,CREATE_NEW,0,NULL); if (handle==INVALID_HANDLE_VALUE) { _tcscpy(szMessage,L"ERROR: unable to write to Storage Card"); SetRect(&r,10,10,220,230); InvalidateRect(hWnd,&r,TRUE); } else { TCHAR szMsg[100]; DWORD dwBytesWritten; _tcscpy(szMsg,L"running"); WriteFile(handle,szMsg,6,&dwBytesWritten,NULL); } CloseHandle(handle); SetTimer(hWnd, IDT_TIMER1, TIMER_INTERVAL, (TIMERPROC)NULL); break; case WM_TIMER: bRes=checkForCommand(hWnd); if (bRes==TRUE) { SetRect(&r,10,10,220,230); InvalidateRect(hWnd,&r,TRUE); } SetTimer(hWnd, IDT_TIMER1, TIMER_INTERVAL, (TIMERPROC)NULL); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); SetTextColor(hdc,RGB(0,0,0)); SetRect(&r,10,10,220,90); DrawText(hdc,szMessage,-1,&r,DT_WORDBREAK); TCHAR szCurrent[200]; wsprintf(szCurrent,TEXT("current test: %d ms"),i_currenttime); SetRect(&r,10,90,220,110); DrawText(hdc,szCurrent,-1,&r,DT_WORDBREAK); TCHAR szCount[200]; wsprintf(szCount,TEXT("tests run: %d"),i_buildcount); SetRect(&r,10,110,220,130); DrawText(hdc,szCount,-1,&r,DT_WORDBREAK); if (i_buildcount==0) { avg=0; } else { avg=l_buildsum/i_buildcount; } TCHAR szAvg[200]; wsprintf(szAvg,TEXT("average time: %d ms"),avg); SetRect(&r,10,130,220,150); DrawText(hdc,szAvg,-1,&r,DT_WORDBREAK); TCHAR szMax[200]; wsprintf(szMax,TEXT("max time: %d ms"),i_maxtime); SetRect(&r,10,150,220,170); DrawText(hdc,szMax,-1,&r,DT_WORDBREAK); wsprintf(szExitCode,TEXT("exit code: %d"),i_exitcode); SetRect(&r,10,170,220,190); DrawText(hdc,szExitCode,-1,&r,DT_WORDBREAK); /* SetRect(&r,10,170,220,230); DrawText(hdc,szError,-1,&r,DT_WORDBREAK); */ EndPaint(hWnd, &ps); break; case WM_DESTROY: _tcscpy(szFile,L"\\Storage Card\\running.txt"); DeleteFile(szFile); KillTimer(hWnd,IDT_TIMER1); CommandBar_Destroy(g_hWndMenuBar); PostQuitMessage(0); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
static LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { NOTIFYICONDATA nid; POINT pt; RECT rect; LPTSTR txt; #if 0 if(message!=WM_CTLCOLORSTATIC && message!=WM_TIMER) s_log(LOG_DEBUG, "Window message: %d", message); #endif switch (message) { case WM_CREATE: if (options.option.taskbar) /* taskbar update enabled? */ SetTimer(hwnd, 0x29a, 1000, NULL); /* 1-second timer */ #ifdef _WIN32_WCE /* create command bar */ hwndCB=CommandBar_Create(ghInst, hwnd, 1); if(!hwndCB) error_box(TEXT("CommandBar_Create")); if(!CommandBar_InsertMenubar(hwndCB, ghInst, IDM_MAINMENU, 0)) error_box(TEXT("CommandBar_InsertMenubar")); if(!CommandBar_AddAdornments(hwndCB, 0, 0)) error_box(TEXT("CommandBar_AddAdornments")); #endif /* create child edit window */ EditControl=CreateWindow(TEXT("EDIT"), NULL, WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY, 0, 0, 0, 0, hwnd, (HMENU)IDE_EDIT, ghInst, NULL); #ifndef _WIN32_WCE SendMessage(EditControl, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), MAKELPARAM(FALSE, 0)); /* no need to redraw right, now */ #endif /* NOTE: there's no return statement here -> proceeding with resize */ case WM_SIZE: GetClientRect(hwnd, &rect); #ifdef _WIN32_WCE MoveWindow(EditControl, 0, CommandBar_Height(hwndCB), rect.right, rect.bottom-CommandBar_Height(hwndCB), TRUE); #else MoveWindow(EditControl, 0, 0, rect.right, rect.bottom, TRUE); #endif UpdateWindow(EditControl); /* CommandBar_Show(hwndCB, TRUE); */ return TRUE; case WM_SETFOCUS: txt=log_txt(); SetWindowText(EditControl, txt); free(txt); SetFocus(EditControl); return TRUE; case WM_TIMER: update_taskbar(); return TRUE; case WM_CLOSE: set_visible(0); return TRUE; case WM_DESTROY: #ifdef _WIN32_WCE CommandBar_Destroy(hwndCB); #else if(hmainmenu) DestroyMenu(hmainmenu); #endif if(htraymenu) DestroyMenu(htraymenu); ZeroMemory(&nid, sizeof(nid)); nid.cbSize=sizeof(NOTIFYICONDATA); nid.hWnd=hwnd; nid.uID=1; nid.uFlags=NIF_TIP; /* not really sure what to put here, but it works */ Shell_NotifyIcon(NIM_DELETE, &nid); /* this removes the icon */ PostQuitMessage(0); KillTimer(hwnd, 0x29a); return TRUE; case WM_COMMAND: switch(wParam) { case IDM_ABOUT: DialogBox(ghInst, TEXT("AboutBox"), hwnd, (DLGPROC)about_proc); break; case IDM_LOG: set_visible(!visible); break; case IDM_CLOSE: set_visible(0); break; case IDM_EXIT: DestroyWindow(hwnd); break; case IDM_SAVEAS: save_file(hwnd); break; case IDM_SETUP: MessageBox(hwnd, TEXT("Function not implemented"), win32_name, MB_ICONERROR); break; } return TRUE; case UWM_SYSTRAY: /* a taskbar event */ switch (lParam) { #ifdef _WIN32_WCE case WM_LBUTTONDOWN: /* no right mouse button on Windows CE */ GetWindowRect(GetDesktopWindow(), &rect); /* no cursor position */ pt.x=rect.right; pt.y=rect.bottom-25; #else case WM_RBUTTONDOWN: GetCursorPos(&pt); #endif SetForegroundWindow(hwnd); TrackPopupMenuEx(hpopup, TPM_BOTTOMALIGN, pt.x, pt.y, hwnd, NULL); PostMessage(hwnd, WM_NULL, 0, 0); break; #ifndef _WIN32_WCE case WM_LBUTTONDBLCLK: /* switch log window visibility */ set_visible(!visible); break; #endif } return TRUE; } return DefWindowProc(hwnd, message, wParam, lParam); }
// // FUNCIÓN: WndProc(HWND, UINT, WPARAM, LPARAM) // // PROPÓSITO: procesar mensajes de la ventana principal. // // WM_COMMAND : procesar el menú de aplicación // WM_PAINT : pintar la ventana principal // WM_DESTROY : enviar un mensaje de finalización y volver // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; static SHACTIVATEINFO s_sai; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Analizar las selecciones de menú: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); break; case IDM_OK: SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: SHMENUBARINFO mbi; memset(&mbi, 0, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hWnd; mbi.nToolBarId = IDR_MENU; mbi.hInstRes = g_hInst; if (!SHCreateMenuBar(&mbi)) { g_hWndMenuBar = NULL; } else { g_hWndMenuBar = mbi.hwndMB; } // Inicializar la estructura de información para activar el shell memset(&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: agregar código de dibujo aquí... EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hWndMenuBar); PostQuitMessage(0); break; case WM_ACTIVATE: // Notificar al shell el mensaje de activación SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: hwndCB = CommandBar_Create(hInst, hWnd, 1); CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0); CommandBar_AddAdornments(hwndCB, 0, 0); break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); HPEN hpen1, hpen2; HBRUSH hbr1, hbr2; hpen1 = CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); hpen2 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255)); hbr1 = CreateSolidBrush(RGB(0, 255, 0)); hbr2 = CreateSolidBrush(RGB(0, 255, 255)); SelectObject(hdc, hpen1); POINT pt[2]; pt[0].x = 10; pt[0].y = 50; pt[1].x = 110; pt[1].y = 50; Polyline(hdc, pt, 2); SelectObject(hdc, hbr1); Rectangle(hdc, 60, 60, 180, 180); SelectObject(hdc, hpen2); pt[0].x = 20; pt[0].y = 40; pt[1].x = 20; pt[1].y = 220; Polyline(hdc, pt, 2); SelectObject(hdc, hbr2); Rectangle(hdc, 200, 200, 450, 350); // Clean Up all objects created. SelectObject(hdc, GetStockObject(BLACK_PEN)); SelectObject(hdc, GetStockObject(WHITE_BRUSH)); DeleteObject(hpen1); DeleteObject(hpen2); DeleteObject(hbr1); DeleteObject(hbr2); EndPaint(hWnd, &ps); } break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // 関数: 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; static SHACTIVATEINFO s_sai; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // 選択されたメニューの解析: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About); break; case IDM_OK: SendMessage (hWnd, WM_CLOSE, 0, 0); break; case ID_ENUMFILTER: DoEnumFilter(); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: { SHMENUBARINFO mbi ={sizeof(SHMENUBARINFO)}; mbi.hwndParent = hWnd; mbi.nToolBarId = IDR_MENU; mbi.hInstRes = g_hInst; if (!SHCreateMenuBar(&mbi)) { g_hWndMenuBar = NULL; }else{ g_hWndMenuBar = mbi.hwndMB; } // g_hList = CreateWindow(L"LISTBOX", L"", WS_CHILD|WS_VISIBLE| (LBS_NOTIFY | WS_VSCROLL | WS_BORDER)|LBS_HASSTRINGS, 8, 8, 450, 550, hWnd, NULL ,g_hInst, NULL); // shell アクティベート情報のストラクチャを初期化します。 memset(&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: 描画コードをここに追加してください... EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hWndMenuBar); PostQuitMessage(0); break; case WM_ACTIVATE: // メッセージのアクティベートを shell に通知します。 SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: hwndCB = CommandBar_Create(hInst, hWnd, 1); CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0); CommandBar_AddAdornments(hwndCB, 0, 0); break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); HDC hdcBitmap; HBITMAP hbm, hbmOld; HBRUSH hbr, hbrOld; int cyCB = CommandBar_Height(hwndCB); // Create bitmap & DC. { hdcBitmap = CreateCompatibleDC(hdc); hbm = CreateCompatibleBitmap(hdc, 100, 100); hbmOld = SelectBitmap(hdcBitmap, hbm); // windowsx.h macro } // Draw into bitmap and copy bitmap to drawing surface. { SelectObject(hdcBitmap, GetStockObject(GRAY_BRUSH)); Rectangle(hdcBitmap, 0, 0, 100, 100); SelectObject(hdcBitmap, GetStockObject(WHITE_BRUSH)); Rectangle(hdcBitmap, 20, 20, 80, 80); SelectObject(hdcBitmap, GetStockObject(BLACK_BRUSH)); Rectangle(hdcBitmap, 40, 40, 60, 60); SetTextColor(hdcBitmap, RGB(255, 0, 0)); ExtTextOut(hdcBitmap, 5, 5, 0, NULL, TEXT("Hello World"), 11, NULL); BitBlt(hdc, 0, cyCB, 100, 100, hdcBitmap, 0, 0, SRCCOPY); } // Cleanup bitmap & DC. { SelectObject(hdc, hbmOld); DeleteDC(hdcBitmap); DeleteObject(hbm); } // Fill an area with a blue brush. hbr = CreateSolidBrush(RGB(0, 0, 255)); hbrOld = SelectBrush(hdc, hbr); // windowsx.h macro BitBlt(hdc, 10, cyCB+110, 80, 20, NULL, 0, 0, PATCOPY); SelectObject(hdc, hbrOld); DeleteObject(hbr); BitBlt(hdc, 20, cyCB+140, 40, 40, NULL, 0, 0, BLACKNESS); BitBlt(hdc, 30, cyCB+150, 20, 20, NULL, 0, 0, WHITENESS); EndPaint(hWnd, &ps); } break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent, nCmdHt; PAINTSTRUCT ps; RECT textRect; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(g_hInst, (const ACE_TCHAR*)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDOK: SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); SendMessage(hWnd, WM_CLOSE, 0, 0); break; case ID_SETTING_RUN: { #ifdef NO_ACE cout << ACE_TEXT("START with command line: ") << g_CommandLine << endl; CE_ARGV ce_argv(g_CommandLine); main_i(ce_argv.argc(), ce_argv.argv()); cout << ACE_TEXT("END") << endl << endl; #else cout << ACE_TEXT("START with command line: ") << g_CommandLine << endl; ACE_ARGV ce_argv(g_CommandLine); ACE::init(); ACE_LOG_MSG->msg_callback(&cout); // register call back ACE_LOG_MSG->set_flags(ACE_Log_Msg::MSG_CALLBACK); // set call back flag ace_main_i(ce_argv.argc(), ce_argv.argv()); ACE::fini(); cout << ACE_TEXT("END") << endl << endl; #endif // NO_ACE } break; case ID_SETTING_EXIT: SendMessage(hWnd, WM_DESTROY, 0, 0); break; case ID_TOOLS_SAVETOFILE: // create a dialog box to get the file name DialogBox(g_hInst, (const ACE_TCHAR*)IDD_OUTFILE, hWnd, (DLGPROC)SaveFileName); break; case ID_SETTING_COMMANDLINE: // create a dialog box to get the command line DialogBox(g_hInst, (const ACE_TCHAR*)IDD_CMDLINE, hWnd, (DLGPROC)CommandLine); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: SHMENUBARINFO mbi; memset(&mbi, 0, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = hWnd; mbi.nToolBarId = IDM_MENU; mbi.hInstRes = g_hInst; mbi.nBmpId = 0; mbi.cBmpImages = 0; if (!SHCreateMenuBar(&mbi)) return 0; g_hwndCB = mbi.hwndMB; // Initialize the shell activate info structure memset (&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); GetClientRect(hWnd, &textRect); nCmdHt = CommandBar_Height(mbi.hwndMB); hWndEdit = CreateWindow(ACE_TEXT("EDIT"), 0, WS_CHILD | WS_VISIBLE | ES_READONLY | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL, 0, 0, textRect.right, textRect.bottom - MENU_HEIGHT, hWnd, 0, g_hInst, 0); cout.SetOutputWindow(hWndEdit); LoadParameterHistory(); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); EndPaint(hWnd, &ps); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; case WM_HIBERNATE: // low power case WM_CLOSE: case WM_DESTROY: g_Parameter.saveParameter(); // save parameters to history file CommandBar_Destroy(g_hwndCB); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; int wmId, wmEvent; PAINTSTRUCT ps; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_HELP_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_FILE_EXIT: SendMessage (hWnd, WM_CLOSE, 0, 0); break; case IDM_FLASH_ERASE: if (gSystemErrorHasOccured != TRUE){ LoadString(hInst, IDS_FLASH_ERASE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); EraseFlash(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); } else SystemErrorAlert(hWnd); break; case IDM_FLASH_TEST_TIMED: LoadString(hInst, IDS_FLASH_TEST_TIMED, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); gTimerID = SetTimer(hWnd,BB_TEST_FLASH,50,NULL); break; case IDM_FLASH_TEST_STRAIGHT: TestFlash(hWnd); break; case IDM_FLASH_SAVE: LoadString(hInst, IDS_FLASH_SAVE_BL, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); SaveFlash(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); break; case IDM_FLASH_SAVE_WINCE: LoadString(hInst, IDS_FLASH_SAVE_WINCE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); SaveFlashWince(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); break; case IDM_FLASH_PROTECT_WINCE: LoadString(hInst, IDS_FLASH_PROTECT_WINCE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); ProtectWince(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); break; case IDM_FLASH_SAVE_GZ: LoadString(hInst, IDS_FLASH_SAVE_BL_GZ, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); SaveFlashGZ(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); break; case IDM_FLASH_PROGRAM: if (gSystemErrorHasOccured != TRUE){ if (LoadImage(hWnd) != TRUE) //loaded, so program it return 0; LoadString(hInst, IDS_FLASH_PROTECT_WINCE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); ProtectWince(hWnd); if (gSystemErrorHasOccured == TRUE) return 0; LoadString(hInst, IDS_FLASH_ERASE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); EraseFlash(hWnd); LoadString(hInst, IDS_FLASH_PROGRAM, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,FALSE); UpdateWindow(hWnd); Sleep(100); if (ProgramFlash(hWnd) == TRUE) VerifyFlash(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); } else SystemErrorAlert(hWnd); break; case IDM_FLASH_PROGRAM_XPLE: if (gSystemErrorHasOccured != TRUE){ if (LoadImage(hWnd) != TRUE) //loaded, so program it return 0; for (int i=0; i < 50; i++){ LoadString(hInst, IDS_FLASH_PROTECT_WINCE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); ProtectWince(hWnd); if (gSystemErrorHasOccured == TRUE) return 0; LoadString(hInst, IDS_FLASH_ERASE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); EraseFlash(hWnd); LoadString(hInst, IDS_FLASH_PROGRAM, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,FALSE); UpdateWindow(hWnd); Sleep(100); ProgramFlash(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); Sleep(100); } VerifyFlash(hWnd); } else SystemErrorAlert(hWnd); break; case IDM_FLASH_SHOW: ShowFlash(hWnd); break; case IDM_FLASH_VERIFY: VerifyFlash(hWnd); break; case IDOK: //SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); //SendMessage (hWnd, WM_CLOSE, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_TIMER: // this method isn;t used anymore, really KillTimer(hWnd,wParam); if (wParam == BB_TEST_FLASH){ TestFlash(hWnd); LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING); InvalidateRect(hWnd,NULL,TRUE); } else{} case WM_CREATE: hwndCB = CreateRpCommandBar(hWnd); break; case WM_PAINT: RECT rt; hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); DrawText(hdc, szStatus, _tcslen(szStatus), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(hwndCB); PostQuitMessage(0); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { INT wmId, wmEvent; HRESULT hr; PAINTSTRUCT ps; HDC hdc; wstring CapMode, Capture; TCHAR waText[BUF_LENGTH], text2[BUF_LENGTH], title[BUF_LENGTH]; static SHACTIVATEINFO s_sai; DWORD dTickCount; switch (message) { case WM_SIZE: if(wParam == SIZE_MINIMIZED) SendMessage (hWnd, WM_CLOSE, 0, 0); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDC_CAPTURE: if (wmEvent == BN_CLICKED) { //Handle the CAPTURE button click here g_hwndTemp = GetDlgItem(g_hwndMain, IDC_CAPTURE); if(!g_bVideoMode) { EnableWindow(g_hwndTemp, FALSE); dTickCount=GetTickCount(); wsprintf(waText, L"\n **** Time Stamp[%d]: Before Calling the API CaptureStill() function\n", dTickCount); OutputDebugString(waText); hr = g_Prop.CaptureStill(); dTickCount=GetTickCount(); wsprintf(waText, L"\n **** Time Stamp[%d]: After API CaptureStill() function return\n", dTickCount); OutputDebugString(waText); if(SUCCEEDED(hr)) { LoadString(g_hinstCurr, IDS_OK, waText, MAX_LOADSTRING); LoadString(g_hinstCurr, STR_STILL, title, MAX_LOADSTRING); EnableWindow(g_hwndTemp, TRUE); if(!g_bStressTest) MessageBox(hWnd, waText, title, MB_ICONEXCLAMATION|MB_OK); } } else if(!g_bNowRecording) { g_bNowRecording = TRUE; g_hmnuCurr = (HMENU) SendMessage(g_hwndMenuBar, SHCMBM_GETSUBMENU, 0, IDM_SETTINGS); EnableMenuItem(g_hmnuCurr, ID_SETTINGS_FILE, MF_BYCOMMAND|MF_GRAYED); hr=g_Prop.StartCapture(); //if(SUCCEEDED(hr)) { LoadString(g_hinstCurr, STR_STOP, waText, MAX_LOADSTRING); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)waText); } } else { g_bNowRecording = FALSE; EnableWindow(g_hwndTemp, FALSE); g_Prop.StopCapture(); EnableMenuItem(g_hmnuCurr, ID_SETTINGS_FILE, MF_BYCOMMAND); LoadString(g_hinstCurr, STR_CAPTURE, waText, MAX_LOADSTRING); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)waText); EnableWindow(g_hwndTemp, TRUE); } } break; case IDC_STRESS: if(wmEvent == BN_CLICKED) { g_hwndTemp = GetDlgItem(g_hwndMain,IDC_STRESS); LRESULT lResult = SendMessage((HWND) g_hwndTemp, (UINT) BM_GETCHECK, 0, 0); g_hwndTemp = GetDlgItem(g_hwndMain,IDC_CAPTURE); if(lResult == BST_CHECKED) { g_bStressTest = TRUE; EnableWindow(g_hwndTemp, FALSE); //Disable the CAPTURE button Set_Timers(hWnd, g_nDuration); } else if(lResult == BST_UNCHECKED) { TCHAR waTemp[BUF_LENGTH]; g_bStressTest = FALSE; KillTimer(hWnd, MY_TIMER); KillTimer(hWnd, MY_TIMER2); EnableWindow(g_hwndTemp, TRUE); //Enable the CAPTURE button g_hwndTemp = GetDlgItem(g_hwndMain, IDC_TIMER); wsprintf(waTemp, L"00:00:%.2d", g_nDuration); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)waTemp); g_nDueTime = g_nDuration; } } break; case ID_MODE_VIDEO: g_hmnuCurr = (HMENU) SendMessage(g_hwndMenuBar, SHCMBM_GETSUBMENU, 0, IDM_SETTINGS); EnableMenuItem(g_hmnuCurr, ID_SETTINGS_FILE, MF_BYCOMMAND); g_hwndTemp = GetDlgItem(g_hwndMain,IDC_MODE); LoadString(g_hinstCurr, STR_VMODE, waText, MAX_LOADSTRING); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)waText); LoadString(g_hinstCurr, STR_MTITLE, text2, MAX_LOADSTRING); #ifdef DEBUG_MODE MessageBox(hWnd, waText, text2, MB_ICONEXCLAMATION|MB_OK); #endif g_bVideoMode = TRUE; RemoveMenu(g_hmnuCurr, 11, MF_BYPOSITION); RemoveMenu(g_hmnuCurr, 11, MF_BYPOSITION); AppendMenu(g_hmnuCurr, MF_STRING | MF_POPUP, (UINT)g_hmnuVideoSub, L"&Resolution"); AppendMenu(g_hmnuCurr, MF_STRING | MF_POPUP, (UINT)g_ahmnuVdoColorFmts[0], L"&ColorFmts"); //Set_ImgRes(0); break; case ID_MODE_STILL: g_hmnuCurr = (HMENU) SendMessage(g_hwndMenuBar, SHCMBM_GETSUBMENU, 0, IDM_SETTINGS); EnableMenuItem(g_hmnuCurr, ID_SETTINGS_FILE, MF_BYCOMMAND|MF_GRAYED); g_hwndTemp = GetDlgItem(g_hwndMain,IDC_MODE); LoadString(g_hinstCurr, STR_SMODE, waText, MAX_LOADSTRING); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)waText); LoadString(g_hinstCurr, STR_MTITLE, text2, MAX_LOADSTRING); #ifdef DEBUG_MODE MessageBox(hWnd, waText, text2, MB_ICONEXCLAMATION|MB_OK); #endif g_bVideoMode = FALSE; RemoveMenu(g_hmnuCurr, 11, MF_BYPOSITION); RemoveMenu(g_hmnuCurr, 11, MF_BYPOSITION); AppendMenu(g_hmnuCurr, MF_STRING | MF_POPUP, (UINT)g_hmnuStillSub, L"&Resolution"); AppendMenu(g_hmnuCurr, MF_STRING | MF_POPUP, (UINT)g_ahmnuStillColorFmts[0], L"&ColorFmts"); //Set_ImgRes(0); break; //Setting a Time duration(in Seconds)for Stress testing case ID_DURATION_10: Set_Duration(10, 0); break; case ID_DURATION_15: Set_Duration(15, 1); break; case ID_DURATION_20: Set_Duration(20, 2); break; case ID_DURATION_25: Set_Duration(25, 3); break; case ID_DURATION_30: Set_Duration(30, 4); break; case ID_DURATION_35: Set_Duration(35, 5); break; case ID_DURATION_40: Set_Duration(40, 6); break; case ID_DURATION_45: Set_Duration(45, 7); break; case ID_DURATION_60: Set_Duration(60, 8); break; case ID_DURATION_NONE: Set_Duration(-1, -1); break; case ID_SETTINGS_FILE: TCHAR szFilter[MAX_FILTER]; TCHAR szTitle[MAX_TITLE]; TCHAR szExt[MAX_EXT]; TCHAR szFile[MAX_PATH]; OPENFILENAME ofn; wsprintf(szFile,TEXT("\0")); memset(&ofn, 0, sizeof (ofn)); ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = hWnd; ofn.lpstrFile = szFile; ofn.nMaxFile = MAX_PATH; LoadString(g_hinstCurr, STR_FEXT, szExt, MAX_LOADSTRING); ofn.lpstrDefExt = szExt; LoadString(g_hinstCurr, STR_FFILTER, szFilter, MAX_LOADSTRING); wcscat(&szFilter[wcslen(szFilter)+1], szExt); wcscat(&szFilter[wcslen(szFilter)+1], L"\0"); ofn.lpstrFilter = szFilter; //TEXT("WMV Files (*.wmv)\0*.wmv\0\0"); LoadString(g_hinstCurr, STR_FOTITLE, szTitle, MAX_LOADSTRING); ofn.lpstrTitle = szTitle; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; if(GetSaveFileName (&ofn)) { #ifdef DEBUG_MODE MessageBox (hWnd, ofn.lpstrFile, szTitle, MB_OK); #endif g_Prop.Set_VdoFileName(ofn.lpstrFile); } else { LoadString(g_hinstCurr, STR_FALSE, waText, MAX_LOADSTRING); MessageBox (hWnd, waText, szTitle, MB_OK); } break; case ID_SETTINGS_HORIZONTAL: g_hmnuCurr = (HMENU) SendMessage(g_hwndMenuBar, SHCMBM_GETSUBMENU, 0, IDM_SETTINGS); hr = g_Prop.Set_Flip(TRUE); if(SUCCEEDED(hr)) { CheckMenuItem(g_hmnuCurr, ID_SETTINGS_HORIZONTAL, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(g_hmnuCurr, ID_SETTINGS_VERTICAL, MF_BYCOMMAND|MF_UNCHECKED); } break; case ID_SETTINGS_VERTICAL: g_hmnuCurr = (HMENU) SendMessage(g_hwndMenuBar, SHCMBM_GETSUBMENU, 0, IDM_SETTINGS); hr = g_Prop.Set_Flip(FALSE); if(SUCCEEDED(hr)) { CheckMenuItem(g_hmnuCurr, ID_SETTINGS_VERTICAL, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(g_hmnuCurr, ID_SETTINGS_HORIZONTAL, MF_BYCOMMAND|MF_UNCHECKED); } break; //Camera Property case ID_CAMERA_PAN: Get_CamProp(PRO_PAN, 0); break; case ID_CAMERA_TILT: Get_CamProp(PRO_TILT, 1); break; case ID_CAMERA_ROLL: Get_CamProp(PRO_ROLL, 2); break; case ID_CAMERA_ZOOM: Get_CamProp(PRO_ZOOM, 3); break; case ID_CAMERA_EXPOSURE: Get_CamProp(PRO_EXPOSURE, 4); break; case ID_CAMERA_IRIS: Get_CamProp(PRO_IRIS, 5); break; case ID_CAMERA_FOCUS: Get_CamProp(PRO_FOCUS, 6); break; case ID_SETTINGS_FLASH: //g_hmnuCurr = (HMENU) SendMessage(g_hwndMenuBar, SHCMBM_GETSUBMENU, 0, IDM_SETTINGS); //CheckMenuRadioItem(g_hmnuCurr, 0, 12, 2, MF_BYPOSITION); Get_CamProp(PRO_FLASH, 7); break; //Image Property case ID_IMAGE_BRIGHTNESS: Get_ImgProp(PRO_BRIGHTNESS, 0); break; case ID_IMAGE_CONTRAST: Get_ImgProp(PRO_CONTRAST, 1); break; case ID_IMAGE_HUE: Get_ImgProp(PRO_HUE, 2); break; case ID_IMAGE_SATURATION: Get_ImgProp(PRO_SATURATION, 3); break; case ID_IMAGE_SHARPNESS: Get_ImgProp(PRO_SHARPNESS, 4); break; case ID_IMAGE_GAMMA: Get_ImgProp(PRO_GAMMA, 5); break; case ID_IMAGE_COLORENABLE: Get_ImgProp(PRO_COLORENABLE, 6); break; case ID_IMAGE_WHITEBALANCE: Get_ImgProp(PRO_WHITEBALANCE, 7); break; case ID_IMAGE_BACKLIGHTCOMP: Get_ImgProp(PRO_BACKLIGHTCOMP, 8); break; case ID_IMAGE_GAIN: Get_ImgProp(PRO_GAIN, 9); break; //Setting Image Resolution case ID_RESOLUTION_0: Set_ImgRes(0); break; case ID_RESOLUTION_1: Set_ImgRes(1); break; case ID_RESOLUTION_2: Set_ImgRes(2); break; case ID_RESOLUTION_3: Set_ImgRes(3); break; case ID_RESOLUTION_4: Set_ImgRes(4); break; case ID_RESOLUTION_5: Set_ImgRes(5); break; case ID_RESOLUTION_6: Set_ImgRes(6); break; case ID_RESOLUTION_7: Set_ImgRes(7); break; case ID_RESOLUTION_8: Set_ImgRes(8); break; case ID_RESOLUTION_9: Set_ImgRes(9); break; //Setting Image Color Format case ID_RESOLUTION_X_0: Set_ImgColorFmt(0); break; case ID_RESOLUTION_X_1: Set_ImgColorFmt(1); break; case ID_RESOLUTION_X_2: Set_ImgColorFmt(2); break; case ID_RESOLUTION_X_3: Set_ImgColorFmt(3); break; //Symbol Custom property case ID_CUSTOM_AIMING: g_hwndTemp = GetDlgItem(g_hwndMain,IDC_PROP); LoadString(g_hinstCurr, PRO_AIM, waText, MAX_LOADSTRING); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)waText); g_tCusTbl.p = CUS_PROPERTY_AIMING; g_ePType = CUS; g_Prop.Get_PropRng(CUS, &g_tCusTbl); UpdateUI(g_tCusTbl.plVal, g_tCusTbl.plMin, g_tCusTbl.plMax, g_tCusTbl.plDelta); break; case ID_CUSTOM_THUMBNAILS: SYSTEMTIME st; GetLocalTime(&st); TCHAR day[10]; TCHAR DName[1024]; wsprintf(day, L"%.2d%.2d%.2d", st.wMonth, st.wDay, st.wYear%100); wsprintf(DName, L"\\My Documents\\My Pictures\\%s", day); TCHAR szFileName[MAX_PATH]; OPENFILENAMEEX ofnex;// = {0}; ofnex.lStructSize = sizeof(ofnex); ofnex.hwndOwner = hWnd; ofnex.lpstrFile = szFileName; ofnex.nMaxFile = sizeof(szFileName) / sizeof(szFileName[0]); ofnex.lpstrFilter = TEXT("JPG Files (*.jpg)\0*.jpg\0"); ofnex.lpstrTitle = TEXT("Photos of the day"); ofnex.ExFlags = OFN_EXFLAG_THUMBNAILVIEW; ofnex.lpstrInitialDir = DName;//L"\\My Documents\\My Pictures\\010107";//NULL if(GetOpenFileNameEx(&ofnex)) { // The selected file name is in szFileName } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_HSCROLL: if(wParam == TB_ENDTRACK) { HRESULT hr; wstring PropStr; WCHAR temp[BUF_LENGTH]; g_hwndTemp = GetDlgItem(g_hwndMain, IDC_PROP); SendMessage(g_hwndTemp, WM_GETTEXT, (WPARAM)STR_LENGHT, (LPARAM)PropStr.c_str()); g_hwndTemp = GetDlgItem(g_hwndMain, IDC_SLIDER); DWORD pos = SendMessage(g_hwndTemp, TBM_GETPOS, 0, 0); g_hwndTemp = GetDlgItem(g_hwndMain, IDC_POS); wsprintf(temp,L"%d", pos); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)temp); #ifdef DEBUG_MODE LoadString(g_hinstCurr, STR_DEMARKATE, waText, MAX_LOADSTRING); OutputDebugString(waText); OutputDebugString(L"|"); OutputDebugString(PropStr.c_str()); OutputDebugString(L"|"); OutputDebugString(waText); #endif if(g_ePType == IMG) { g_tImgTbl.plVal = (LONG)pos; hr = g_Prop.Set_PropVal(IMG, &g_tImgTbl); } else if(g_ePType == CAM) { g_tCamTbl.plVal = (LONG)pos; hr = g_Prop.Set_PropVal(CAM, &g_tCamTbl); } else { g_tCusTbl.plVal = (LONG)pos; hr = g_Prop.Set_PropVal(CUS, &g_tCusTbl); } if(SUCCEEDED(hr)) OutputDebugString(L"\n--------Property Value Set OK----------"); else OutputDebugString(L"\n--------Property Value Set FAIL--------"); } break; case WM_CREATE: SHMENUBARINFO info; memset(&info, 0, sizeof(SHMENUBARINFO)); info.cbSize = sizeof(info); info.hwndParent = hWnd; info.dwFlags = SHCMBF_HIDESIPBUTTON|SHCMBF_COLORBK; info.nToolBarId = IDR_MENU; info.hInstRes = g_hinstCurr; if (!SHCreateMenuBar(&info)) { g_hwndMenuBar = NULL; } else { g_hwndMenuBar = info.hwndMB; } // Initialize the shell activate info structure memset(&s_sai, 0, sizeof (s_sai)); s_sai.cbSize = sizeof (s_sai); break; case WM_TIMER: if(wParam==MY_TIMER2) { TCHAR waTemp[BUF_LENGTH]; if(!g_bVideoMode&&g_bStressTest) { g_hwndTemp = GetDlgItem(g_hwndMain, IDC_TIMER); wsprintf(waTemp,L"00:00:%.2d",(--g_nDueTime)); SendMessage(g_hwndTemp, WM_SETTEXT, 0, (LPARAM)waTemp); } } else if(wParam==MY_TIMER) { if(!g_bVideoMode&&g_bStressTest) { g_nDueTime = g_nDuration; g_Prop.CaptureStill(); } } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); #ifdef DEBUG_MODE LoadString(g_hinstCurr, STR_WM_PAINT, waText, MAX_LOADSTRING); OutputDebugString(waText); #endif // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: CommandBar_Destroy(g_hwndMenuBar); PostQuitMessage(0); break; case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE); break; case WM_SETTINGCHANGE: SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
/*---------------------------------------------------------------------------*\ | | \*---------------------------------------------------------------------------*/ void OnDestroy(HWND hwnd) { CommandBar_Destroy(hwndCB); PostQuitMessage(0); }