BOOL CPrefabDlg::OnInitDialog() { CDialog::OnInitDialog(); CMenu menu; menu.LoadMenu(IDR_MENU2); SetMenu(&menu); menu.Detach(); if (g_editorMode == eMODE_PREFAB) { GetMenu()->EnableMenuItem(ID_PACKAGE_NEW, MF_ENABLED); GetMenu()->EnableMenuItem(ID_PACKAGE_RENAMESELECTED, MF_ENABLED); GetMenu()->EnableMenuItem(ID_PACKAGE_DELETESELECTED, MF_ENABLED); GetMenu()->EnableMenuItem(ID_PREFAB_NEW, MF_ENABLED); GetMenu()->EnableMenuItem(ID_PREFAB_OPENSELECTED, MF_ENABLED); GetMenu()->EnableMenuItem(ID_PREFAB_RENAMESELECTED, MF_ENABLED); GetMenu()->EnableMenuItem(ID_PREFAB_DELETESELECTED, MF_ENABLED); m_btnInsertPrefab.SetWindowTextA("Open Prefab"); } else { GetMenu()->EnableMenuItem(ID_PACKAGE_NEW, MF_DISABLED | MF_GRAYED); GetMenu()->EnableMenuItem(ID_PACKAGE_RENAMESELECTED, MF_DISABLED | MF_GRAYED); GetMenu()->EnableMenuItem(ID_PACKAGE_DELETESELECTED, MF_DISABLED | MF_GRAYED); GetMenu()->EnableMenuItem(ID_PREFAB_NEW, MF_DISABLED | MF_GRAYED); GetMenu()->EnableMenuItem(ID_PREFAB_OPENSELECTED, MF_DISABLED | MF_GRAYED); GetMenu()->EnableMenuItem(ID_PREFAB_RENAMESELECTED, MF_DISABLED | MF_GRAYED); GetMenu()->EnableMenuItem(ID_PREFAB_DELETESELECTED, MF_DISABLED | MF_GRAYED); m_btnInsertPrefab.SetWindowTextA("Insert Prefab"); } m_slideLod.SetRange(0, 2); CBitmap cBmp; CBitmap* cBmpMask = NULL; m_packageListImage.Create(36, 36, ILC_COLOR24, 1, 1); cBmp.LoadBitmap(IDB_BITMAP_DEFAULT_PACKAGE); m_packageListImage.Add(&cBmp, cBmpMask); cBmp.DeleteObject(); RECT tempRect; m_listPrefabPackages.GetClientRect(&tempRect); m_listPrefabPackages.SetImageList(&m_packageListImage, LVSIL_SMALL); m_listPrefabPackages.InsertColumn(0, "Packages", LVCFMT_CENTER | LVS_SHOWSELALWAYS, (tempRect.right - tempRect.left) * 80 / 100); m_listPrefabPackages.ShowWindow(SW_SHOW); m_listPrefabPackages.UpdateWindow(); m_prefabListImage.Create(80, 80, ILC_COLOR24, 1, 1); cBmp.LoadBitmap(IDB_BITMAP_DEFAULT_VPF); m_prefabListImage.Add(&cBmp, cBmpMask); cBmp.DeleteObject(); m_listPrefabs.SetImageList(&m_prefabListImage, LVSIL_NORMAL); m_listPrefabs.GetClientRect(&tempRect); m_listPrefabs.InsertColumn(0, "Prefabs", LVCFMT_LEFT | LVS_SHOWSELALWAYS, (tempRect.right - tempRect.left) * 80 / 100); m_listPrefabs.ShowWindow(SW_SHOW); m_listPrefabs.UpdateWindow(); //insert items for (CUInt i = 0; i < g_prefabPackagesAndNames.size(); i++) { CChar str[MAX_NAME_SIZE]; Cpy(str, g_prefabPackagesAndNames[i].front().c_str()); if (!Cmp(str, "Vanda_Basics")) InsertItemToPackageList(str); } RECT rect; m_listPrefabProperties.GetClientRect(&rect); m_listPrefabProperties.InsertColumn(0, "Parameters", LVCFMT_LEFT, rect.right - rect.left, 1); m_listPrefabProperties.SetExtendedStyle(LVS_EX_INFOTIP | LVS_EX_ONECLICKACTIVATE | LVS_EX_LABELTIP); InserItemToPropertiesList("Vertices"); InserItemToPropertiesList("Textures"); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void Toolbar_UpdateUI( HWND hwnd) { HWND hwndFrame; HMENU hmenu; unsigned nCount; /*=======================================*/ /* Get frame window (parent of toolbar). */ /*=======================================*/ hwndFrame = GetParent(hwnd); ASSERT(NULL != hwndFrame); /*===================================*/ /* Get the main frame window's menu. */ /*===================================*/ hmenu = GetMenu(hwndFrame); //ASSERT (NULL != hmenu) ; if (NULL == hmenu) { return; } /*======================================*/ /* Get count of buttons on the toolbar. */ /*======================================*/ nCount = Toolbar_ButtonCount(hwnd); /*===================================*/ /* For each button on the toolbar... */ /*===================================*/ while (nCount > 0) { BOOL bMenuEnabled, bButtonEnabled; TBBUTTON tbb; UINT uiState; /*===================================*/ /* Get information about the button. */ /*===================================*/ VERIFY(Toolbar_GetButton(hwnd,--nCount,&tbb)); /*==========================================*/ /* If the button is a separator, ignore it. */ /*==========================================*/ if (tbb.fsStyle & TBSTYLE_SEP) { continue; } /*=========================================*/ /* Get information about the corresponding */ /* menu item, if any. */ /*=========================================*/ uiState = GetMenuState(hmenu,(unsigned) tbb.idCommand,MF_BYCOMMAND); if (0xFFFFFFFF == uiState) { bMenuEnabled = FALSE; } else { bMenuEnabled = 0 == (uiState & (MF_DISABLED | MF_GRAYED)); } bButtonEnabled = 0 != (tbb.fsState & TBSTATE_ENABLED); /*===========================================*/ /* If button and menu are in the same state, */ /* we need do nothing for this button. */ /*===========================================*/ if (bMenuEnabled == bButtonEnabled) { continue; } /*=====================================*/ /* Enable/Disable this toolbar button. */ /*=====================================*/ VERIFY(Toolbar_EnableButton(hwnd,tbb.idCommand,bMenuEnabled)); } }
static LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; HMENU hMenu; static BOARD board; switch( msg ) { case WM_CREATE: board.hInst = ((LPCREATESTRUCTW) lParam)->hInstance; board.hWnd = hWnd; InitBoard( &board ); CreateBoard( &board ); return 0; case WM_PAINT: { HDC hMemDC; WINE_TRACE("WM_PAINT\n"); hdc = BeginPaint( hWnd, &ps ); hMemDC = CreateCompatibleDC( hdc ); DrawBoard( hdc, hMemDC, &ps, &board ); DeleteDC( hMemDC ); EndPaint( hWnd, &ps ); return 0; } case WM_MOVE: WINE_TRACE("WM_MOVE\n"); board.pos.x = (short)LOWORD(lParam); board.pos.y = (short)HIWORD(lParam); return 0; case WM_DESTROY: SaveBoard( &board ); DestroyBoard( &board ); PostQuitMessage( 0 ); return 0; case WM_TIMER: if( board.status == PLAYING ) { board.time++; RedrawWindow( hWnd, &board.timer_rect, 0, RDW_INVALIDATE | RDW_UPDATENOW ); } return 0; case WM_LBUTTONDOWN: WINE_TRACE("WM_LBUTTONDOWN\n"); if( wParam & ( MK_RBUTTON | MK_SHIFT ) ) msg = WM_MBUTTONDOWN; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); SetCapture( hWnd ); return 0; case WM_LBUTTONUP: WINE_TRACE("WM_LBUTTONUP\n"); if( wParam & ( MK_RBUTTON | MK_SHIFT ) ) msg = WM_MBUTTONUP; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); ReleaseCapture(); return 0; case WM_RBUTTONDOWN: WINE_TRACE("WM_RBUTTONDOWN\n"); if( wParam & MK_LBUTTON ) { board.press.x = 0; board.press.y = 0; msg = WM_MBUTTONDOWN; } TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_RBUTTONUP: WINE_TRACE("WM_RBUTTONUP\n"); if( wParam & MK_LBUTTON ) msg = WM_MBUTTONUP; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_MBUTTONDOWN: WINE_TRACE("WM_MBUTTONDOWN\n"); TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_MBUTTONUP: WINE_TRACE("WM_MBUTTONUP\n"); TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; case WM_MOUSEMOVE: { if( ( wParam & MK_MBUTTON ) || ( ( wParam & MK_LBUTTON ) && ( wParam & MK_RBUTTON ) ) ) { msg = WM_MBUTTONDOWN; } else if( wParam & MK_LBUTTON ) { msg = WM_LBUTTONDOWN; } else { return 0; } TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); return 0; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_NEW: CreateBoard( &board ); return 0; case IDM_MARKQ: hMenu = GetMenu( hWnd ); board.IsMarkQ = !board.IsMarkQ; if( board.IsMarkQ ) CheckMenuItem( hMenu, IDM_MARKQ, MF_CHECKED ); else CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED ); return 0; case IDM_BEGINNER: SetDifficulty( &board, BEGINNER ); CreateBoard( &board ); return 0; case IDM_ADVANCED: SetDifficulty( &board, ADVANCED ); CreateBoard( &board ); return 0; case IDM_EXPERT: SetDifficulty( &board, EXPERT ); CreateBoard( &board ); return 0; case IDM_CUSTOM: SetDifficulty( &board, CUSTOM ); CreateBoard( &board ); return 0; case IDM_EXIT: SendMessageW( hWnd, WM_CLOSE, 0, 0); return 0; case IDM_TIMES: DialogBoxParamW( board.hInst, MAKEINTRESOURCEW(DLG_TIMES), hWnd, TimesDlgProc, (LPARAM) &board); return 0; case IDM_ABOUT: { WCHAR appname[256], other[256]; LoadStringW( board.hInst, IDS_APPNAME, appname, sizeof(appname)/sizeof(WCHAR) ); LoadStringW( board.hInst, IDS_ABOUT, other, sizeof(other)/sizeof(WCHAR) ); ShellAboutW( hWnd, appname, other, LoadImageW(board.hInst, MAKEINTRESOURCEW(IDI_WINEMINE), IMAGE_ICON, 48, 48, LR_SHARED)); return 0; } default: WINE_TRACE("Unknown WM_COMMAND command message received\n"); break; } } return DefWindowProcW( hWnd, msg, wParam, lParam ); }
BOOL Show(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; // Store instance handle in our global variable int zoom = g_Config.iWindowZoom; if (zoom < 1) zoom = 1; if (zoom > 4) zoom = 4; RECT rc, rcOrig; GetWindowRectAtZoom(zoom, rcOrig, rc); u32 style = WS_OVERLAPPEDWINDOW; hwndMain = CreateWindowEx(0,szWindowClass, "", style, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL); if (!hwndMain) return FALSE; hwndDisplay = CreateWindowEx(0, szDisplayClass, TEXT(""), WS_CHILD | WS_VISIBLE, rcOrig.left, rcOrig.top, rcOrig.right - rcOrig.left, rcOrig.bottom - rcOrig.top, hwndMain, 0, hInstance, 0); if (!hwndDisplay) return FALSE; menu = GetMenu(hwndMain); #ifdef FINAL RemoveMenu(menu,2,MF_BYPOSITION); RemoveMenu(menu,2,MF_BYPOSITION); #endif MENUINFO info; ZeroMemory(&info,sizeof(MENUINFO)); info.cbSize = sizeof(MENUINFO); info.cyMax = 0; info.dwStyle = MNS_CHECKORBMP; info.fMask = MIM_STYLE; for (int i = 0; i < GetMenuItemCount(menu); i++) { SetMenuInfo(GetSubMenu(menu,i),&info); } UpdateMenus(); //accept dragged files DragAcceptFiles(hwndMain, TRUE); hideCursor = true; SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0); Update(); SetPlaying(0); ShowWindow(hwndMain, nCmdShow); W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); #if ENABLE_TOUCH RegisterTouchWindow(hwndDisplay, TWF_WANTPALM); #endif RAWINPUTDEVICE keyboard; memset(&keyboard, 0, sizeof(keyboard)); keyboard.usUsagePage = 1; keyboard.usUsage = 6; keyboard.dwFlags = 0; // RIDEV_NOLEGACY | ; RegisterRawInputDevices(&keyboard, 1, sizeof(RAWINPUTDEVICE)); SetFocus(hwndDisplay); return TRUE; }
void CheckUndoMenu(HWND hwnd, BOOL bEnable) { bUndo = bEnable; EnableMenuItem(GetMenu(hwnd), IDM_UNDO, MF_BYCOMMAND | (bEnable ? MF_ENABLED : MF_GRAYED)); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 回调函数 LRESULT CALLBACK CMainWnd::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CChildWnd *pWnd; TCHAR tzTemp[MAX_PATH]; switch (uMsg) { case WM_CREATE: // 窗口被创建 m_hWnd = hWnd; m_hMenu = GetMenu(m_hWnd); OnCreate(); break; case WM_SIZE: // 尺寸改变 OnSize(wParam, lParam); return 0; case WM_WINDOWPOSCHANGED: // 位置改变 for (pWnd = CChildWnd::m_pHead; pWnd; pWnd = pWnd->m_pNext) { if (pWnd->m_hWnd) { pWnd->SetDrawRect(); } } break; case WM_INITMENUPOPUP: // 弹出菜单初始化 OnMenuPopup(wParam, lParam); break; case WM_MENUSELECT: // 菜单项被选择 OnMenuSelect(LOWORD(wParam)); break; case WM_EXITMENULOOP: // 退出菜单循环 CClientWnd::SetStatusText(LNG_Ready); break; case WM_COMMAND: // 命令处理 OnCommand(wParam, lParam); break; case WM_COPYDATA: // 本程序的其它实例通知打开文件 if (((PCOPYDATASTRUCT) lParam)->dwData == IDM_File_Open) { static TCHAR s_tzFileName[MAX_PATH]; lstrcpyn(s_tzFileName, (PTSTR) ((PCOPYDATASTRUCT) lParam)->lpData, MAX_PATH); PostMessage(m_hWnd, WM_COMMAND, IDM_File_Open, (LPARAM) s_tzFileName); } break; case WM_HOTKEY: // 热键消息 if ((m_hWnd != GetForegroundWindow()) && (wParam == IDC_TrayIcon)) { OnTrayIcon(FALSE); } break; case WM_DROPFILES: // 拖动文件 DragQueryFile((HDROP) wParam, 0, tzTemp, MAX_PATH); DragFinish((HDROP) wParam); OnFileOpen(tzTemp); break; case WM_HELP: // 帮助 OnCommand(IDM_Help_Content); break; case WM_DESTROY: // 窗口被销毁 OnDestroy(); break; } return DefFrameProc(hWnd, CClientWnd::m_hWnd, uMsg, wParam, lParam); }
void UpdateMenu(HWND hWnd) { HMENU hMenu = GetMenu(hWnd); CheckMenuRadioItem(hMenu, IDM_VIEW_25, IDM_VIEW_400, IDM_VIEW_100 + iViewScale, MF_BYCOMMAND); CheckMenuItem(hMenu, ID_VIEW_ANIMATE, bAnimate ? MF_CHECKED : MF_UNCHECKED); }
LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_CREATE: if (!InitControls(hwnd)) PostMessage(hwnd, WM_CLOSE, 0, 0); break; case WM_COMMAND: MainWndOnCommand(hwnd, wParam, lParam); break; case WM_NOTIFY: { LPNMHDR data = (LPNMHDR)lParam; switch (data->code) { case TVN_SELCHANGED: { if (data->hwndFrom == hTreeView) { switch (((LPNMTREEVIEW)lParam)->itemNew.lParam) { case IDS_INSTALLED: UpdateApplicationsList(ENUM_ALL_COMPONENTS); break; case IDS_APPLICATIONS: UpdateApplicationsList(ENUM_APPLICATIONS); break; case IDS_UPDATES: UpdateApplicationsList(ENUM_UPDATES); break; case IDS_AVAILABLEFORINST: UpdateApplicationsList(ENUM_ALL_AVAILABLE); break; case IDS_CAT_AUDIO: UpdateApplicationsList(ENUM_CAT_AUDIO); break; case IDS_CAT_DEVEL: UpdateApplicationsList(ENUM_CAT_DEVEL); break; case IDS_CAT_DRIVERS: UpdateApplicationsList(ENUM_CAT_DRIVERS); break; case IDS_CAT_EDU: UpdateApplicationsList(ENUM_CAT_EDU); break; case IDS_CAT_ENGINEER: UpdateApplicationsList(ENUM_CAT_ENGINEER); break; case IDS_CAT_FINANCE: UpdateApplicationsList(ENUM_CAT_FINANCE); break; case IDS_CAT_GAMES: UpdateApplicationsList(ENUM_CAT_GAMES); break; case IDS_CAT_GRAPHICS: UpdateApplicationsList(ENUM_CAT_GRAPHICS); break; case IDS_CAT_INTERNET: UpdateApplicationsList(ENUM_CAT_INTERNET); break; case IDS_CAT_LIBS: UpdateApplicationsList(ENUM_CAT_LIBS); break; case IDS_CAT_OFFICE: UpdateApplicationsList(ENUM_CAT_OFFICE); break; case IDS_CAT_OTHER: UpdateApplicationsList(ENUM_CAT_OTHER); break; case IDS_CAT_SCIENCE: UpdateApplicationsList(ENUM_CAT_SCIENCE); break; case IDS_CAT_TOOLS: UpdateApplicationsList(ENUM_CAT_TOOLS); break; case IDS_CAT_VIDEO: UpdateApplicationsList(ENUM_CAT_VIDEO); break; } } /* Disable/enable items based on treeview selection */ if (IsSelectedNodeInstalled()) { EnableMenuItem(GetMenu(hwnd), ID_REGREMOVE, MF_ENABLED); EnableMenuItem(GetMenu(hwnd), ID_INSTALL, MF_GRAYED); EnableMenuItem(GetMenu(hwnd), ID_UNINSTALL, MF_ENABLED); EnableMenuItem(GetMenu(hwnd), ID_MODIFY, MF_ENABLED); EnableMenuItem(GetMenu(hListView), ID_REGREMOVE, MF_ENABLED); EnableMenuItem(GetMenu(hListView), ID_INSTALL, MF_GRAYED); EnableMenuItem(GetMenu(hListView), ID_UNINSTALL, MF_ENABLED); EnableMenuItem(GetMenu(hListView), ID_MODIFY, MF_ENABLED); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_REGREMOVE, TRUE); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_INSTALL, FALSE); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_UNINSTALL, TRUE); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_MODIFY, TRUE); } else { EnableMenuItem(GetMenu(hwnd), ID_REGREMOVE, MF_GRAYED); EnableMenuItem(GetMenu(hwnd), ID_INSTALL, MF_ENABLED); EnableMenuItem(GetMenu(hwnd), ID_UNINSTALL, MF_GRAYED); EnableMenuItem(GetMenu(hwnd), ID_MODIFY, MF_GRAYED); EnableMenuItem(GetMenu(hListView), ID_REGREMOVE, MF_GRAYED); EnableMenuItem(GetMenu(hListView), ID_INSTALL, MF_ENABLED); EnableMenuItem(GetMenu(hListView), ID_UNINSTALL, MF_GRAYED); EnableMenuItem(GetMenu(hListView), ID_MODIFY, MF_GRAYED); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_REGREMOVE, FALSE); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_INSTALL, TRUE); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_UNINSTALL, FALSE); SendMessage(hToolBar, TB_ENABLEBUTTON, ID_MODIFY, FALSE); } } break; case LVN_ITEMCHANGED: { LPNMLISTVIEW pnic = (LPNMLISTVIEW) lParam; if (pnic->hdr.hwndFrom == hListView) { /* Check if this is a valid item * (technically, it can be also an unselect) */ INT ItemIndex = pnic->iItem; if (ItemIndex == -1 || ItemIndex >= ListView_GetItemCount(pnic->hdr.hwndFrom)) { break; } /* Check if the focus has been moved to another item */ if ((pnic->uChanged & LVIF_STATE) && (pnic->uNewState & LVIS_FOCUSED) && !(pnic->uOldState & LVIS_FOCUSED)) { if (IS_INSTALLED_ENUM(SelectedEnumType)) ShowInstalledAppInfo(ItemIndex); if (IS_AVAILABLE_ENUM(SelectedEnumType)) ShowAvailableAppInfo(ItemIndex); } } } break; case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam; (VOID) ListView_SortItems(hListView, ListViewCompareFunc, pnmv->iSubItem); bAscending = !bAscending; } break; case NM_CLICK: { if (data->hwndFrom == hListView && ((LPNMLISTVIEW)lParam)->iItem != -1) { if (IS_INSTALLED_ENUM(SelectedEnumType)) ShowInstalledAppInfo(-1); if (IS_AVAILABLE_ENUM(SelectedEnumType)) ShowAvailableAppInfo(-1); } } break; case NM_DBLCLK: { if (data->hwndFrom == hListView && ((LPNMLISTVIEW)lParam)->iItem != -1) { /* this won't do anything if the program is already installed */ SendMessage(hwnd, WM_COMMAND, ID_INSTALL, 0); } } break; case NM_RCLICK: { if (data->hwndFrom == hListView && ((LPNMLISTVIEW)lParam)->iItem != -1) { ShowPopupMenu(hListView, 0, ID_INSTALL); } } break; case EN_LINK: RichEditOnLink(hwnd, (ENLINK*)lParam); break; case TTN_GETDISPINFO: ToolBarOnGetDispInfo((LPTOOLTIPTEXT)lParam); break; } } break; case WM_PAINT: break; case WM_SIZE: { if ((GetClientWindowHeight(hMainWnd) - GetWindowHeight(hStatusBar) - SPLIT_WIDTH) < GetHSplitterPos()) { INT NewSplitPos = GetClientWindowHeight(hwnd) - 100 - GetWindowHeight(hStatusBar) - SPLIT_WIDTH; if (NewSplitPos > GetWindowHeight(hToolBar) + SPLIT_WIDTH) SetHSplitterPos(NewSplitPos); } MainWndOnSize(hwnd, wParam, lParam); } break; case WM_SIZING: { int RichEditHeight = GetWindowHeight(hRichEdit); LPRECT pRect = (LPRECT)lParam; while (RichEditHeight <= 100) { if (GetHSplitterPos() - 1 < GetWindowHeight(hToolBar) + GetWindowHeight(hListView) + SPLIT_WIDTH) break; SetHSplitterPos(GetHSplitterPos() - 1); RichEditHeight++; } if (pRect->right-pRect->left < 565) pRect->right = pRect->left + 565; if (pRect->bottom-pRect->top < 300) pRect->bottom = pRect->top + 300; return TRUE; } case WM_SYSCOLORCHANGE: { /* Forward WM_SYSCOLORCHANGE to common controls */ SendMessage(hListView, WM_SYSCOLORCHANGE, 0, 0); SendMessage(hTreeView, WM_SYSCOLORCHANGE, 0, 0); SendMessage(hToolBar, WM_SYSCOLORCHANGE, 0, 0); SendMessageW(hRichEdit, EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE)); } break; case WM_DESTROY: { ShowWindow(hwnd, SW_HIDE); SaveSettings(hwnd); FreeLogs(); FreeCachedAvailableEntries(); if (IS_INSTALLED_ENUM(SelectedEnumType)) FreeInstalledAppList(); if (hImageTreeView) ImageList_Destroy(hImageTreeView); PostQuitMessage(0); return 0; } break; } return DefWindowProc(hwnd, Msg, wParam, lParam); }
PObjectBase MenuEditor::GetMenu(long& n, PObjectDatabase base, bool isSubMenu) { // Get item from list control wxString label, shortcut, id, name, help, kind; PObjectBase menu; GetItem(n, label, shortcut, id, name, help, kind, &menu); bool createNew = true; if ( menu ) { createNew = ( menu->GetClassName() != (isSubMenu ? wxT("submenu") : wxT("wxMenu")) ); } // preserve original menu if the object types match // this preserves properties that are not exposed in the menu editor - like C++ scope if ( createNew ) { PObjectInfo info = base->GetObjectInfo(isSubMenu ? wxT("submenu") : wxT("wxMenu") ); menu = base->NewObject(info); } label.Trim(true); label.Trim(false); menu->GetProperty( wxT("label") )->SetValue(label); menu->GetProperty( wxT("name") )->SetValue(name); int ident = GetItemIdentation(n); n++; while (n < m_menuList->GetItemCount() && GetItemIdentation(n) > ident) { PObjectBase menuitem; GetItem(n, label, shortcut, id, name, help, kind, &menuitem); createNew = true; label.Trim(true); label.Trim(false); if (label == wxT("---")) { if ( menuitem ) { createNew = ( menuitem->GetClassName() != wxT("separator") ); } if ( createNew ) { PObjectInfo info = base->GetObjectInfo( wxT("separator") ); menuitem = base->NewObject(info); } menu->AddChild(menuitem); menuitem->SetParent(menu); n++; } else if (HasChildren(n)) { PObjectBase child = GetMenu(n, base); menu->AddChild(child); child->SetParent(menu); } else { if ( menuitem ) { createNew = ( menuitem->GetClassName() != wxT("wxMenuItem") ); } if ( createNew ) { PObjectInfo info = base->GetObjectInfo( wxT("wxMenuItem") ); menuitem = base->NewObject(info); } menuitem->GetProperty( wxT("label") )->SetValue(label); menuitem->GetProperty( wxT("shortcut") )->SetValue(shortcut); menuitem->GetProperty( wxT("name") )->SetValue(name); menuitem->GetProperty( wxT("help") )->SetValue(help); menuitem->GetProperty( wxT("id") )->SetValue(id); menuitem->GetProperty( wxT("kind") )->SetValue(kind); menu->AddChild(menuitem); menuitem->SetParent(menu); n++; } } return menu; }
// front end void ChatPopDown() { if(--chatCount <= 0) CheckMenuItem(GetMenu(hwndMain), IDM_NewChat, MF_UNCHECKED); }
void init() { RgnHandle tempRgn; Rect BaseRect; OSErr err; long QDfeature/*, OSfeature*/; GDHandle SaveGD; CGrafPtr SavePort; /* Initialize Managaer. */ //InitGraf(&qd.thePort); //InitWindows(); //InitDialogs(nil); InitCursor(); FlushEvents(everyEvent, 0); /* Set up menus. */ mymenu0 = GetMenu(appleID); //AppendResMenu(mymenu0, 'DRVR'); InsertMenu(mymenu0,0); mymenu1 = GetMenu(fileID); InsertMenu(mymenu1,0); DrawMenuBar(); DoneFlag = false; ThePict = GetPicture(PictID); if (ThePict == nil) DoneFlag = true; /* Use Gestalt to find is QuickDraw is avaiable. */ /*if ((GetOSTrapAddress(Gestalttest) != GetOSTrapAddress(NoTrap))) { err = Gestalt(gestaltQuickdrawVersion, &QDfeature); if (err) DoneFlag = true; err = Gestalt(gestaltSystemVersion, &OSfeature); if (err) DoneFlag = true; if (!DoneFlag && (QDfeature & 0x0f00) != 0x0200 && OSfeature < 0x0605) DoneFlag = true; } else DoneFlag = true;*/ err = Gestalt(gestaltQuickdrawVersion, &QDfeature); if (err != noErr || QDfeature < gestalt32BitQD) DoneFlag = true; /* Set Rects. */ SetRect(&BaseRect, 40, 60, 472, 282); SetRect(&WinMinusScroll, BaseRect.left-40, BaseRect.top-60, BaseRect.right-60, BaseRect.bottom - 80); SetRect(&InitWindowSize, WinMinusScroll.left, WinMinusScroll.top, WinMinusScroll.right, WinMinusScroll.bottom); tempRgn = GetGrayRgn(); HLock ((Handle) tempRgn); //TotalRect = (**tempRgn).rgnBBox; GetRegionBounds(tempRgn, &TotalRect); /*SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40, (**tempRgn).rgnBBox.bottom - 40);*/ SetRect(&minRect, 80, 80, TotalRect.right - 40, TotalRect.bottom - 40); HUnlock ((Handle) tempRgn); /* Open window and set up picture. */ GetGWorld (&SavePort, &SaveGD); mycolors = GetCTable (clutID); (*mycolors)->ctFlags |= 0x4000; myWindow = NewCWindow(nil, &BaseRect, (ConstStr255Param)"", true, zoomDocProc, (WindowPtr) -1, true, 150); SetGWorld(GetWindowPort(myWindow), SaveGD); DrawGrowIcon (myWindow); srcPalette = NewPalette (((**mycolors).ctSize)+1, mycolors, pmTolerant + pmExplicit + pmAnimated, 0); SetPalette ((WindowPtr) myWindow, srcPalette, true); GetGWorld (&SavePort, &SaveGD); err = NewGWorld (&offscreenGWorld, 8, &InitWindowSize, mycolors, nil, 0); if (err) Debugger(); SetGWorld (offscreenGWorld, nil); EraseRect (&InitWindowSize); DrawPicture (ThePict, &InitWindowSize); SetGWorld (SavePort, SaveGD); }
pascal MenuHandle SafeGetMenu(short resourceID) { StAcroResourceContext resContext; return GetMenu(resourceID); }
// // FUNCTION: WndProc(HWND, unsigniert, WORD, LONG) // // PUPOSE: handling of messages from main window // // WM_COMMAND - Processes message coming from the menu and the controls (e.g. button) // WM_PAINT - Re/Drawing of main window // WM_DESTROY - Ends application // // 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); // handling commands from menu and controls (e.g. buttons) switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDC_CHECK_BOX_BASE: if (videofolderPath.compare("") == 0 && showVideoConfigWarning){ MessageBox(hWnd, "You haven't configure the video directory, which may lead to an error when trying to play video.", "WARNNING", MB_OK); showVideoConfigWarning = false; } DestroyImage(MATCH_TYPE); HandleMovement(0); //need to first disable, then enable, otherwise same button will be disabled by mistake EnableMatchImageInteractions(false); EnableVideoInteractions(true); EnableNavigator(true); EnableBaseImageInteractions(true); break; case IDC_CHECK_BOX_MATCH: HandleMovement(0); //need to first disable, then enable, otherwise same button will be disabled by mistake EnableBaseImageInteractions(false); EnableMatchImageInteractions(true); EnableNavigator(true); break; case IDC_BUTTON_LEFT: HandleMovement(-1); break; case IDC_BUTTON_RIGHT: HandleMovement(+1); break; case IDC_BUTTON_SAVE: { if (BST_CHECKED == SendMessage(check_box_handles[0], BM_GETCHECK, 0, 0)){ int trackID = Get_Number(trackId_handle); int type = UNKNOW; if (BST_CHECKED == SendMessage(check_box_handles[2], BM_GETCHECK, 0, 0)){ type = PARK; } else if (BST_CHECKED == SendMessage(check_box_handles[3], BM_GETCHECK, 0, 0)){ type = LEAVE; } int spotNum = Get_Number(spot_handle); if (spotNum < 0 || type == UNKNOW){ MessageBox(hWnd, "Either SpotNum or Park/Leave type is not set yet, please check and save again!", "WARNING", MB_OK); } else{ if (saveSpotConfig(type, trackID, spotNum)){ Set_Text(spot_handle, ""); PostMessage(type == PARK ? check_box_handles[2] : check_box_handles[3], BM_SETCHECK, BST_UNCHECKED, 0); } } } else if (BST_CHECKED == SendMessage(check_box_handles[1], BM_GETCHECK, 0, 0)){ if (BST_CHECKED == SendMessage(merge_checkbox_handle, BM_GETCHECK, 0, 0)){ if (saveMerge(curBaseImageInfo->trackNum, curMatchImageInfo->trackNum)){ PostMessage(merge_checkbox_handle, BM_SETCHECK, BST_UNCHECKED, 0); } } else{ MessageBox(hWnd, "The merge radio button is not set yet, please check and save again!", "WARNING", MB_OK); } } else{ MessageBox(hWnd, "This should never be shown!", "ERROR", MB_OK); } } break; case IDC_BUTTON_DO_IT: { char buf[15]; int x = GetWindowText(button_handle, buf, 15); if (strcmp(buf, "PLAY") == 0){ char videoName[MAX_PATH]; x = GetWindowText(videoName_handle, videoName, MAX_PATH); string fullVideoPath = videofolderPath + "\\" + string(videoName); if (vio->Get_Video_from_File((char*)fullVideoPath.c_str())){ Set_Text(button_handle, "STOP"); int start = max(Get_Number(from_handle), 0); int end = max(Get_Number(to_handle), 0); start = start > end ? 0 : start; vio->Play_Video(start, end); Set_Text(button_handle, "PLAY"); } else{ MessageBox(hWnd, "Failed to open the video file, please verify your video dir setup!", "SORRY", MB_OK); } } else { vio->Stop_Video(); Set_Text(button_handle, "PLAY"); } } break; case IDM_IMAGEOP_LOADIMAGEFOLDER: { if (fd->OpenDirectory()){ imagefolderPath = fd->Get_ImgFolder_Name(); std::vector<string> imageNameList; fd->GetFilesInDirectory(imageNameList, imagefolderPath, ".jpg"); Set_Text(img_pathinfo_handle, (char*)imagefolderPath.c_str()); imginfoset = new ImageInfoSet(imageNameList); EnableBaseImage(true); } } break; case IDM_IMAGEOP_SELECTVIDEOFOLDER: { if (fd->OpenDirectory()){ videofolderPath = fd->Get_ImgFolder_Name(); //fd->GetFilesInDirectory(imageNameList, imagefolderPath, ".jpg"); Set_Text(video_pathinfo_handle, (char*)videofolderPath.c_str()); } } break; case IDM_IMAGEOP_SELECTOUTPUTFILE: { if (fd->OpenFile()){ closeOutputFile(); outputPath = fd->Get_Name(); outputStream.open(outputPath, ios::out | ios::app); time_t now = time(0); char buf[100]; ctime_s(buf, 100, &now); appendTxtToOutput("OpenFile : " + outputPath + " @ " + string(buf)); } else{ MessageBox(hWnd, "Failed to open the output file!", "SORRY", MB_OK); } } break; case IDM_EXIT: vio->Stop_Video(); DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_CREATE: { fd = new FileDialog(hWnd); vio = new Video_OP(); // Static control as caption for path info textfield img_path_caption_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "ImageDir:", WS_CHILD | WS_VISIBLE, 10, 10, 70, 30, hWnd, (HMENU)IDC_STATIC_IMAGE_PATH, GetModuleHandle(NULL), NULL); //SetBkColor(img_path_caption_handle, GetSysColor(COLOR_WINDOW)); // Textfield for image pathinfo img_pathinfo_handle = CreateWindowEx(WS_EX_STATICEDGE, "STATIC", "", WS_CHILD | WS_VISIBLE, 85, 10, 440, 30, hWnd, (HMENU)IDC_EDIT_IMAGE_PATH, GetModuleHandle(NULL), NULL); video_path_caption_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "VideoDir:", WS_CHILD | WS_VISIBLE, 10, 50, 70, 30, hWnd, (HMENU)IDC_STATIC_VIDEO_PATH, GetModuleHandle(NULL), NULL); // Textfield for video pathinfo video_pathinfo_handle = CreateWindowEx(WS_EX_STATICEDGE, "STATIC", "", WS_CHILD | WS_VISIBLE, 85, 50, 440, 30, hWnd, (HMENU)IDC_EDIT_VIDEO_PATH, GetModuleHandle(NULL), NULL); //videoName CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "CurVideo:", WS_CHILD | WS_VISIBLE, 10, 90, 70, 30, hWnd, (HMENU)IDC_STATIC_VIDENAME, GetModuleHandle(NULL), NULL); videoName_handle = CreateWindowEx(WS_EX_STATICEDGE, "STATIC", "", WS_CHILD | WS_VISIBLE, 85, 90, 300, 30, hWnd, (HMENU)IDC_EDIT_VIDEONAME, GetModuleHandle(NULL), NULL); //trackId CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "CurTrack:", WS_CHILD | WS_VISIBLE, 400, 90, 70, 30, hWnd, (HMENU)IDC_STATIC_TRACK, GetModuleHandle(NULL), NULL); trackId_handle = CreateWindowEx(WS_EX_STATICEDGE, "STATIC", "", WS_CHILD | WS_VISIBLE, 475, 90, 50, 30, hWnd, (HMENU)IDC_EDIT_TRACK, GetModuleHandle(NULL), NULL); int horzSeparatorPos = 130; CreateWindowEx(WS_EX_CLIENTEDGE, "Static", "", SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 5, horzSeparatorPos, 535, 10, hWnd, NULL, GetModuleHandle(NULL), NULL); // Static control saying FROM CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Video Info Section", WS_CHILD | WS_VISIBLE, 10, horzSeparatorPos + 10, 145, 30, hWnd, NULL, GetModuleHandle(NULL), NULL); from_caption_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Frame start:", WS_CHILD | WS_VISIBLE, 10, horzSeparatorPos + 50, 90, 30, hWnd, (HMENU)IDC_STATIC_START, GetModuleHandle(NULL), NULL); // Textfield to fill in frame where video shall start from from_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE, 105, horzSeparatorPos + 50, 50, 30, hWnd, (HMENU)IDC_EDIT_START, GetModuleHandle(NULL), NULL); // Static control saying TO to_caption_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Frame end:", WS_CHILD | WS_VISIBLE, 10, horzSeparatorPos + 90, 90, 30, hWnd, (HMENU)IDC_STATIC_STOP, GetModuleHandle(NULL), NULL); // Textfield for telling program where to stop to_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE, 105, horzSeparatorPos + 90, 50, 30, hWnd, (HMENU)IDC_EDIT_STOP, GetModuleHandle(NULL), NULL); // Button to start processes which were selected in the menu button_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "PLAY", WS_CHILD | WS_VISIBLE, 40, horzSeparatorPos + 130, 80, 40, hWnd, (HMENU)IDC_BUTTON_DO_IT, GetModuleHandle(NULL), NULL); int vertSeparatorPos = 170; CreateWindowEx(WS_EX_CLIENTEDGE, "Static", "", SS_ETCHEDVERT | WS_CHILD | WS_VISIBLE, vertSeparatorPos, horzSeparatorPos + 1, 100, 181, hWnd, NULL, GetModuleHandle(NULL), NULL); // commoncontrol DLL needs to be loaded (needed for trackbar) //Attention: also requires <commctrl.h> and comctl32.lib INITCOMMONCONTROLSEX icc; icc.dwICC = ICC_BAR_CLASSES; icc.dwSize = sizeof(icc); bool z = InitCommonControlsEx(&icc); //frame diff and distance filters framediff_caption_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Framediff Thres:", WS_CHILD | WS_VISIBLE, vertSeparatorPos + 10, horzSeparatorPos + 10, 110, 30, hWnd, (HMENU)IDC_STATIC_FRAME_DIFF, GetModuleHandle(NULL), NULL); framediff_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", std::to_string(DEFAULT_FRAMEDIFF_THRES).c_str(), WS_CHILD | WS_VISIBLE, vertSeparatorPos + 125, horzSeparatorPos + 10, 50, 30, hWnd, (HMENU)IDC_EDIT_FRAME_DIFF, GetModuleHandle(NULL), NULL); int thirdcolPos = vertSeparatorPos + 180; distance_caption_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Distance Thres:", WS_CHILD | WS_VISIBLE, thirdcolPos + 10, horzSeparatorPos + 10, 110, 30, hWnd, (HMENU)IDC_STATIC_DISTANCE_THRES, GetModuleHandle(NULL), NULL); distance_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", std::to_string(DEFAULT_DISTANCE_THRES).c_str(), WS_CHILD | WS_VISIBLE, thirdcolPos + 125, horzSeparatorPos + 10, 50, 30, hWnd, (HMENU)IDC_EDIT_DISTANCE_THRES, GetModuleHandle(NULL), NULL); //base/match image selector check_box_handles[0] = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON", "Base Image", WS_CHILD | WS_VISIBLE | WS_GROUP | BS_AUTORADIOBUTTON, vertSeparatorPos + 10, horzSeparatorPos + 50, 165, 30, hWnd, (HMENU)IDC_CHECK_BOX_BASE, GetModuleHandle(NULL), NULL); check_box_handles[1] = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON", "Match Image", WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, vertSeparatorPos + 10, horzSeparatorPos + 90, 165, 30, hWnd, (HMENU)IDC_CHECK_BOX_MATCH, GetModuleHandle(NULL), NULL); //merge checkbox merge_checkbox_handle = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON", "Merge Match to Base", WS_CHILD | BS_AUTOCHECKBOX, thirdcolPos + 10, horzSeparatorPos + 50, 165, 30, hWnd, (HMENU)IDC_CHECK_BOX_MERGE, GetModuleHandle(NULL), NULL); //base/match image selector check_box_handles[2] = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON", "Park", WS_CHILD | WS_VISIBLE | WS_GROUP | BS_AUTORADIOBUTTON, thirdcolPos + 10, horzSeparatorPos + 50, 80, 30, hWnd, (HMENU)IDC_CHECK_BOX_PARK, GetModuleHandle(NULL), NULL); check_box_handles[3] = CreateWindowEx(WS_EX_STATICEDGE, "BUTTON", "Leave", WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, thirdcolPos + 95, horzSeparatorPos + 50, 80, 30, hWnd, (HMENU)IDC_CHECK_BOX_LEAVE, GetModuleHandle(NULL), NULL); //change spot CreateWindowEx(WS_EX_TRANSPARENT, "Static", "New Spot:", WS_CHILD | WS_VISIBLE, thirdcolPos + 10, horzSeparatorPos + 90, 110, 30, hWnd, (HMENU)IDC_STATIC_SPOT, GetModuleHandle(NULL), NULL); spot_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE, thirdcolPos + 125, horzSeparatorPos + 90, 50, 30, hWnd, (HMENU)IDC_EDIT_SPOT, GetModuleHandle(NULL), NULL); //navigator leftnavi_button_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "<---", WS_CHILD | WS_VISIBLE, vertSeparatorPos + 100 - 80, horzSeparatorPos + 130, 80, 40, hWnd, (HMENU)IDC_BUTTON_LEFT, GetModuleHandle(NULL), NULL); rightnavi_button_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "--->", WS_CHILD | WS_VISIBLE, vertSeparatorPos + 185 - 80, horzSeparatorPos + 130, 80, 40, hWnd, (HMENU)IDC_BUTTON_RIGHT, GetModuleHandle(NULL), NULL); //save review result save_button_handle = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "SAVE", WS_CHILD | WS_VISIBLE, vertSeparatorPos + 275, horzSeparatorPos + 130, 80, 40, hWnd, (HMENU)IDC_BUTTON_SAVE, GetModuleHandle(NULL), NULL); horzSeparatorPos += 175; CreateWindowEx(WS_EX_CLIENTEDGE, "Static", "", SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 5, horzSeparatorPos, 535, 10, hWnd, NULL, GetModuleHandle(NULL), NULL); CreateWindowEx(WS_EX_TRANSPARENT, "Static", "Latest Logs:", WS_CHILD | WS_VISIBLE, 10, horzSeparatorPos + 10, 515, 30, hWnd, (HMENU)IDC_STATIC_RESULT, GetModuleHandle(NULL), NULL); result_handle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", " Waiting for configurting the output file!", WS_CHILD | WS_VISIBLE, 10, horzSeparatorPos + 40, 515, 110, hWnd, (HMENU)IDC_EDIT_RESULT, GetModuleHandle(NULL), NULL); EnableAllInteractions(false); // Gets Menu Handle menu_handle = GetMenu(hWnd); CheckMenuItem(menu_handle, IDM_PLAY_MOV, MF_CHECKED); } break; // press left mouse button somewhere in the main window to uncheck all radiobuttons (optionbuttons) case WM_LBUTTONDOWN: { if (BST_CHECKED == SendMessage(check_box_handles[0], BM_GETCHECK, 0, 0)){ if (showClearTutorial){ int ret = MessageBox(hWnd, "Enable the function to clear park/leave radio when clicking the background or a non-active component?", "You just clicked the background or a non-active component", MB_YESNO); showClearTutorial = false; enableClear = (ret == IDYES); } } if (enableClear){ SendMessage(check_box_handles[2], BM_SETCHECK, BST_UNCHECKED, 0); SendMessage(check_box_handles[3], BM_SETCHECK, BST_UNCHECKED, 0); } } break; case WM_KEYDOWN: { int x = 0; switch (wParam) { case VK_LEFT: HandleMovement(-1); break; case VK_RIGHT: HandleMovement(+1); break; } } break; case WM_DESTROY: vio->Stop_Video(); DestroyImage(BASE_TYPE); DestroyImage(MATCH_TYPE); closeOutputFile(); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void COpenCVInterfaceDlg::OnPaint() { CPaintDC dc(this); // device context for painting //In variabila r1 pastrez dimensiunile ferestrei picture1 CRect r1; GetClientRect(&r1); int w,h; if(mainImage.cols) { //aleg minimul dintre dimensiunile imag si ale ferestrei de afisare if(mainImage.cols<r1.Width()) w=mainImage.cols; else w=r1.Width(); if(mainImage.rows<r1.Height()) h=mainImage.rows; else h=r1.Height(); //creez un dreptunghi cu dimensiunile minime si il umplu cu peria imagine CRect r(0,0,w-1,h-1); dc.FillRect(r,ImageBrush); CMenu* mmenu =GetMenu(); CMenu* submenu =mmenu->GetSubMenu(1); UINT state = submenu->GetMenuState(ID_TOOLS_GRAYLEVELROW,MF_BYCOMMAND); UINT state1 = submenu->GetMenuState(ID_TOOLS_GRAYLEVELCOLUMN,MF_BYCOMMAND); ASSERT(state != 0xFFFFFFFF); ASSERT(state1 != 0xFFFFFFFF); if(state & MF_CHECKED) { if(gr->GetY()<mainImage.rows) { gr->setGCheck(true); CPen *pen = new CPen(PS_SOLID,1,RGB(255,0,0)); CPen *oldPen; oldPen=(CPen*)dc.SelectObject(pen); dc.MoveTo(0,gr->GetY()); dc.LineTo(mainImage.cols,gr->GetY()); dc.SelectObject(oldPen); delete pen; } } else { if(state1 & MF_CHECKED) { gr->setGCheck(false); if(gr->GetX()<mainImage.cols) { CPen *pen = new CPen(PS_SOLID,1,RGB(255,0,0)); CPen *oldPen; oldPen=(CPen*)dc.SelectObject(pen); dc.MoveTo(gr->GetX(),0); dc.LineTo(gr->GetX(),mainImage.rows); dc.SelectObject(oldPen); delete pen; } } } } }
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam ) /***********************************************************************/ { FNAME szFileName; LPFRAME lpFrame; LPOBJECT lpObject, lpBase; RECT rect, rMask, rTemp, rAll; HWND hWnd; STRING szString; int i, idFileType, x, y, dx, dy; BOOL fDoZoom, bPrint, fHasZoom; LPSTR lpszCmdLine; HGLOBAL hMem; ITEMID idDataType; DWORD dwReturn; int NewShape; UINT wID; SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ ); /* WIN16: ID = wParam ctrl handle = LOWORD(lParam) notify code = HIWORD(lParam) WIN32: ID = LOWORD(wParam) ctrl handle = lParam notify code = HIWORD(wParam) */ #ifdef WIN32 wID = LOWORD(wParam); #else wID = wParam; #endif switch (wID) { case IDM_EXIT: DeactivateTool(); PostMessage( hWndAstral, WM_CLOSE, 0, 0L); Delay (750); break; case IDM_CLOSE: DeactivateTool(); /* Check to see if the image needs to be saved */ if ( !ConfirmClose(NO,NO) ) break; CloseImage( NO, lpImage ); // Close the active image break; case IDM_ABOUT: /* Bring up the modal 'About' dialog box */ AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc); break; case IDM_NEXTPAGE: if ( !lpImage ) break; DeactivateTool(); SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L ); break; case IDM_NEW: DeactivateTool(); SoundStartResource( "magic01", NO, NULL ); AstralCursor( IDC_WAIT ); New( Control.NewWidth, Control.NewHeight, Control.NewResolution, Control.NewDepth ); AstralCursor( NULL ); break; case IDM_OPEN: DeactivateTool(); /* Bring up the modal 'File Open' box */ if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN, Save.FileType, szFileName, NO )) ) break; idFileType = LOWORD( dwReturn ); Save.FileType = idFileType; PutDefaultInt( "FileType", idFileType - IDN_TIFF ); AstralImageLoad( idFileType, szFileName, MAYBE, YES ); break; case IDM_ALTOPEN: DeactivateTool(); // Command line sent from a second instance prior to it closing /* If the caller passed in a file name, try to load it or print it */ if ( !(lpszCmdLine = (LPSTR)lParam) ) break; HandleCommandLine( hWindow, lpszCmdLine, &bPrint ); break; case IDM_SAVE: DeactivateTool(); HandleSaveCommand(hWindow, wID, YES); break; case IDM_SAVEAS: DeactivateTool(); HandleSaveCommand(hWindow, wID, YES); break; case IDM_SAVESPECIAL: DeactivateTool(); HandleSaveCommand(hWindow, wID, YES); break; case IDM_SAVEWALLPAPER: DeactivateTool(); SaveWallpaper( "CRAYOLA", NO/*fTiled*/ ); break; case IDM_REVERT: if ( !lpImage ) break; DeactivateTool(); if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out break; if ( ImgChanged(lpImage) ) { /* Check to see if its OK to trash changes */ if ( AstralOKCancel(IDS_OKTOREVERT, (LPSTR)lpImage->CurFile) == IDCANCEL ) break; } lstrcpy( szFileName, lpImage->CurFile ); idFileType = lpImage->FileType; fDoZoom = IsZoomed(lpImage->hWnd); fHasZoom = Window.fHasZoom; CloseImage( NO, lpImage ); // Close the active image if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) ) break; break; case IDM_RECALLIMAGE0: case IDM_RECALLIMAGE1: case IDM_RECALLIMAGE2: case IDM_RECALLIMAGE3: case IDM_RECALLIMAGE4: case IDM_RECALLIMAGE5: case IDM_RECALLIMAGE6: case IDM_RECALLIMAGE7: case IDM_RECALLIMAGE8: case IDM_RECALLIMAGE9: DeactivateTool(); GetMenuString( GetMenu(hWindow), wID, szFileName, sizeof(szFileName), MF_BYCOMMAND ); i = 0; while ( szFileName[i] && szFileName[i] != ' ' ) i++; // Skip over the numeric id in the string (3. junk.tif) lstrcpy(szString, &szFileName[i+1]); GetRecallFileName(szString); AstralImageLoad( NULL, szString, MAYBE, YES ); break; case IDM_PRINT: if ( !lpImage ) break; DeactivateTool(); AstralCursor( IDC_WAIT ); DoPrintSizeInits(); SoundStartResource( "print", YES, NULL ); PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL ); SoundStop(); AstralCursor( NULL ); break; case IDM_PRINTSETUP: /* Bring up the setup dialog box for the active printer */ AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP, DlgPrintSetupProc); break; case IDC_SOUND: SoundToggle(); break; case IDM_UNDO: if ( !lpImage ) break; DeactivateTool(); ImgEditUndo(lpImage, YES, NO); break; case IDM_CUT: case IDM_COPY: if ( !lpImage ) break; DeactivateTool(); // Create the clipboard files from the image ProgressBegin(1, IDS_PROGCOPY); if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) ) { ProgressEnd(); Message(IDS_EMEMALLOC); break; } ProgressEnd(); OpenClipboard(hWindow); EmptyClipboard(); // Passing a NULL data handle in SetClipboardData() means that // the data will be requested in a WM_RENDERFORMAT message hMem = ConstructObject( lpImage, IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask ); if ( pOLE ) { // Any data put on before Native will become staticly copied SetClipboardData( pOLE->cfNative, NULL ); SetClipboardData( pOLE->cfOwnerLink, hMem ); } SetClipboardData( CF_DIB, NULL ); if ( Control.DoPicture ) SetClipboardData( CF_METAFILEPICT, NULL ); if ( Control.DoBitmap ) SetClipboardData( CF_BITMAP, NULL ); SetClipboardData( CF_PALETTE, NULL ); SetClipboardData( Control.cfImage, NULL ); if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled ) { // ObjectLink is retrieved during a Paste Link... SetClipboardData( pOLE->cfObjectLink, hMem ); } CloseClipboard(); if ( wID == IDM_COPY ) break; // else fall through to IDM_DELETE case IDM_DELETE: if ( !lpImage ) break; { COLORINFO ColorInfo; DeactivateTool(); ColorInfo.gray = 255; SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY ); TintFill( lpImage, &ColorInfo, 255, MM_NORMAL, wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE ); } break; case IDM_PASTE: if ( !lpImage ) break; case IDM_PASTEASNEW: if ( !OpenClipboard(hWndAstral) ) { Message( IDS_ECLIPOPEN ); break; } if ( !IsClipboardFormatAvailable(CF_DIB) && !IsClipboardFormatAvailable(CF_BITMAP) && !IsClipboardFormatAvailable(Control.cfImage) ) { Message( IDS_ECLIPOPEN ); CloseClipboard(); break; } CloseClipboard(); DeactivateTool(); // First put clipboard contents into a file(s) AstralCursor(IDC_WAIT); if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) ) { AstralCursor(NULL); Message(IDS_EMEMALLOC); break; } if ( wID == IDM_PASTE ) { ProgressBegin(1, IDS_PROGPASTECLIP); TransformObjectsStart( YES/*fNewObject*/ ); if ( ImgCreateClipInObject( lpImage, NO ) ) ; ProgressEnd(); } else if ( wID == IDM_PASTEASNEW ) { if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1, &idDataType, &idFileType) ) { if ( NewImageWindow( NULL, // lpOldFrame NULL, // Name lpFrame, // lpNewFrame idFileType, // lpImage->FileType idDataType, // lpImage->DataType FALSE, // New view? IMG_DOCUMENT, // lpImage->DocumentType NULL, // lpImage->ImageName MAYBE ) ) lpImage->fChanged = YES; } } break; case IDM_ESCAPE: if (!lpImage) break; if (lpImage->hWnd == hZoomWindow) break; if ( Tool.bActive && Tool.lpToolProc ) DestroyProc( lpImage->hWnd, 1L ); break; case IDM_SIZEUP: case IDM_SIZEDOWN: if (!Retouch.hBrush) break; SetFocus( hWindow ); // Take focus away from any controls if ( Retouch.BrushShape == IDC_BRUSHCUSTOM ) break; if ( wID == IDM_SIZEUP ) { if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) Retouch.BrushSize += 2; else Retouch.BrushSize++; } else { if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) Retouch.BrushSize -= 2; else Retouch.BrushSize--; } if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE ) { Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE); MessageBeep(0); break; } if (lpImage) DisplayBrush(0, 0, 0, OFF); SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize); if (lpImage && Window.hCursor == Window.hNullCursor) DisplayBrush(lpImage->hWnd, 32767, 32767, ON); if ( Tool.hRibbon ) SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize ); break; case IDM_SHAPEUP: case IDM_SHAPEDOWN: if (!Retouch.hBrush) break; SetFocus( hWindow ); // Take focus away from any controls NewShape = Retouch.BrushShape; if ( wID == IDM_SHAPEUP ) NewShape++; else NewShape--; if ( NewShape > IDC_BRUSHCUSTOM ) NewShape = IDC_BRUSHCIRCLE; if ( NewShape < IDC_BRUSHCIRCLE ) NewShape = IDC_BRUSHCUSTOM; if (lpImage) DisplayBrush(0, 0, 0, OFF); if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush)) { NewShape = IDC_BRUSHCIRCLE; SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush); } Retouch.BrushShape = NewShape; if (lpImage && Window.hCursor == Window.hNullCursor) DisplayBrush(lpImage->hWnd, 32767, 32767, ON); if ( Tool.hRibbon ) { CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE, IDC_BRUSHCUSTOMNEW, Retouch.BrushShape ); SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L ); } break; case IDM_MOVEUP: case IDM_MOVEDOWN: case IDM_MOVELEFT: case IDM_MOVERIGHT: if (!lpImage) break; lpBase = ImgGetBase(lpImage); if (ImgGetSelObject(lpImage, NULL) == lpBase) break; dx = dy = 0; if (wID == IDM_MOVEUP) --dy; if (wID == IDM_MOVEDOWN) ++dy; if (wID == IDM_MOVELEFT) --dx; if (wID == IDM_MOVERIGHT) ++dx; lpObject = NULL; while (lpObject = ImgGetSelObject(lpImage, lpObject)) { rect = lpObject->rObject; OffsetRect(&rect, dx, dy); if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect)) break; } if (lpObject) break; AstralSetRectEmpty(&rAll); lpObject = NULL; while (lpObject = ImgGetSelObject(lpImage, lpObject)) { rect = lpObject->rObject; OffsetRect(&lpObject->rObject, dx, dy); AstralUnionRect(&rAll, &rAll, &lpObject->rObject); if (!lpObject->Pixmap.fNewFrame && EqualRect(&rect, &lpObject->rUndoObject)) lpObject->rUndoObject = lpObject->rObject; UpdateImage(&rect, TRUE); UpdateImage(&lpObject->rObject, TRUE); } if (wID == IDM_MOVEUP) { x = (rAll.left + rAll.right)/2; y = rAll.top; } else if (wID == IDM_MOVEDOWN) { x = (rAll.left + rAll.right)/2; y = rAll.bottom; } else if (wID == IDM_MOVELEFT) { x = rAll.left; y = (rAll.top + rAll.bottom)/2; } else if (wID == IDM_MOVERIGHT) { x = rAll.right; y = (rAll.top + rAll.bottom)/2; } File2Display(&x, &y); AutoScroll(lpImage->hWnd, x, y); AstralUpdateWindow(lpImage->hWnd); DisplayInfo(-1, &rAll); break; case IDM_LASTTOOL: DeactivateTool(); if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) ) SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L); break; case IDM_PREF: // prevent problems if running animations and they change // the wave mix dll setting in preferences StopAnimation(); AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc ); break; case IDC_VIEWLAST: // duplicate of function in the view ribbon if ( !lpImage ) break; RevertLastView(); break; // case IDC_VIEWFULL: // duplicate of function in the view ribbon // if ( !lpImage ) // break; // AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc ); // break; case IDC_VIEWALL: // duplicate of function in the view ribbon if ( !lpImage ) break; ViewAll(); break; case IDC_ZOOMIN: // duplicate of function in the view ribbon if ( !lpImage ) break; if (!lpImage->lpDisplay) break; if (!lpImage->lpDisplay->ViewPercentage) break; x = ( lpImage->lpDisplay->FileRect.left + lpImage->lpDisplay->FileRect.right ) / 2; y = ( lpImage->lpDisplay->FileRect.top + lpImage->lpDisplay->FileRect.bottom ) / 2; SaveLastView(); Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) ); break; case IDC_ZOOMOUT: // duplicate of function in the view ribbon if ( !lpImage ) break; if (!lpImage->lpDisplay) break; if (!lpImage->lpDisplay->ViewPercentage) break; x = ( lpImage->lpDisplay->FileRect.left + lpImage->lpDisplay->FileRect.right ) / 2; y = ( lpImage->lpDisplay->FileRect.top + lpImage->lpDisplay->FileRect.bottom ) / 2; SaveLastView(); Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) ); break; case IDM_HELP: Control.Hints = !Control.Hints; PutDefInt (Control.Hints,Control.Hints); break; default: return( FALSE ); } return( TRUE ); }
/* * WindowProc - main window message handler */ LONG CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { WORD cmd; about_info ai; HMENU mh; CommunicationBuffer *dbginfo; switch ( msg ) { case WM_CREATE: setupSystemMenu( hwnd ); MainLBox = CreateListBox( hwnd ); mh = GetMenu( hwnd ); if( ConfigData.auto_attatch ) { CheckMenuItem( mh, MENU_AUTO_ATTATCH, MF_BYCOMMAND | MF_CHECKED ); } if( ConfigData.continue_exception ) { CheckMenuItem( mh, MENU_EXCEPTION_CONTINUE, MF_BYCOMMAND | MF_CHECKED ); } LBPrintf( MainLBox, STR_DRNT_STARTED, AppName ); break; case WM_SIZE: MoveListBox( MainLBox, 0, 0, LOWORD( lparam ), HIWORD( lparam ) ); ClearAlert(); break; case WM_SYSCOMMAND: switch( wparam ) { case MENU_LOG_CURRENT_STATE: case MENU_LOG_OPTIONS: case MENU_TASK_CTL: SendMessage( hwnd, WM_COMMAND, wparam, 0 ); break; default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } break; case WM_COMMAND: cmd = LOWORD( wparam ); switch( cmd ) { case LISTBOX_1: break; case MENU_EXCEPTION_CONTINUE: ConfigData.continue_exception = !ConfigData.continue_exception; mh = GetMenu( hwnd ); if( ConfigData.continue_exception ) { CheckMenuItem( mh, MENU_EXCEPTION_CONTINUE, MF_BYCOMMAND | MF_CHECKED ); } else { CheckMenuItem( mh, MENU_EXCEPTION_CONTINUE, MF_BYCOMMAND | MF_UNCHECKED ); } break; case MENU_LOG_VIEW: ViewLog(); break; case MENU_NEW_TASK: CallProcCtl( MENU_NEW_TASK, NULL, NULL ); break; case MENU_AUTO_ATTATCH: ConfigData.auto_attatch = ! ConfigData.auto_attatch; mh = GetMenu( hwnd ); if( ConfigData.auto_attatch ) { CheckMenuItem( mh, MENU_AUTO_ATTATCH, MF_BYCOMMAND | MF_CHECKED ); } else { CheckMenuItem( mh, MENU_AUTO_ATTATCH, MF_BYCOMMAND | MF_UNCHECKED ); } break; case MENU_SHOW_DIP_STATUS: ShowDIPStatus( hwnd ); break; case MENU_CLEAR: ClearListBox( MainLBox ); break; case MENU_SAVE_AS: SaveListBox( SLB_SAVE_AS, SaveExtra, "", AppName, hwnd, GetListBoxHwnd( MainLBox ) ); break; case MENU_SAVE: SaveListBox( SLB_SAVE_TMP, SaveExtra, ".\\drwat.txt", AppName, hwnd, GetListBoxHwnd( MainLBox ) ); break; case MENU_FONT: if( ChooseMonoFont( hwnd ) ) { SetListBoxFont( MainLBox ); } break; case MENU_MARK: ProcessMark( hwnd, Instance, MarkPrint ); break; case MENU_ABOUT: ai.owner = hwnd; ai.inst = Instance; ai.name = AllocRCString( STR_ABOUT_NAME ); ai.version = AllocRCString( STR_ABOUT_VERSION ); ai.first_cr_year = "1993"; ai.title = AllocRCString( STR_ABOUT_TITLE ); DoAbout( &ai ); FreeRCString( ai.name ); FreeRCString( ai.version ); FreeRCString( ai.title ); break; case MENU_HELP_CONTENTS: if( !WHtmlHelp( hwnd, DR_CHM_FILE, HELP_CONTENTS, 0 ) ) { WWinHelp( hwnd, DR_HELP_FILE, HELP_CONTENTS, 0 ); } break; case MENU_HELP_SRCH: if( !WHtmlHelp( hwnd, DR_CHM_FILE, HELP_PARTIALKEY, (DWORD)"" ) ) { WWinHelp( hwnd, DR_HELP_FILE, HELP_PARTIALKEY, (DWORD)"" ); } break; case MENU_HELP_ON_HELP: WWinHelp( hwnd, HELP_HELP_FILE, HELP_HELPONHELP, 0 ); break; case MENU_TASK_CTL: DisplayProcList(); break; case MENU_LOG_CURRENT_STATE: MakeLog( NULL ); break; case MENU_ERASE_LOG_FILE: EraseLog(); break; case MENU_LOG_OPTIONS: SetLogOptions( hwnd ); break; case MENU_EXIT: SendMessage( hwnd, WM_CLOSE, 0, 0L ); break; default: MessageBox( hwnd, "This function is not yet available", AppName, MB_OK ); break; } break; case DR_DEBUG_EVENT: dbginfo = (CommunicationBuffer *)lparam; dbginfo->action = DebugEventHandler( &dbginfo->dbginfo ); break; case WM_COPYDATA: { COPYDATASTRUCT *copydata; copydata = (COPYDATASTRUCT *)lparam; ProcessCommandLine( copydata->lpData ); } break; case WM_CLOSE: if( QueryEnd( hwnd ) ) { SendMessage( hwnd, WM_DESTROY, 0, 0L ); } break; case WM_DESTROY: FiniListBox( MainLBox ); PutProfileInfo(); DestroyMonoFonts(); WWinHelp( hwnd, DR_HELP_FILE, HELP_QUIT, 0 ); PostQuitMessage( 0 ); break; default: return( DefWindowProc( hwnd, msg, wparam, lparam ) ); } return( 0L ); } /* WindowProc */
// The Main Window Procedure LRESULT CALLBACK mainWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CTLCOLORSTATIC: // Give Color Values to Buttons etc { // if ((HWND)lParam == standByChBox) // Check the button hBrushColor = CreateSolidBrush(RGB(255, 255, 255)); // White background is returned SetTextColor((HDC)wParam, RGB(0, 0, 0)); // Black foreground for text //SetTextColor((HDC)wParam, RGB(0x99, 0xB4, 0xD1)); SetBkColor((HDC)wParam, RGB(255, 255, 255)); // White background for text // Background color that is used to repaint the control (doesn't affect text background) return (LRESULT)hBrushColor; } //// RECT desktopRect,thisWindowRect; //// //// GetWindowRect(GetDesktopWindow(), &desktopRect); //// GetWindowRect(hwnd, &thisWindowRect); //// //// // Set the destination rect to the lower right corner of the screen //// desktopRect.left = desktopRect.right; //// desktopRect.top = desktopRect.bottom; //// //// // Animate //// DrawAnimatedRects(hwnd, IDANI_CAPTION, &thisWindowRect, &desktopRect); // // case WM_SYSCOMMAND: switch ( LOWORD(wParam) ) { case SC_MINIMIZE: // Minimize Button if (g_minToTray) // Minimize to Tray { // Show the notification icon Shell_NotifyIcon(NIM_ADD,¬ifyID); // Hide the window ShowWindow(hwnd,SW_HIDE); return 0; } else // Regular Minimaze return DefWindowProc(hwnd, msg, wParam, lParam); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } break; case WM_TRAYICON: if ( lParam == WM_LBUTTONDBLCLK ) { // Remove the icon from the system tray Shell_NotifyIcon(NIM_DELETE, ¬ifyID); // ..and show the window ShowWindow(hwnd, SW_SHOW); return 0; } // else if (lParam == WM_RBUTTONDOWN) // { // // CASE CONTEXT MENU // // } //return 0; //} break; case WM_COMMAND: // Menu Command switch(LOWORD(wParam)) { case ID_STANDBY_CHBOX: // Get standByChBox state if ( IsDlgButtonChecked( hwnd, ID_STANDBY_CHBOX )== BST_CHECKED ) setExecState(hwnd, 1); else setExecState(hwnd, 0); break; case ID_NOSLEEP_CHBOX: // Get noSleepChBox state { BOOL ch1,ch2; if ( IsDlgButtonChecked( hwnd, ID_STANDBY_CHBOX )== BST_CHECKED ) ch1=true; else ch1=false; if ( IsDlgButtonChecked( hwnd, ID_NOSLEEP_CHBOX )== BST_CHECKED ) ch2=true; else ch2=false; if ( ch1 && ch2 ) setExecState(hwnd, 2); else if ( ch1 && !ch2 ) setExecState(hwnd, 1); else setExecState(hwnd, 0); break; } case ID_SETTINGS_MINTOTRAY: // Chenge menu item check state { HMENU mainMenu = GetMenu(hwnd); UINT checkUncheck = (g_minToTray ? MF_UNCHECKED : MF_CHECKED); CheckMenuItem(mainMenu, ID_SETTINGS_MINTOTRAY, checkUncheck); g_minToTray = !g_minToTray; } break; // case ID_FILE_EXIT: // DestroyWindow(hwnd); // break; case ID_HELP_ABOUT: int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT_DLG), hwnd, AboutDlgProc ); if ( ret == -1) LastErrMsgBox(hwnd); break; } break; case WM_CLOSE: // Close Button Click DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { // this is the winmain function WNDCLASS winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // generic dc PAINTSTRUCT ps; // generic paintstruct // first fill in the window class stucture winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; // register the window class if (!RegisterClass(&winclass)) return(0); // create the window, note the test to see if WINDOWED_APP is // true to select the appropriate window flags if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class WINDOW_TITLE, // title (WINDOWED_APP ? (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION) : (WS_POPUP | WS_VISIBLE)), 0,0, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hinstance,// instance NULL))) // creation parms return(0); // save the window handle and instance in a global main_window_handle = hwnd; main_instance = hinstance; // resize the window so that client is really width x height if (WINDOWED_APP) { // now resize the window, so the client area is the actual size requested // since there may be borders and controls if this is going to be a windowed app // if the app is not windowed then it won't matter RECT window_rect = {0,0,WINDOW_WIDTH-1,WINDOW_HEIGHT-1}; // make the call to adjust window_rect AdjustWindowRectEx(&window_rect, GetWindowStyle(main_window_handle), GetMenu(main_window_handle) != NULL, GetWindowExStyle(main_window_handle)); // save the global client offsets, they are needed in DDraw_Flip() window_client_x0 = -window_rect.left; window_client_y0 = -window_rect.top; // now resize the window with a call to MoveWindow() MoveWindow(main_window_handle, 0, // x position 0, // y position window_rect.right - window_rect.left, // width window_rect.bottom - window_rect.top, // height FALSE); // show the window, so there's no garbage on first render ShowWindow(main_window_handle, SW_SHOW); } // end if windowed // perform all game console specific initialization Game_Init(); // disable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, NULL, 0); // enter main event loop while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // shutdown game and release all resources Game_Shutdown(); // enable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, NULL, 0); // return to Windows like this return(msg.wParam); } // end WinMain
int PASCAL wWinMain(HINSTANCE hInstC, HINSTANCE hInstP, LPWSTR lpCmdLine, int nCmdShow) { MSG msg={0}; WNDCLASS wc; // Initialize COM if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { Msg(TEXT("CoInitialize Failed!\r\n")); return FALSE; } // Verify that the VMR is present on this system if(!VerifyVMR9()) return FALSE; // Was a filename specified on the command line? if(lpCmdLine[0] != '\0') { (void)StringCchCopy(g_szFileName, NUMELMS(g_szFileName), lpCmdLine); } // Set initial media state g_psCurrent = Init; // Register the window class ZeroMemory(&wc, sizeof wc); ghInst = wc.hInstance = hInstC; wc.lpfnWndProc = WndMainProc; wc.lpszClassName = CLASSNAME; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = NULL; if(!RegisterClass(&wc)) { Msg(TEXT("RegisterClass Failed! Error=0x%x\r\n"), GetLastError()); CoUninitialize(); exit(1); } // Create the main window. The WS_CLIPCHILDREN style is required. ghApp = CreateWindow(CLASSNAME, APPLICATIONNAME, WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, DEFAULT_AUDIO_WIDTH, DEFAULT_AUDIO_HEIGHT, 0, 0, ghInst, 0); if(ghApp) { // Save menu handle for later use ghMenu = GetMenu(ghApp); EnablePlaybackMenu(FALSE); // If a media file was specified on the command line, open it now. // (If the first character in the string isn't NULL, post an open clip message.) if (g_szFileName[0] != 0) PostMessage(ghApp, WM_COMMAND, ID_FILE_OPENCLIP, 0); // Main message loop while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } else { Msg(TEXT("Failed to create the main window! Error=0x%x\r\n"), GetLastError()); } // Finished with COM CoUninitialize(); return (int) msg.wParam; }
// // This is the Window Procedure for handling windows messages // LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps ; static RECT rect ; // region of client window static HMENU hMenu; // handle to menu static INT currentSelection = 0; // current menu selection static int x=0, y=0; static HWND hButton[4]; // the button windows static HWND hButtonICE; // the "ICE" Button static HDC hdc; HRGN hRgn; // region to allow for drawing switch (message) { case WM_CREATE: GetClientRect(hwnd, &rect); hButton[0] = CreateWindow(TEXT("BUTTON"), TEXT("1"), WS_CHILD| WS_VISIBLE | BS_AUTORADIOBUTTON, 100,80,30,200, hwnd, (HMENU)(ID_SELECTSTICK_STICK1 ), ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButton[1] = CreateWindow(TEXT("BUTTON"), TEXT("2"), WS_CHILD| WS_VISIBLE | BS_AUTORADIOBUTTON, 140,280,200,30, hwnd, (HMENU)(ID_SELECTSTICK_STICK2), ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButton[2] = CreateWindow(TEXT("BUTTON"), TEXT("3"), WS_CHILD | WS_VISIBLE | BS_CENTER | BS_AUTORADIOBUTTON, 340,80,30,200, hwnd, (HMENU)(ID_SELECTSTICK_STICK3 ), ((LPCREATESTRUCT)lParam)->hInstance, NULL); hButton[3] = CreateWindow(TEXT("BUTTON"), TEXT("4"), WS_CHILD |WS_VISIBLE | BS_AUTORADIOBUTTON, 215,320,30,200, hwnd, (HMENU)(ID_SELECTSTICK_STICK4), ((LPCREATESTRUCT)lParam)->hInstance, NULL); // fill end here // Initialize menu and button selections. hMenu = GetMenu(hwnd); // handle to menu currentSelection = ID_BASE; // start with cheese CheckMenuItem(hMenu, currentSelection, MF_CHECKED); // check menu SendMessage(hButton[currentSelection-ID_BASE], BM_SETCHECK, 1,0); // check button // Create the "ICE" push button hButtonICE = CreateWindow(TEXT("BUTTON"), // button class TEXT("ICE"), // window name WS_CHILD | WS_VISIBLE | BS_MULTILINE | BS_PUSHBUTTON, // pushbutton style child window 210,200, // location bottom right 50,50, hwnd, (HMENU) ID_ICE, // unique child window id ((LPCREATESTRUCT)lParam)->hInstance, NULL); wpOriginalWndProc = (WNDPROC) SetWindowLong(hButtonICE, // subclass to use ICE proc GWL_WNDPROC, (LONG) NewButtonWndProc); // to take over original wndproc return 0; case WM_RBUTTONDOWN: // Get position of cursor when right-click happened. // Call GetClientRect() to get dimensions of the stick. // Call MoveWindow() to move to new position // fill start here x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); GetWindowRect (hButton[currentSelection-ID_BASE], &rect); MoveWindow(hButton[currentSelection-ID_BASE], x, y, rect.right-rect.left, rect.bottom-rect.top, true); // fill end here return 0; case WM_CHAR: // WM_CHAR is generated when keyboard character is pressed. // This message is sent to the window that has focus, or the // default active/parent window. // When a Number Key 1-4 is pressed, we will send a WM_COMMAND message // to parent window and act "as if" a radio/menu selection was made. // fill start here switch (wParam) { case '1': SendMessage(hwnd,WM_COMMAND, (WPARAM)ID_SELECTSTICK_STICK1, lParam); break; case '2': SendMessage(hwnd,WM_COMMAND, (WPARAM)ID_SELECTSTICK_STICK2, lParam); break; case '3': SendMessage(hwnd,WM_COMMAND, (WPARAM)ID_SELECTSTICK_STICK3, lParam); break; case '4': SendMessage(hwnd,WM_COMMAND, (WPARAM)ID_SELECTSTICK_STICK4, lParam); break; } // fill end here return 0; case WM_COMMAND: // WM_COMMAND is sent from child to parent window when // a menu checkbox is checked (LOWORD(wParam) is menu checkbox ID) // or when a pushbutton is clicked (LOWORD(wParam) is child window ID). if (LOWORD(wParam) == ID_ICE) { SetFocus(hButtonICE); ShowWindow(hButtonICE, SW_SHOW); } else if (LOWORD(wParam) != ID_ICE) { // synchronize radio and menu buttons here // start fill here // deselect Menu item - CheckMenuItem(hMenu, currentSelection, MF_UNCHECKED); //radio button SendMessage(hButton[currentSelection - ID_BASE], BM_SETCHECK, MF_UNCHECKED, 0); //update current selection currentSelection = LOWORD(wParam); //select menu item CheckMenuItem(hMenu, currentSelection, MF_CHECKED); //select radio button SendMessage(hButton[currentSelection -ID_BASE], BM_SETCHECK, MF_CHECKED, 0); SetFocus(hwnd); } return 0; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ; rect.top = rect.bottom - 50; DrawText (hdc, TEXT ("Instructions: Select stick with menu, radio button, or keyboard numbers 1-4\n Move stick with right-click."), -1, &rect, DT_LEFT | DT_CENTER) ; rect.top = 0; DrawText (hdc, TEXT ("Goal: Use 2 moves to get ICE out of the glass."), -1, &rect, DT_LEFT | DT_CENTER) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
void CMainFrame::OnCreate(WPARAM wParam, LPARAM lParam) { // Create MDI client window CLIENTCREATESTRUCT ccs; ccs.hWindowMenu = GetSubMenu(GetMenu(m_hWnd), 5); ccs.idFirstChild = 3; m_hClient = CreateWindow("MDICLIENT", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL, 0, 0, 0, 0, m_hWnd, (HMENU)IDR_CLIENT, NULL, &ccs); // Create status bar m_hStatus = CreateStatusWindow(WS_VISIBLE | WS_CHILD | SBARS_SIZEGRIP, "Stopped", m_hWnd, IDR_STATUS); // Create rebar m_hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE |WS_BORDER| WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER | RBS_AUTOSIZE | RBS_VARHEIGHT | RBS_BANDBORDERS, 0, 0, 0, 0, m_hWnd, (HMENU)IDR_REBAR, NULL, NULL); // Initialize rebar REBARINFO rbi; rbi.cbSize = sizeof(REBARINFO); ZeroMemory(&rbi, sizeof(REBARINFO)); SendMessage(m_hRebar, RB_SETBARINFO, 0, (LPARAM)&rbi); // Load toolbar from resource m_hToolbar = LoadToolbar(NULL, TBSTYLE_FLAT | TBSTYLE_WRAPABLE | CCS_NODIVIDER |CCS_NOPARENTALIGN | CCS_NORESIZE , IDR_TOOLBAR, m_hRebar); // Insert toolbar into rebar SIZE size; REBARBANDINFO rbbi; SendMessage(m_hToolbar, TB_GETMAXSIZE, 0, (LPARAM)&size); ZeroMemory(&rbbi, sizeof(REBARBANDINFO)); rbbi.cbSize = sizeof(REBARBANDINFO); rbbi.fMask = RBBIM_CHILD| RBBIM_CHILDSIZE | RBBIM_STYLE; rbbi.fStyle = RBBS_GRIPPERALWAYS; rbbi.hwndChild = m_hToolbar; rbbi.cxMinChild = size.cx; rbbi.cyMinChild = size.cy; SendMessage(m_hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbbi); // TODO: Load and set window icon m_hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_APP)); SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)m_hIcon); SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)m_hIcon); // Open command argument file if exists and valid if (__argc == 2) { // Create default model window m_pMainWnd = new CModelView(this, new CModelDoc); // Assign file name m_sFileName = __argv[1]; // Open target file fstream file; file.open(__argv[1], ios::in|ios::binary); // Load data from file if (m_pMainWnd->m_pDocument->Load(&file) == FALSE) { // If error, clean file name m_sFileName.clear(); // Create the window m_pMainWnd->Create("Root Document", m_hClient); // Release error data m_pMainWnd->OnDestroy(0, 0); m_pMainWnd = NULL; } else { // Create the window m_pMainWnd->Create("Root Document", m_hClient); // Compile blocks m_pMainWnd->m_pDocument->Compile(); // Update document m_pMainWnd->m_pDocument->Update(); m_pMainWnd->m_pDocument->Check(); // Update window InvalidateRect(m_pMainWnd->m_hWnd, NULL, TRUE); } // End of file operating file.close(); } }
RchooseDialog::RchooseDialog(ProfileDocInf *d,int den) { short iType; Handle iHandle; Rect iRect; long id; int i; MenuHandle menuH; int which; doc = d; density = den; _which = doc->defaults->input_type; _which_patch = doc->defaults->patch_format; _which_port = doc->defaults->port; if (_which == DT_None) _which = DT_TechkonSP820; switch (_which) { case DT_TiffFile: which = DataFile; break; case DT_DTP51: which = DTP51; break; case DT_XriteDTP41: which = DTP41; break; case DT_TechkonCP300: which = TechkonCP300; break; case DT_TechkonSP820: which = TechkonSP820; break; case DT_TechkonTCRCP300: which = TechkonTCRCP300; break; case DT_TechkonTCRSP820: which = TechkonTCRSP820; break; case DT_GretagHand: which = GretagHand; break; case DT_GretagTable: which = GretagTable; break; case DT_Xrite408: which = XR408; break; } setDialog(Rchoose_Dialog); frame_button(); for (i=0; i<MAX_PATCH_NAMES; i++) { convert[i] = 0; convert2[i] = 0; } GetDItem (dialogptr, FileType, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,which); if ((XR408 != -1) && (!density)) { menuH = GetMenu(DeviceMenuID); DisableItem(menuH,XR408); } setDialogState(); }
void UpdateMenus() { HMENU menu = GetMenu(GetHWND()); #define CHECKITEM(item,value) CheckMenuItem(menu,item,MF_BYCOMMAND | ((value) ? MF_CHECKED : MF_UNCHECKED)); CHECKITEM(ID_EMULATION_SPEEDLIMIT,g_Config.bSpeedLimit); // CHECK(ID_OPTIONS_ENABLEFRAMEBUFFER,g_Config.bEnableFrameBuffer); // CHECK(ID_OPTIONS_EMULATESYSCALL,g_bEmulateSyscall); CHECKITEM(ID_OPTIONS_DISPLAYRAWFRAMEBUFFER, g_Config.bDisplayFramebuffer); CHECKITEM(ID_OPTIONS_IGNOREILLEGALREADS,g_Config.bIgnoreBadMemAccess); CHECKITEM(ID_CPU_INTERPRETER,g_Config.bJit == false); CHECKITEM(ID_CPU_DYNAREC,g_Config.bJit == true); CHECKITEM(ID_OPTIONS_BUFFEREDRENDERING, g_Config.bBufferedRendering); CHECKITEM(ID_OPTIONS_SHOWDEBUGSTATISTICS, g_Config.bShowDebugStats); CHECKITEM(ID_OPTIONS_HARDWARETRANSFORM, g_Config.bHardwareTransform); CHECKITEM(ID_OPTIONS_FASTMEMORY, g_Config.bFastMemory); CHECKITEM(ID_OPTIONS_SIMPLE2XSSAA, g_Config.SSAntiAliasing); CHECKITEM(ID_OPTIONS_STRETCHDISPLAY, g_Config.bStretchToDisplay); CHECKITEM(ID_EMULATION_RUNONLOAD, g_Config.bAutoRun); CHECKITEM(ID_OPTIONS_USEVBO, g_Config.bUseVBO); CHECKITEM(ID_OPTIONS_VERTEXCACHE, g_Config.bVertexCache); CHECKITEM(ID_OPTIONS_SHOWFPS, g_Config.iShowFPSCounter); CHECKITEM(ID_OPTIONS_FRAMESKIP, g_Config.iFrameSkip != 0); CHECKITEM(ID_OPTIONS_MIPMAP, g_Config.bMipMap); CHECKITEM(ID_OPTIONS_VSYNC, g_Config.iVSyncInterval != 0); CHECKITEM(ID_OPTIONS_TOPMOST, g_Config.bTopMost); CHECKITEM(ID_EMULATION_SOUND, g_Config.bEnableSound); CHECKITEM(ID_TEXTURESCALING_DEPOSTERIZE, g_Config.bTexDeposterize); static const int zoomitems[4] = { ID_OPTIONS_SCREEN1X, ID_OPTIONS_SCREEN2X, ID_OPTIONS_SCREEN3X, ID_OPTIONS_SCREEN4X, }; for (int i = 0; i < 4; i++) { CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom - 1) ? MF_CHECKED : MF_UNCHECKED)); } static const int texscalingitems[] = { ID_TEXTURESCALING_OFF, ID_TEXTURESCALING_2X, ID_TEXTURESCALING_3X, ID_TEXTURESCALING_4X, ID_TEXTURESCALING_5X, }; for (int i = 0; i < 5; i++) { CheckMenuItem(menu, texscalingitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingLevel-1) ? MF_CHECKED : MF_UNCHECKED)); } static const int texscalingtypeitems[] = { ID_TEXTURESCALING_XBRZ, ID_TEXTURESCALING_HYBRID, ID_TEXTURESCALING_BICUBIC, ID_TEXTURESCALING_HYBRID_BICUBIC, }; for (int i = 0; i < 4; i++) { CheckMenuItem(menu, texscalingtypeitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingType) ? MF_CHECKED : MF_UNCHECKED)); } static const int texfilteringitems[] = { ID_OPTIONS_TEXTUREFILTERING_AUTO, ID_OPTIONS_NEARESTFILTERING, ID_OPTIONS_LINEARFILTERING, ID_OPTIONS_LINEARFILTERING_CG, }; for (int i = 0; i < 4; i++) { int texFilterLevel = i > 0? (g_Config.iTexFiltering - 1) : g_Config.iTexFiltering; CheckMenuItem(menu, texfilteringitems[i], MF_BYCOMMAND | ((i == texFilterLevel) ? MF_CHECKED : MF_UNCHECKED)); } UpdateCommands(); }
void RchooseDialog::setDialogState(void) { int i,m; MenuHandle menuH; short menucount; short item; short iType; Handle iHandle; Rect iRect; switch (_which) { case DT_TiffFile: if (DataFile < 0) _which = 1; break; case DT_DTP51: if (DTP51 < 0) _which = 1; break; case DT_XriteDTP41: if (DTP41 < 0) _which = 1; break; case DT_TechkonCP300: if (TechkonCP300 < 0) _which = 1; break; case DT_TechkonSP820: if (TechkonSP820 < 0) _which = 1; break; case DT_TechkonTCRCP300: if (TechkonTCRCP300 < 0) _which = 1; break; case DT_TechkonTCRSP820: if (TechkonTCRSP820 < 0) _which = 1; break; case DT_GretagHand: if (GretagHand < 0) _which = 1; break; case DT_GretagTable: if (GretagTable < 0) _which = 1; break; case DT_Xrite408: if (XR408 < 0) _which = 1; break; } switch (_which) { case (DT_DataFile): Disable(dialogptr,PatchFormat); Disable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); _which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_patch); DrawControls(dialogptr); break; case (DT_DTP51): Enable(dialogptr,PatchFormat); Enable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); m = 1; for (i=0; i<doc->patchset->filenum; i++) { if (doc->patchset->patches[i] != NULL) { if ( doc->patchset->patches[i]->patches.strips == 1) { convert[m] = i; convert2[i] = m; InsMenuItem(menuH, doc->patchset->patchames[i], m++); } } } //_which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]); GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_port); DrawControls(dialogptr); break; case (DT_TiffFile): Enable(dialogptr,PatchFormat); Disable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); m = 1; for (i=0; i<doc->patchset->filenum; i++) { if (doc->patchset->patches[i] != NULL) { if (doc->patchset->patches[i]->patches.strips == 0) { convert[m] = i; convert2[i] = m; InsMenuItem(menuH, doc->patchset->patchames[i], m++); } } } //_which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]); GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_port); DrawControls(dialogptr); break; case (DT_TechkonCP300): case (DT_TechkonSP820): case (DT_TechkonTCRCP300): case (DT_TechkonTCRSP820): case (DT_GretagHand): case (DT_GretagTable): Enable(dialogptr,PatchFormat); Enable(dialogptr,DevicePort); menuH = GetMenu(Table_menu); menucount = CountMItems(menuH); for( i = menucount; i > 0; i-- ) DelMenuItem(menuH,i); m = 1; for (i=0; i<doc->patchset->filenum; i++) { if (doc->patchset->patches[i] != NULL) { if (doc->patchset->patches[i]->patches.strips == 0) { convert[m] = i; convert2[i] = m; InsMenuItem(menuH, doc->patchset->patchames[i], m++); } } } //_which_patch = 1; GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]); GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect); SetCtlValue((ControlHandle)iHandle,_which_port); DrawControls(dialogptr); break; case (DT_Xrite408): Disable(dialogptr,PatchFormat); break; } if ((!density) && (_which == DT_Xrite408)) Disable(dialogptr,1); else Enable(dialogptr,1); }
// // 関数: 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 HWND boardWnd, hBut[2]; // レバーコントロールのハンドル INITCOMMONCONTROLSEX ic; // INITCOMMONCONTROLSEX構造体 REBARBANDINFO rbBand; // REBARBANDINFO構造体 switch (message) { case WM_CREATE: /* ボード表示ウィンドウの作成 */ //boardWnd = MakeBoardWindow(hWnd); /* レバーコントロールの作成 */ ic.dwSize = sizeof(INITCOMMONCONTROLSEX); ic.dwICC = ICC_COOL_CLASSES; InitCommonControlsEx(&ic); hRebar = MakeMyRebar(hWnd); hListBox = CreateListBox(hWnd); ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_TEXT | RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; rbBand.fStyle = RBBS_CHILDEDGE | RBBS_NOGRIPPER; rbBand.cxMinChild = 90; rbBand.cyMinChild = 25; rbBand.hwndChild = CreateWindow("BUTTON", "新規対局", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)NEWGAME_BT, hInst ,NULL); SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.hwndChild = CreateWindow("BUTTON", "継続対局", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)CONTINUE_BT, hInst ,NULL); SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.hwndChild = CreateWindow("BUTTON", "中断", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)INTERRUPT_BT, hInst ,NULL); rbBand.cxMinChild = 60; SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.hwndChild = CreateWindow("BUTTON", "手番変更", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)CHANGE_BT, hInst ,NULL); rbBand.cxMinChild = 90; SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.cxMinChild = 30; rbBand.hwndChild = CreateWindow("BUTTON", "<<", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)FIRST_BT, hInst ,NULL); SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.hwndChild = CreateWindow("BUTTON", "←", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)UNDO_BT, hInst ,NULL); SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.hwndChild = CreateWindow("BUTTON", "→", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)REDO_BT, hInst ,NULL); SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); rbBand.hwndChild = CreateWindow("BUTTON", ">>", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hRebar, (HMENU)FINAL_BT, hInst ,NULL); SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); //hToolBar = CreateToolbarEx( // hWnd, //親ウィンドウ // WS_CHILD | WS_VISIBLE, //ウィンドウスタイル // ID_TOOLBAR, //コントロールID // 8, //イメージの数 // hInst, // ID_MYBMP, // tbb, // 8, // ボタンの数 // 0, //ボタンの幅 // 0, //ボタンの高さ // 18, //イメージの幅 // 18, //イメージの高さ // sizeof(TBBUTTON)); //SendMessage(hToolBar, TB_INSERTBUTTON, 2, (LPARAM)&tb); hComBox1 = CreateComBox1(hWnd, BOARD_SIZE + 10, 90, 0); SendMessage(hComBox1, CB_SETCURSEL, 0, 0); hComBox2 = CreateComBox1(hWnd, BOARD_SIZE + 10, 120, 1); SendMessage(hComBox2, CB_SETCURSEL, 1, 0); hComBox3 = CreateComBox2(hWnd, BOARD_SIZE + 100, 90, 2); ShowWindow(hComBox3, SW_HIDE); hComBox4 = CreateComBox2(hWnd, BOARD_SIZE + 100, 120, 3); player[0] = HUMAN; player[1] = CPU; /* 初期難易度 */ Onnormal(hWnd, BLACK); Onnormal(hWnd, WHITE); ShowWindow(hListBox, SW_SHOW); //リストボックスを表示 UpdateWindow(hWnd); UpdateWindow(hRebar); //srand((unsigned int)time(NULL)); /* ステータスバー作成 */ hStatus = CreateStatusBar(hWnd); /* 定石データオープン */ open_book_thread(hInst); break; case WM_LBUTTONDOWN: /* 左クリックイベント 打てるマスをクリックすればスレッドが起動 */ if(!AI_THINKING && chk_range_board(lParam)) { Flag_Abort = TRUE; WaitForSingleObject(SIG_HINT_FINISHED, INFINITE); Flag_Abort = FALSE; GameThread(lParam, LBUTTON); } SendMessage(hStatus, SB_SETTEXT, (WPARAM)1 | 0, (LPARAM)turn_str[NowTurn]); return 0; case WM_RBUTTONDOWN: RButtonClick(hWnd, hStatus, lParam); return 0; case WM_SET_TEXT_BAR: SendMessage(hStatus, SB_SETTEXT, (WPARAM)0 | 3, (LPARAM)lParam); return 0; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // 選択されたメニューの解析: switch (wmId) { /* コンボボックス */ case IDC_COM1: /* 変更された */ if(HIWORD(wParam) == CBN_SELCHANGE) { int index = SendMessage(hComBox1, CB_GETCURSEL, 0, 0); /* 人間を選択 */ if(index == 0) { player[0] = HUMAN; CpuColor = WHITE; ShowWindow(hComBox3, SW_HIDE); } /* CPUを選択 */ else { player[0] = CPU; CpuColor = BLACK; ShowWindow(hComBox3, SW_SHOW); } } break; case IDC_COM2: /* 変更された */ if(HIWORD(wParam) == CBN_SELCHANGE) { int index = SendMessage(hComBox2, CB_GETCURSEL, 0, 0); /* 人間を選択 */ if(index == 0) { player[1] = HUMAN; CpuColor = BLACK; ShowWindow(hComBox4, SW_HIDE); } /* CPUを選択 */ else { player[1] = CPU; CpuColor = WHITE; ShowWindow(hComBox4, SW_SHOW); } } break; case IDC_COM3: /* 変更された */ if(HIWORD(wParam) == CBN_SELCHANGE) { int index = SendMessage(hComBox3, CB_GETCURSEL, 0, 0); /* 難易度 */ switch(index) { case 0: OnVeasy(hWnd, BLACK); break; case 1: Oneasy(hWnd, BLACK); break; case 2: Onnormal(hWnd, BLACK); break; case 3: Onhard(hWnd, BLACK); break; case 4: OnVhard(hWnd, BLACK); break; case 5: OnUhard(hWnd, BLACK); break; case 6: OnSUhard(hWnd, BLACK); break; case 7: OnSSUhard(hWnd, BLACK); break; case 8: OnHUhard(hWnd, BLACK); break; case 9: OnUltra(hWnd, BLACK); break; case 10: OnSUltra(hWnd, BLACK); break; case 11: OnSSUltra(hWnd, BLACK); break; case 12: OnAllSearchWin(hWnd, BLACK); break; case 13: OnAllSearchSD(hWnd, BLACK); break; } } break; case IDC_COM4: /* 変更された */ if(HIWORD(wParam) == CBN_SELCHANGE) { int index = SendMessage(hComBox4, CB_GETCURSEL, 0, 0); /* 難易度 */ switch(index) { case 0: OnVeasy(hWnd, WHITE); break; case 1: Oneasy(hWnd, WHITE); break; case 2: Onnormal(hWnd, WHITE); break; case 3: Onhard(hWnd, WHITE); break; case 4: OnVhard(hWnd, WHITE); break; case 5: OnUhard(hWnd, WHITE); break; case 6: OnSUhard(hWnd, WHITE); break; case 7: OnSSUhard(hWnd, WHITE); break; case 8: OnHUhard(hWnd, WHITE); break; case 9: OnUltra(hWnd, WHITE); break; case 10: OnSUltra(hWnd, WHITE); break; case 11: OnSSUltra(hWnd, WHITE); break; case 12: OnAllSearchWin(hWnd, WHITE); break; case 13: OnAllSearchSD(hWnd, WHITE); break; } } break; case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; case NEWGAME_BT: case StartNew: InitBoard(); /* 置換表の取得 */ HashDelete(ghash); ghash = HashNew(21); HashClear(ghash); /* 再描写 */ hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, -1, -1); ReleaseDC(hWnd, hdc); GameThread(lParam, STARTGAME); return DefWindowProc(hWnd, message, wParam, lParam); case CONTINUE_BT: /* 置換表の取得 */ if(ghash == NULL){ HashDelete(ghash); ghash = HashNew(21); HashClear(ghash); } if(NowTurn == BLACK) { /* 再描写 */ hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, -1, -1); ReleaseDC(hWnd, hdc); NowTurn = BLACK; GameThread(lParam, STARTGAME); return DefWindowProc(hWnd, message, wParam, lParam); } else { hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, -1, -1); ReleaseDC(hWnd, hdc); NowTurn = WHITE; GameThread(lParam, STARTGAME); return DefWindowProc(hWnd, message, wParam, lParam); } case StartContinue_B: /* 再描写 */ hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, -1, -1); ReleaseDC(hWnd, hdc); NowTurn = BLACK; GameThread(lParam, STARTGAME); return DefWindowProc(hWnd, message, wParam, lParam); case StartContinue_W: hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, -1, -1); ReleaseDC(hWnd, hdc); NowTurn = WHITE; GameThread(lParam, STARTGAME); return DefWindowProc(hWnd, message, wParam, lParam); /*case Veasy: Force_SearchWin = FALSE; Force_SearchSD = FALSE; OnVeasy(hWnd); break; case easy: Force_SearchWin = FALSE; Force_SearchSD = FALSE; Oneasy(hWnd); break; case normal: Force_SearchWin = FALSE; Force_SearchSD = FALSE; Onnormal(hWnd); break; case hard: Force_SearchWin = FALSE; Force_SearchSD = FALSE; Onhard(hWnd); break; case Vhard: Force_SearchWin = FALSE; Force_SearchSD = FALSE; OnVhard(hWnd); break; case Uhard: Force_SearchWin = FALSE; Force_SearchSD = FALSE; OnUhard(hWnd); break; case AllWinLoss: Force_SearchWin = TRUE; OnAllSearchWin(hWnd); break; case AllStoneDiff: Force_SearchSD = TRUE; Force_SearchWin = FALSE; OnAllSearchSD(hWnd); break;*/ case book_switch: if(!UseBook) { UseBook = TRUE; m_FlagBook = TRUE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, book_switch, MFS_CHECKED); } else { UseBook = FALSE; m_FlagBook = FALSE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, book_switch, MFS_UNCHECKED); } break; case book_best: if(!b_Flag_not_change) { HMENU hMenu = GetMenu(hWnd); UncheckedAll_BookMenu(hMenu); b_Flag_not_change = TRUE; CheckMenuItem(hMenu, book_best, MFS_CHECKED); } break; case book_little_change: if(!b_Flag_little_change) { HMENU hMenu = GetMenu(hWnd); UncheckedAll_BookMenu(hMenu); b_Flag_little_change = TRUE; CheckMenuItem(hMenu, book_little_change, MFS_CHECKED); } break; case book_change: if(!b_Flag_change) { HMENU hMenu = GetMenu(hWnd); UncheckedAll_BookMenu(hMenu); b_Flag_change = TRUE; CheckMenuItem(hMenu, book_change, MFS_CHECKED); } break; case book_random: { HMENU hMenu = GetMenu(hWnd); UncheckedAll_BookMenu(hMenu); CheckMenuItem(hMenu, book_random, MFS_CHECKED); } break; /*case CorrectSt: PrintCorrectSt(hWnd); return DefWindowProc(hWnd, message, wParam, lParam);*/ case rotate90: m_FlagInGame = FALSE; black = rotate_90(black); white = rotate_90(white); { BitBoard move = one << (move_x * 8 + move_y); move = rotate_90(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case rotate180: m_FlagInGame = FALSE; black = rotate_180(black); white = rotate_180(white); { BitBoard move = one << (move_x * 8 + move_y); move = rotate_180(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case rotate270: m_FlagInGame = FALSE; black = rotate_270(black); white = rotate_270(white); { BitBoard move = one << (move_x * 8 + move_y); move = rotate_270(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case symX: m_FlagInGame = FALSE; black = symmetry_x(black); white = symmetry_x(white); { BitBoard move = one << (move_x * 8 + move_y); move = symmetry_x(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case symY: m_FlagInGame = FALSE; black = symmetry_y(black); white = symmetry_y(white); { BitBoard move = one << (move_x * 8 + move_y); move = symmetry_y(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case symBL: m_FlagInGame = FALSE; black = symmetry_b(black); white = symmetry_b(white); { BitBoard move = one << (move_x * 8 + move_y); move = symmetry_b(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case symWL: m_FlagInGame = FALSE; black = symmetry_w(black); white = symmetry_w(white); { BitBoard move = one << (move_x * 8 + move_y); move = symmetry_w(move); int pos = CountBit((move & (-(signed long long int)move)) - 1); move_x = pos / 8; move_y = pos % 8; } break; case BoardInit: InitBoard(); { /* メニューバーの各項目の有効無効化 */ HMENU hMenu = GetMenu(hWnd); EnableMenuItem(hMenu, interrupt, MFS_GRAYED); EnableMenuItem(hMenu, EditBoard, MFS_ENABLED); EnableMenuItem(hMenu, ChangeColor, MFS_ENABLED); } break; case EditBoard: Flag_Edit = TRUE; break; case INTERRUPT_BT: case interrupt: if(AI_THINKING /*|| m_FlagHint */) { Flag_Abort = TRUE; } else { Interrupt_flag = TRUE; m_FlagInterrupt = TRUE; m_FlagInGame = FALSE; } { HMENU hMenu = GetMenu(hWnd); EnableMenuItem(hMenu, interrupt, MFS_GRAYED); hMenu = GetMenu(hWnd); EnableMenuItem(hMenu, EditBoard, MFS_ENABLED); EnableMenuItem(hMenu, ChangeColor, MFS_ENABLED); } break; case CHANGE_BT: case ChangeColor: CpuColor ^= 1; break; case print_result: if(!AI_result) { AI_result = TRUE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, print_result, MFS_CHECKED); } else { AI_result = FALSE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, print_result, MFS_UNCHECKED); } break; case print_AI_moves: /*if(!AI_thinking) { AI_thinking = TRUE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, print_AI_moves, MFS_CHECKED); } else { AI_thinking = FALSE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, print_AI_moves, MFS_UNCHECKED); }*/ break; case print_thinking: /* if(!OnTheWay) { OnTheWay = TRUE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, print_thinking, MFS_CHECKED); } else { OnTheWay = FALSE; HMENU hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, print_thinking, MFS_UNCHECKED); }*/ break; case Auto_Learn: //InitBoard(); //{ // int i = 0; // while(i < 1) // { // Learn_Thread(); // //Start_Auto_Learn(4, 13, 100000, -1); // i++; // } //} break; case 32849: /*{ Learn_Thread(); }*/ break; case auto_g: m_FlagInterrupt = FALSE; Interrupt_flag = FALSE; auto_game_thread(); break; case UNDO_BT: case Undo: if(turn == 0 || (UndoBoard_B[turn - 1] == 0 && UndoBoard_W[turn - 1] == 0)) { break; } m_FlagInGame = FALSE; if(AI_THINKING /* || m_FlagHint */) { Flag_Abort = TRUE; } /* ヒント用の評価データ破棄 */ /*{ for(int i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;} }*/ black = UndoBoard_B[turn - 1]; white = UndoBoard_W[turn - 1]; move_x = Undo_x[turn - 1]; move_y = Undo_y[turn - 1]; NowTurn = Undo_color[turn - 1]; turn--; SendMessage(hListBox, LB_SETCURSEL, turn - 1, 0); if(turn - 1 < 0 || (UndoBoard_B[turn - 1] == 0 && UndoBoard_W[turn - 1] == 0)) { EnableMenuItem(GetMenu(hWnd), Undo, MFS_GRAYED); EnableWindow(GetDlgItem(hRebar, UNDO_BT), FALSE); } if(!(UndoBoard_B[turn + 1] == 0 && UndoBoard_W[turn + 1] == 0) || turn + 1 <= 60) { EnableMenuItem(GetMenu(hWnd), Redo, MFS_ENABLED); EnableWindow(GetDlgItem(hRebar, REDO_BT), TRUE); } break; case REDO_BT: case Redo: if(turn == 60 || UndoBoard_B[turn + 1] == 0 && UndoBoard_W[turn + 1] == 0) { break; } m_FlagInGame = FALSE; /* ヒント用の評価データ破棄 */ /*{ for(int i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;} }*/ SendMessage(hListBox, LB_SETCURSEL, turn, 0); black = UndoBoard_B[turn + 1]; white = UndoBoard_W[turn + 1]; move_x = Undo_x[turn + 1]; move_y = Undo_y[turn + 1]; NowTurn = Undo_color[turn + 1]; turn++; if((UndoBoard_B[turn + 1] == 0 && UndoBoard_W[turn + 1] == 0) || turn + 1 > 60) { EnableMenuItem(GetMenu(hWnd), Redo, MFS_GRAYED); EnableWindow(GetDlgItem(hRebar, REDO_BT), FALSE); } if(turn - 1 >= 0 || !(UndoBoard_B[turn - 1] == 0 && UndoBoard_W[turn - 1] == 0)) { EnableMenuItem(GetMenu(hWnd), Undo, MFS_ENABLED); EnableWindow(GetDlgItem(hRebar, UNDO_BT), TRUE); } break; case FIRST_BT: { int i; for(i = 0; i < 60; i++) { if(UndoBoard_B[i] != 0 || UndoBoard_W[i] != 0) { black = UndoBoard_B[i]; white = UndoBoard_W[i]; move_x = Undo_x[i]; move_y = Undo_y[i]; NowTurn = Undo_color[i]; turn = i; /* ヒント用の評価データ破棄 */ //for(i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;} m_FlagInGame = FALSE; break; } } } break; case FINAL_BT: { int i; for(i = 60; i >= 0; i--) { if(UndoBoard_B[i] != 0 || UndoBoard_W[i] != 0) { black = UndoBoard_B[i]; white = UndoBoard_W[i]; move_x = Undo_x[i]; move_y = Undo_y[i]; NowTurn = Undo_color[i]; turn = i; /* ヒント用の評価データ破棄 */ //for(i = 0; i < 32; i++){ EvalData[i] = NEGAMAX;} m_FlagInGame = FALSE; break; } } } break; case Hint_0: OnHint_0(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case Hint_1: OnHint_1(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case Hint_2: OnHint_2(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case Hint_3: OnHint_3(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case Hint_4: OnHint_4(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case Hint_5: OnHint_5(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case Hint_6: OnHint_6(hWnd); HINT_DISPED = FALSE; GameThread(0, HINTONLY); break; case print_eval: //read_eval_table(CountBit(black | white) - 4); if(turn == 0){ break; } //read_eval_table(turn - 1); if(NowTurn == BLACK){ init_index_board(black, white); GetEvalFromPattern(black, white, NowTurn, turn - 1); } else{ init_index_board(white, black); GetEvalFromPattern(white, black, NowTurn, turn - 1); } { char eval_msg[PATTERN_NUM + 1][64]; sprintf_s(eval_msg[0], "hori_ver1_1 = %f, ", key_hori_ver1[0]); sprintf_s(eval_msg[1], "hori_ver1_2 = %f\n", key_hori_ver1[1]); sprintf_s(eval_msg[2], "hori_ver1_3 = %f,", key_hori_ver1[2]); sprintf_s(eval_msg[3], "hori_ver1_4 = %f\n", key_hori_ver1[3]); sprintf_s(eval_msg[4], "hori_ver2_1 = %f,", key_hori_ver2[0]); sprintf_s(eval_msg[5], "hori_ver2_2 = %f\n", key_hori_ver2[1]); sprintf_s(eval_msg[6], "hori_ver2_3 = %f,", key_hori_ver2[2]); sprintf_s(eval_msg[7], "hori_ver2_4 = %f\n", key_hori_ver2[3]); sprintf_s(eval_msg[8], "hori_ver3_1 = %f,", key_hori_ver3[0]); sprintf_s(eval_msg[9], "hori_ver3_2 = %f\n", key_hori_ver3[1]); sprintf_s(eval_msg[10], "hori_ver3_3 = %f,", key_hori_ver3[2]); sprintf_s(eval_msg[11], "hori_ver3_4 = %f\n", key_hori_ver3[3]); sprintf_s(eval_msg[12], "dia_ver1_1 = %f,", key_dia_ver1[0]); sprintf_s(eval_msg[13], "dia_ver1_2 = %f\n", key_dia_ver1[1]); sprintf_s(eval_msg[14], "dia_ver2_1 = %f,", key_dia_ver2[0]); sprintf_s(eval_msg[15], "dia_ver2_2 = %f\n", key_dia_ver2[1]); sprintf_s(eval_msg[16], "dia_ver2_3 = %f,", key_dia_ver2[2]); sprintf_s(eval_msg[17], "dia_ver2_4 = %f\n", key_dia_ver2[3]); sprintf_s(eval_msg[18], "dia_ver3_1 = %f,", key_dia_ver3[0]); sprintf_s(eval_msg[19], "dia_ver3_2 = %f\n", key_dia_ver3[1]); sprintf_s(eval_msg[20], "dia_ver3_3 = %f,", key_dia_ver3[2]); sprintf_s(eval_msg[21], "dia_ver3_4 = %f\n", key_dia_ver3[3]); sprintf_s(eval_msg[22], "dia_ver4_1 = %f,", key_dia_ver4[0]); sprintf_s(eval_msg[23], "dia_ver4_2 = %f\n", key_dia_ver4[1]); sprintf_s(eval_msg[24], "dia_ver4_3 = %f,", key_dia_ver4[2]); sprintf_s(eval_msg[25], "dia_ver4_4 = %f\n", key_dia_ver4[3]); sprintf_s(eval_msg[26], "edge_1 = %f,", key_edge[0]); sprintf_s(eval_msg[27], "edge_2 = %f\n", key_edge[1]); sprintf_s(eval_msg[28], "edge_3 = %f,", key_edge[2]); sprintf_s(eval_msg[29], "edge_4 = %f\n", key_edge[3]); sprintf_s(eval_msg[26], "edge_cor_1 = %f,", key_edge_cor[0]); sprintf_s(eval_msg[27], "edge_cor_2 = %f\n", key_edge_cor[1]); sprintf_s(eval_msg[28], "edge_cor_3 = %f,", key_edge_cor[2]); sprintf_s(eval_msg[29], "edge_cor_4 = %f\n", key_edge_cor[3]); sprintf_s(eval_msg[34], "corner4_2_1 = %f,", key_corner4_2[0]); sprintf_s(eval_msg[35], "corner4_2_2 = %f\n", key_corner4_2[1]); sprintf_s(eval_msg[36], "corner4_2_3 = %f,", key_corner4_2[2]); sprintf_s(eval_msg[37], "corner4_2_4 = %f\n", key_corner4_2[3]); sprintf_s(eval_msg[38], "corner3_3_1 = %f,", key_corner3_3[0]); sprintf_s(eval_msg[39], "corner3_3_2 = %f\n", key_corner3_3[1]); sprintf_s(eval_msg[40], "corner3_3_3 = %f,", key_corner3_3[2]); sprintf_s(eval_msg[41], "corner3_3_4 = %f\n", key_corner3_3[3]); /*sprintf_s(eval_msg[38], "triangle_1 = %f,", key_triangle[0]); sprintf_s(eval_msg[39], "triangle_2 = %f\n", key_triangle[1]); sprintf_s(eval_msg[40], "triangle_3 = %f,", key_triangle[2]); sprintf_s(eval_msg[41], "triangle_4 = %f\n", key_triangle[3]); sprintf_s(eval_msg[42], "mobility = %f\n", key_mobility); sprintf_s(eval_msg[43], "potential_mobility = %f\n", key_pot_mobility); sprintf_s(eval_msg[44], "paility = %f\n", key_pality);*/ sprintf_s(eval_msg[42], "mobility = %f\n", key_mobility); sprintf_s(eval_msg[43], "constant = %f\n", key_constant); sprintf_s(eval_msg[44], "\n評価値 = %f,", eval_sum); sprintf_s(eval_msg[45], "\nblack = 0x%llx\nwhite = 0x%llx\n", black, white); int i; char print_msg[8192]; strcpy_s(print_msg, eval_msg[0]); for(i = 1; i < 46; i++) { strcat_s(print_msg, eval_msg[i]); } MessageBox(hWnd, print_msg, "評価値詳細一覧", MB_OK); //memset(msg, 0, sizeof(print_msg)); } break; /* FFOメニュ− */ case FFO40: black = 9158069842325798912; white = 11047339776155165; configCPU(BLACK); break; case FFO41: black = 616174399789064; white = 39493460025648416; configCPU(BLACK); break; case FFO42: white = 9091853944868375556; black = 22586176447709200; configCPU(BLACK); break; case FFO43: black = 38808086923902976; white = 13546258740034592; configCPU(WHITE); break; case FFO44: black = 2494790880993312; white = 1010251075753548824; configCPU(WHITE); break; case FFO45: black = 282828816915486; white = 9287318235258944; configCPU(BLACK); break; case FFO46: black = 4052165999611379712; white = 36117299622447104; configCPU(BLACK); break; case FFO47: black = 277938752194568; white = 3536224466208; configCPU(WHITE); break; case FFO48: black = 38519958422848574; white = 4725679339520; configCPU(WHITE); break; case FFO49: black = 5765976742297600; white = 4253833575484; configCPU(BLACK); break; case FFO50: black = 4504145659822080; white = 4336117619740130304; configCPU(BLACK); break; case FFO51: black = 349834415978528; white = 8664011788383158280; configCPU(WHITE); break; case FFO52: black = 9096176176681728056; white = 35409824317440; configCPU(WHITE); break; case FFO53: black = 2515768979493888; white = 8949795312300457984; configCPU(BLACK); break; case FFO54: black = 277938752194568; white = 3536224466208; configCPU(BLACK); break; case FFO55: black = 4635799596172290; white = 289361502099486840; configCPU(BLACK); break; case FFO56: black = 4925086697193472; white = 9007372734053408; configCPU(WHITE); break; case FFO57: black = 9060166336512000; white = 8943248156475301888; configCPU(BLACK); break; case FFO58: black = 4636039783186432; white = 3383245044333600; configCPU(BLACK); break; case FFO59: black = 17320879491911778304; white = 295223649004691488; configCPU(BLACK); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } InvalidateRect(hWnd, NULL, FALSE); /* 再描写 */ hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, -1, -1); ReleaseDC(hWnd, hdc); UpdateWindow(hRebar); SendMessage(hStatus, SB_SETTEXT, (WPARAM)1 | 0, (LPARAM)turn_str[NowTurn]); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: 描画コードをここに追加してください... hdc = GetDC(hWnd); DrawBoard( hdc, hStatus, move_x, move_y); ReleaseDC(hWnd, hdc); SendMessage(hStatus, SB_SETTEXT, (WPARAM)1 | 0, (LPARAM)turn_str[NowTurn]); //char str[64]; //sprintf_s(str, "black = %llu", black); //SendMessage(hStatus, SB_SETTEXT, (WPARAM)3 | 0, (LPARAM)str); EndPaint(hWnd, &ps); break; case WM_DESTROY: /* 置換表の解放 */ //HashDelete(hashTable); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK QTFrame_FrameWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam) { HWND myChild; switch (theMessage) { case WM_CREATE: { CLIENTCREATESTRUCT myClientStruct = {0}; myClientStruct.hWindowMenu = GetSubMenu(GetMenu(theWnd), WINDOWMENU); myClientStruct.idFirstChild = IDM_WINDOWCHILD; // create the MDI client filling the client area ghWndMDIClient = CreateWindow("mdiclient", NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, 0, 0, 0, 0, theWnd, (HMENU)0xCAC, ghInst, (LPVOID)&myClientStruct); // set initial menu state QTFrame_AdjustMenus(NULL, GetMenu(theWnd), 0L); if (ghWndMDIClient != NULL) ShowWindow(ghWndMDIClient, SW_SHOW); return(0); } case WM_ACTIVATE: // the MDI frame window is being activated or deactivated; // activate or deactivate any active child window by sending this message to DefMDIChildProc myChild = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L); if (IsWindow(myChild)) SendMessage(myChild, WM_ACTIVATE, wParam, lParam); break; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDM_FILENEW: case IDM_FILEOPEN: case IDM_FILECLOSE: case IDM_EXIT: QTFrame_HandleFileMenuItem(NULL, LOWORD(wParam)); return(0); case IDM_FILESAVE: case IDM_FILESAVEAS: // save the active child window myChild = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L); if (IsWindow(myChild)) SendMessage(myChild, WM_COMMAND, wParam, lParam); return(0); case IDM_WINDOWTILE: SendMessage(ghWndMDIClient, WM_MDITILE, 0, 0L); return(0); case IDM_WINDOWCASCADE: SendMessage(ghWndMDIClient, WM_MDICASCADE, 0, 0L); return(0); case IDM_WINDOWICONS: SendMessage(ghWndMDIClient, WM_MDIICONARRANGE, 0, 0L); return(0); case IDM_WINDOWCLOSEALL: { WindowReference myWindow, myNextWindow; // walk the window list and destroy any open windows myWindow = QTFrame_GetFrontMovieWindow(); while (myWindow != NULL) { myNextWindow = QTFrame_GetNextMovieWindow(myWindow); SendMessage(myWindow, WM_CLOSE, 0L, 0L); myWindow = myNextWindow; } return(0); } case IDM_ABOUT: QTFrame_ShowAboutBox(); return(0); default: // pass this message to the active child window... myChild = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L); if (IsWindow(myChild)) SendMessage(myChild, WM_COMMAND, wParam, lParam); // ...then do any application-specific menu handling, if no movie windows are open... if (myChild == NULL) QTApp_HandleMenu((UInt16)LOWORD(wParam)); // ...and then pass it to DefFrameProc break; } break; } case WM_OPENDROPPEDFILES: // open any movie files that were dropped onto the application icon QTFrame_OpenCommandLineMovies(gCmdLine); return(0); case WM_INITMENU: { long myModifiers = 0L; myModifiers = QTFrame_GetKeyboardModifiers(); if (GetMenu(theWnd) == (HMENU)wParam) return(QTFrame_AdjustMenus((HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L), (HMENU)wParam, myModifiers)); return(1); } case WM_CLOSE: // if we're not already in the process of shutting down, // simulate the selection of the Quit menu command if (!gShuttingDown) { SendMessage(ghWnd, WM_COMMAND, IDM_EXIT, 0L); return(0); } break; case WM_DESTROY: // do any application-specific shutdown QTApp_Stop(kStopAppPhase_AfterDestroyWindows); PostQuitMessage(0); break; } return(DefFrameProc(theWnd, ghWndMDIClient, theMessage, wParam, lParam)); }
consolewin_info::consolewin_info(debugger_windows_interface &debugger) : disasmbasewin_info(debugger, true, "Debug", NULL), m_devices_menu(NULL) { if ((window() == NULL) || (m_views[0] == NULL)) goto cleanup; // create the views m_views[1].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_STATE))); if (!m_views[1]->is_valid()) goto cleanup; m_views[2].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_CONSOLE))); if (!m_views[2]->is_valid()) goto cleanup; { // Add image menu only if image devices exist image_interface_iterator iter(machine().root_device()); device_image_interface *img = iter.first(); if (img != NULL) { m_devices_menu = CreatePopupMenu(); for ( ; img != NULL; img = iter.next()) { astring temp; temp.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[no image]"); TCHAR *tc_buf = tstring_from_utf8(temp.c_str()); if (tc_buf != NULL) { AppendMenu(m_devices_menu, MF_ENABLED, 0, tc_buf); osd_free(tc_buf); } } AppendMenu(GetMenu(window()), MF_ENABLED | MF_POPUP, (UINT_PTR)m_devices_menu, TEXT("Images")); } // get the work bounds RECT work_bounds, bounds; SystemParametersInfo(SPI_GETWORKAREA, 0, &work_bounds, 0); // adjust the min/max sizes for the window style bounds.top = bounds.left = 0; bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + 100 + EDGE_WIDTH; AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); set_minwidth(bounds.right - bounds.left); bounds.top = bounds.left = 0; bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + MAX(m_views[0]->maxwidth(), m_views[2]->maxwidth()) + EDGE_WIDTH; AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); set_maxwidth(bounds.right - bounds.left); // position the window at the bottom-right int const bestwidth = MIN(maxwidth(), work_bounds.right - work_bounds.left); int const bestheight = MIN(500, work_bounds.bottom - work_bounds.top); SetWindowPos(window(), HWND_TOP, work_bounds.right - bestwidth, work_bounds.bottom - bestheight, bestwidth, bestheight, SWP_SHOWWINDOW); } // recompute the children set_cpu(*debug_cpu_get_visible_cpu(machine())); // mark the edit box as the default focus and set it set_default_focus(); return; cleanup: m_views[2].reset(); m_views[1].reset(); m_views[0].reset(); }
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT r; RECT r2; int dx1, dy1, dx2, dy2; static int watchIndex=0; Update_RAM_Watch(); switch(uMsg) { case WM_MOVE: { RECT wrect; GetWindowRect(hDlg,&wrect); ramw_x = wrect.left; ramw_y = wrect.top; break; }; case WM_INITDIALOG: { GetWindowRect(MainWindow->getHWnd(), &r); //Ramwatch window dx1 = (r.right - r.left) / 2; dy1 = (r.bottom - r.top) / 2; GetWindowRect(hDlg, &r2); // Gens window dx2 = (r2.right - r2.left) / 2; dy2 = (r2.bottom - r2.top) / 2; // push it away from the main window if we can const int width = (r.right-r.left); const int height = (r.bottom - r.top); const int width2 = (r2.right-r2.left); if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) { r.right += width; r.left += width; } else if((int)r.left - (int)width2 > 0) { r.right -= width2; r.left -= width2; } //----------------------------------------------------------------------------------- //If user has Save Window Pos selected, override default positioning if (RWSaveWindowPos) { //If ramwindow is for some reason completely off screen, use default instead if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN)) ) r.left = ramw_x; //This also ignores cases of windows -32000 error codes //If ramwindow is for some reason completely off screen, use default instead if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN)) ) r.top = ramw_y; //This also ignores cases of windows -32000 error codes } //------------------------------------------------------------------------------------- SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); ramwatchmenu=GetMenu(hDlg); rwrecentmenu=CreateMenu(); UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); const char* names[3] = {"Address","Value","Notes"}; int widths[3] = {62,64,64+51+53}; init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths); /* if (!ResultCount) //TODO what do these do reset_address_info(); else signal_new_frame();*/ ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); // if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); // if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); RamWatchAccels = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR1)); // due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE); Update_RAM_Watch(); DragAcceptFiles(hDlg, TRUE); RefreshWatchListSelectedCountControlStatus(hDlg); return true; break; } case WM_INITMENU: CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); break; case WM_MENUSELECT: case WM_ENTERSIZEMOVE: break; case WM_NOTIFY: { switch(wParam) { case ID_WATCHES_UPDOWN: { switch(((LPNMUPDOWN)lParam)->hdr.code) { case UDN_DELTAPOS: int delta = ((LPNMUPDOWN)lParam)->iDelta; SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0); break; } } default: { LPNMHDR lP = (LPNMHDR) lParam; switch (lP->code) { case LVN_ITEMCHANGED: // selection changed event { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP; if(pNMListView->uNewState & LVIS_FOCUSED || (pNMListView->uNewState ^ pNMListView->uOldState) & LVIS_SELECTED) { // disable buttons that we don't have the right number of selected items for RefreshWatchListSelectedCountControlStatus(hDlg); } } break; case LVN_GETDISPINFO: { LV_DISPINFO *Item = (LV_DISPINFO *)lParam; Item->item.mask = LVIF_TEXT; Item->item.state = 0; Item->item.iImage = 0; const unsigned int iNum = Item->item.iItem; static char num[11]; switch (Item->item.iSubItem) { case 0: sprintf(num,"%08X",rswatches[iNum].Address); Item->item.pszText = num; return true; case 1: { int i = rswatches[iNum].CurValue; int t = rswatches[iNum].Type; int size = rswatches[iNum].Size; const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X")); switch (size) { case 'b': default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; } Item->item.pszText = num; } return true; case 2: Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : ""; return true; default: return false; } } case LVN_ODFINDITEM: { // disable search by keyboard typing, // because it interferes with some of the accelerators // and it isn't very useful here anyway SetWindowLongPtr(hDlg, DWLP_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST))); return 1; } } } } break; } case WM_COMMAND: switch(LOWORD(wParam)) { case RAMMENU_FILE_SAVE: QuickSaveWatches(); break; case RAMMENU_FILE_SAVEAS: return Save_Watches(); case RAMMENU_FILE_OPEN: return Load_Watches(true); case RAMMENU_FILE_APPEND: return Load_Watches(false); case RAMMENU_FILE_NEW: ResetWatches(); return true; case IDC_C_WATCH_REMOVE: { HWND watchListControl = GetDlgItem(hDlg, IDC_WATCHLIST); watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED); while (watchIndex >= 0) { RemoveWatch(watchIndex); ListView_DeleteItem(watchListControl, watchIndex); watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED); } RWfileChanged=true; SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; } case IDC_C_WATCH_EDIT: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if(watchIndex != -1) { DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); } return true; case IDC_C_WATCH: rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0; rswatches[WatchCount].Size = 'b'; rswatches[WatchCount].Type = 's'; DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_DUPLICATE: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if(watchIndex != -1) { rswatches[WatchCount].Address = rswatches[watchIndex].Address; rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; rswatches[WatchCount].Size = rswatches[watchIndex].Size; rswatches[WatchCount].Type = rswatches[watchIndex].Type; DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); } return true; case IDC_C_WATCH_SEPARATE: AddressWatcher separator; separator.Address = 0; separator.WrongEndian = false; separator.Size = 'S'; separator.Type = 'S'; InsertWatch(separator, "----------------------------"); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_UP: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if (watchIndex == 0 || watchIndex == -1) return true; void *tmp = malloc(sizeof(AddressWatcher)); memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher)); free(tmp); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex,0,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; } case IDC_C_WATCH_DOWN: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if (watchIndex >= WatchCount - 1 || watchIndex == -1) return true; void *tmp = malloc(sizeof(AddressWatcher)); memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher)); free(tmp); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex,0,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; } case RAMMENU_FILE_AUTOLOAD: { AutoRWLoad ^= 1; CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); break; } case RAMMENU_FILE_SAVEWINDOW: { RWSaveWindowPos ^=1; CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); break; } case IDC_C_ADDCHEAT: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if(watchIndex != -1) { u32 address = rswatches[watchIndex].Address; u8 size = (rswatches[watchIndex].Size=='b') ? 1 : (rswatches[watchIndex].Size=='w' ? 2 : 4); u32 value = rswatches[watchIndex].CurValue; const char* desc = rswatches[watchIndex].comment; CheatsAddDialog(hDlg, address, value, size, desc); } break; } case IDCANCEL: RamWatchHWnd = NULL; DragAcceptFiles(hDlg, FALSE); EndDialog(hDlg, true); return true; default: if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES) OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE); } break; case WM_KEYDOWN: // handle accelerator keys { SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); MSG msg; msg.hwnd = hDlg; msg.message = uMsg; msg.wParam = wParam; msg.lParam = lParam; if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg)) return true; } break; case WM_CLOSE: RamWatchHWnd = NULL; DragAcceptFiles(hDlg, FALSE); EndDialog(hDlg, true); return true; case WM_DROPFILES: { HDROP hDrop = (HDROP)wParam; DragQueryFile(hDrop, 0, Str_Tmp, 1024); DragFinish(hDrop); return Load_Watches(true, Str_Tmp); } break; } return false; }
BOOL UserHasMenu(HWND hWnd, ULONG Style) { return (!(Style & WS_CHILD) && GetMenu(hWnd) != 0); }
/* FUNCTION: CanvasProc(HWND, UINT, WPARAM, LPARAM) PURPOSE: Windows procedure for the canvas window PARAMETERS: hWnd - window handle message - window message wParam - window message parameter (depends on message) lParam - window message parameter (depends on message) RETURN: If the message was processed, the return value is 0 If the message was not processed and passed to DefWindowProc and the return value depends on the value of that function. */ LRESULT CALLBACK CanvasProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // a rectangle to hold current selection coords and a boolean to know whether we are in a drawing mode or not static RECT rect; static POINT pt[2]; static POINT select; static BOOL fDrawing; HMENU hMenu; // We'll be iterating through the list to find a selected object pPROGRAM_ITEM pListItem; pPROGRAM_ITEM pPrevItem; hMenu = GetMenu(ghWndMain); switch (message) { case WM_CREATE: // case for when the window is created SetRect(&rect, 0, 0, 0, 0); fDrawing = FALSE; break; case WM_MOUSEACTIVATE: // when the mouse moves into this window SetFocus(hWnd); return MA_ACTIVATE; break; case WM_LBUTTONDOWN: if(fDrawing) { // this should not happen, but no harm checking ReleaseCapture(); } // start selecting fDrawing = TRUE; // mouse x and y in lParam rect.left = (short)LOWORD(lParam); rect.top = (short)HIWORD(lParam); rect.right = (short)LOWORD(lParam); rect.bottom = (short)HIWORD(lParam); pt[0].x = (short)LOWORD(lParam); pt[0].y = (short)HIWORD(lParam); pt[1].x = (short)LOWORD(lParam); pt[1].y = (short)HIWORD(lParam); // draw first to keep drawing/erasing in synch. // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } SetCapture(hWnd); return 0; case WM_MOUSEMOVE: if (fDrawing) { RECT rcClient; GetClientRect(hWnd, &rcClient); // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { // erase old selection DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { // erase old selection DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } // mouse x and y in lParam rect.right = (short)LOWORD(lParam); rect.bottom = (short)HIWORD(lParam); pt[1].x = (short)LOWORD(lParam); pt[1].y = (short)HIWORD(lParam); // make sure our selection does not go outside client area if(rect.right < 0) { rect.right = 0; pt[1].x = 0; } if(rect.right > rcClient.right) { rect.right = rcClient.right; pt[1].x = rcClient.right; } if(rect.bottom < 0) { rect.bottom = 0; pt[1].x = 0; } if(rect.bottom > rcClient.bottom) { rect.bottom = rcClient.bottom; pt[1].y = rcClient.bottom; } // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } } break; case WM_LBUTTONUP: if(fDrawing) { // reset selection // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } fDrawing = FALSE; ReleaseCapture(); // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { // Add line to queue InsertObject(pt, rect, TRUE, gRGBCurrent); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { // Add rectangle to queue InsertObject(pt, rect, FALSE, gRGBCurrent); } // draw the newly created object InvalidateRect(hWnd, NULL, TRUE); } // Check to see if we're selecting an object if (GetMenuState(hMenu, ID_TOOLS_SELECT, MF_BYCOMMAND) == MF_CHECKED) { select.x = (short)LOWORD(lParam); select.y = (short)HIWORD(lParam); (PSLIST_HEADER)pListItem = gpListHead; // Reverse the linked list while (pListItem) { if (pListItem->fLine) { if (pListItem->rect.left < select.x && pListItem->rect.right > select.x && pListItem->rect.bottom > select.y && pListItem->rect.top < select.y) { InsertObject(pListItem->line, pListItem->rect, TRUE, SELECTED_OBJECT); selCount++; break; } } else { if (pListItem->rect.left < select.x && pListItem->rect.right > select.x && pListItem->rect.bottom > select.y && pListItem->rect.top < select.y) { InsertObject(pListItem->line, pListItem->rect, FALSE, SELECTED_OBJECT); selCount++; break; } } //switch to next list item pPrevItem = pListItem; pListItem = (pPROGRAM_ITEM)pListItem->ItemEntry.Next; } } return 0; case WM_PAINT: PaintWindow(hWnd); break; case WM_CLOSE: break; default: return (int)DefWindowProc(hWnd, message, wParam, lParam); } return 0; }