Exemple #1
0
INT_PTR CALLBACK MainDlgProc(HWND sheet, UINT msg, WPARAM wParam, LPARAM lParam)
{
	INT_PTR ret = FALSE;

	switch (msg)
	{
	case WM_CLOSE:
		DestroyWindow(sheet);
		return CALLPROC();

	case WM_SYSCOMMAND:
		//the overloaded DialogProc screwes up the automatic SC_CLOSE translation to WM_CLOSE
		if (wParam == SC_CLOSE)
			DestroyWindow(sheet);
		else
			return CALLPROC();
		break;

	case WM_COMMAND:
		ret = 0;	//processing message
		Sheet_HandleCommand(sheet, HIWORD(wParam), LOWORD(wParam), (HWND)lParam);
		CALLPROC();
		break;

	case WM_DESTROY:
		{
		    SendMessage(
			    PropSheet_GetCurrentPageHwnd(sheet),
			    AOKTS_Closing, 0, 0);
			WinHelp(sheet, "ts.hlp", HELP_QUIT, 0);
			PostQuitMessage(0);
		}
		return CALLPROC();

	case WM_HELP:
		WinHelp(sheet, "ts.hlp", HELP_CONTENTS, 0);
		break;

	case WM_MENUSELECT:
		OnMenuSelect(LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
		break;

	case MAP_Close:
		CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND | MF_UNCHECKED);
		propdata.mapview = NULL;
		break;

	case MAP_Click:
		SendMessage(
			PropSheet_GetCurrentPageHwnd(sheet),
			MAP_Click, wParam, lParam);
		break;

	default:
		return CALLPROC();
	}

	return ret;
}
Exemple #2
0
LRESULT CALLBACK CursorProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
    ShowWindow(hwnd, SW_HIDE);
    HWND page = PropSheet_GetCurrentPageHwnd(g_cfgwnd);

    if (msg == WM_LBUTTONDOWN) {
      POINT pt;
      GetCursorPos(&pt);
      HWND window = WindowFromPoint(pt);
      window = GetAncestor(window, GA_ROOT);

      wchar_t title[256], classname[256];
      GetWindowText(window, title, ARRAY_SIZE(title));
      GetClassName(window, classname, ARRAY_SIZE(classname));

      wchar_t txt[1000];
      swprintf(txt, L"%s|%s", title, classname);
      SetDlgItemText(page, IDC_NEWRULE, txt);
    }

    // Show icon again
    ShowWindowAsync(GetDlgItem(page,IDC_FINDWINDOW), SW_SHOW);

    DestroyWindow(hwnd);
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}
Exemple #3
0
BOOL CTreePropSheet::KillActiveCurrentPage()
{
	HWND	hCurrentPage = PropSheet_GetCurrentPageHwnd(m_hWnd);
	if (!IsWindow(hCurrentPage))
	{
		ASSERT(FALSE);
		return TRUE;
	}

	// Check if the current page is really active (if page is invisible
	// an virtual empty page is the active one.
	if (!::IsWindowVisible(hCurrentPage))
		return TRUE;

	// Try to deactivate current page
	PSHNOTIFY	pshn;
	pshn.hdr.code = PSN_KILLACTIVE;
	pshn.hdr.hwndFrom = m_hWnd;
	pshn.hdr.idFrom = GetDlgCtrlID();
	pshn.lParam = 0;
	if (::SendMessage(hCurrentPage, WM_NOTIFY, pshn.hdr.idFrom, (LPARAM)&pshn))
		// current page does not allow page change
		return FALSE;

	// Hide the page
	::ShowWindow(hCurrentPage, SW_HIDE);

	return TRUE;
}
Exemple #4
0
void CTreePropSheet::UpdateCaption()
{
	HWND			hPage = PropSheet_GetCurrentPageHwnd(GetSafeHwnd());
	BOOL			bRealPage = IsWindow(hPage) && ::IsWindowVisible(hPage);
	HTREEITEM	hItem = m_pwndPageTree->GetSelectedItem();
	if (!hItem)
		return;
	CString		strCaption = m_pwndPageTree->GetItemText(hItem);

	// if empty page, then update empty page message
	if (!bRealPage)
		m_pFrame->SetMsgText(GenerateEmptyPageMessage(m_strEmptyPageMessage, strCaption));

	// if no captions are displayed, cancel here
	if (!m_pFrame->GetShowCaption())
		return;

	// get tab control, to the the images from
	CTabCtrl	*pTabCtrl = GetTabControl();
	if (!IsWindow(pTabCtrl->GetSafeHwnd()))
	{
		ASSERT(FALSE);
		return;
	}

	if (m_bTreeImages)
	{
		// get image from tree
		int	nImage;
		m_pwndPageTree->GetItemImage(hItem, nImage, nImage);
		HICON	hIcon = m_Images.ExtractIcon(nImage);
		m_pFrame->SetCaption(strCaption, hIcon);
		if (hIcon)
			DestroyIcon(hIcon);
	}
	else if (bRealPage)
	{
		// get image from hidden (original) tab provided by the original
		// implementation
		CImageList	*pImages = pTabCtrl->GetImageList();
		if (pImages)
		{
			TCITEM	ti;
			ZeroMemory(&ti, sizeof(ti));
			ti.mask = TCIF_IMAGE;

			HICON	hIcon = NULL;
			if (pTabCtrl->GetItem((int)m_pwndPageTree->GetItemData(hItem), &ti))
				hIcon = pImages->ExtractIcon(ti.iImage);

			m_pFrame->SetCaption(strCaption, hIcon);
			if (hIcon)
				DestroyIcon(hIcon);
		}
		else
			m_pFrame->SetCaption(strCaption);
	}
	else
		m_pFrame->SetCaption(strCaption);
}
Exemple #5
0
int	PropertySheetDialog::DoModal(int start_page)
{
	PROPSHEETHEADER::ppsp = (LPCPROPSHEETPAGE) &_pages[0];
	PROPSHEETHEADER::nPages = _pages.size();
	PROPSHEETHEADER::nStartPage = start_page;
/*
	Window* pwnd = Window::create_property_sheet(this, WINDOW_CREATOR(PropertySheetDlg), NULL);
	if (!pwnd)
		return -1;

	HWND hwndPropSheet = *pwnd;
*/
	int ret = PropertySheet(this);
	if (ret == -1)
		return -1;

	HWND hwndPropSheet = (HWND) ret;
	HWND hwndparent = GetParent(hwndPropSheet);

	if (hwndparent)
		EnableWindow(hwndparent, FALSE);

	ret = 0;
	MSG msg;

	while(GetMessage(&msg, 0, 0, 0)) {
		try {
			if (Window::pretranslate_msg(&msg))
				continue;

			if (PropSheet_IsDialogMessage(hwndPropSheet, &msg))
				continue;

			if (Window::dispatch_dialog_msg(&msg))
				continue;

			TranslateMessage(&msg);

			try {
				DispatchMessage(&msg);
			} catch(COMException& e) {
				HandleException(e, 0);
			}

			if (!PropSheet_GetCurrentPageHwnd(hwndPropSheet)) {
				ret = PropSheet_GetResult(hwndPropSheet);
				break;
			}
		} catch(COMException& e) {
			HandleException(e, 0);
		}
	}

	if (hwndparent)
		EnableWindow(hwndparent, TRUE);

	DestroyWindow(hwndPropSheet);

	return ret;
}
/*
================
GEOptionsDlg_GeneralProc

Dialog procedure for the general options tab
================
*/
static INT_PTR CALLBACK GEOptionsDlg_GeneralProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
		case WM_INITDIALOG:
			ColorButton_SetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR),
			                     RGB(gApp.GetOptions().GetSelectionColor()[0]*255,
			                         gApp.GetOptions().GetSelectionColor()[1]*255,
			                         gApp.GetOptions().GetSelectionColor()[2]*255));
			CheckDlgButton(hwnd, IDC_GUIED_IGNOREDESKTOP, gApp.GetOptions().GetIgnoreDesktopSelect()?BST_CHECKED:BST_UNCHECKED);
			break;

		case WM_COMMAND:

			switch (LOWORD(wParam)) {
				case IDC_GUIED_SELECTIONCOLOR: {
					CHOOSECOLOR col;
					ZeroMemory(&col, sizeof(col));
					col.lStructSize = sizeof(col);
					col.lpCustColors = gApp.GetOptions().GetCustomColors();
					col.hwndOwner = hwnd;
					col.hInstance = NULL;
					col.Flags = CC_RGBINIT;
					col.rgbResult = ColorButton_GetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR));

					if (ChooseColor(&col)) {
						ColorButton_SetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR), col.rgbResult);
					}

					break;
				}
			}

			break;

		case WM_DRAWITEM:
			ColorButton_DrawItem(GetDlgItem(hwnd, wParam), (LPDRAWITEMSTRUCT)lParam);
			return TRUE;

		case WM_NOTIFY:

			switch (((NMHDR FAR *) lParam)->code) {
				case PSN_APPLY:
					gApp.GetOptions().SetLastOptionsPage(PropSheet_HwndToIndex(GetParent(hwnd), PropSheet_GetCurrentPageHwnd(GetParent(hwnd))));
					gApp.GetOptions().SetSelectionColor(ColorButton_GetColor(GetDlgItem(hwnd, IDC_GUIED_SELECTIONCOLOR)));
					gApp.GetOptions().SetIgnoreDesktopSelect(IsDlgButtonChecked(hwnd, IDC_GUIED_IGNOREDESKTOP) != 0);
					break;
			}

			break;
	}

	return FALSE;
}
Exemple #7
0
LRESULT CALLBACK PropSheetWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
  LRESULT ret = DefSubclassProc(hwnd, msg, wParam, lParam);
  if (msg == WM_NCHITTEST && (ret == HTBOTTOM || ret == HTBOTTOMLEFT || ret == HTBOTTOMRIGHT || ret == HTLEFT || ret == HTTOPLEFT || ret == HTTOPRIGHT || ret == HTRIGHT || ret == HTTOP)) {
    ret = HTCAPTION;
  }
  else if (msg == WM_UPDATESETTINGS) {
    UpdateStrings();
    HWND page = PropSheet_GetCurrentPageHwnd(g_cfgwnd);
    SendMessage(page, WM_INITDIALOG, 0, 0);
    NMHDR pnmh = { g_cfgwnd, 0, PSN_SETACTIVE };
    SendMessage(page, WM_NOTIFY, 0, (LPARAM) &pnmh);
  }
  return ret;
}
Exemple #8
0
void UpdateStrings() {
  // Update window title
  PropSheet_SetTitle(g_cfgwnd, 0, l10n->title);

  // Update tab titles
  HWND tc = PropSheet_GetTabControl(g_cfgwnd);
  int numrows_prev = TabCtrl_GetRowCount(tc);
  wchar_t *titles[] = { l10n->tab_general, l10n->tab_input, l10n->tab_blacklist, l10n->tab_advanced, l10n->tab_about };
  int i;
  for (i=0; i < ARRAY_SIZE(titles); i++) {
    TCITEM ti;
    ti.mask = TCIF_TEXT;
    ti.pszText = titles[i];
    TabCtrl_SetItem(tc, i, &ti);
  }

  // Modify UI if number of rows have changed
  int numrows = TabCtrl_GetRowCount(tc);
  if (numrows_prev != numrows) {
    HWND page = PropSheet_GetCurrentPageHwnd(g_cfgwnd);
    if (page != NULL) {
      int diffrows = numrows-numrows_prev;
      WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
      // Resize window
      GetWindowPlacement(g_cfgwnd, &wndpl);
      wndpl.rcNormalPosition.bottom += 18*diffrows;
      SetWindowPlacement(g_cfgwnd, &wndpl);
      // Resize tabcontrol
      GetWindowPlacement(tc, &wndpl);
      wndpl.rcNormalPosition.bottom += 18*diffrows;
      SetWindowPlacement(tc, &wndpl);
      // Move button
      HWND button = GetDlgItem(g_cfgwnd, IDOK);
      GetWindowPlacement(button, &wndpl);
      int height = wndpl.rcNormalPosition.bottom-wndpl.rcNormalPosition.top;
      wndpl.rcNormalPosition.top += 18*diffrows;
      wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top+height;
      SetWindowPlacement(button, &wndpl);
      // Re-select tab
      PropSheet_SetCurSel(g_cfgwnd, page, 0);
      // Invalidate region
      GetWindowPlacement(g_cfgwnd, &wndpl);
      InvalidateRect(g_cfgwnd, &wndpl.rcNormalPosition, TRUE);
    }
  }
}
int PASCAL WinMain(  HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,
                     int nCmdShow)
{
MSG      msg;

g_hInst = hInstance;

//don't forget this
InitCommonControls();

if(!hPrevInstance)
   if(!InitApplication(hInstance))
      return FALSE;

if (!InitInstance(hInstance, nCmdShow))
   return FALSE;

while(GetMessage(&msg, NULL, 0x00, 0x00))
   {
   // If the modeless guy is up and is ready to be destroyed
   // (PropSheet_GetCurrentPageHwnd returns NULL) then destroy the dialog.
   
   // PropSheet_GetCurrentPageHwnd will return NULL after the OK or Cancel 
   // button has been pressed and all of the pages have been notified. The 
   // Apply button doesn't cause this to happen.
   if(g_hwndPropSheet && (NULL == PropSheet_GetCurrentPageHwnd(g_hwndPropSheet)))
      {
      //enable the parent first to prevent another window from becoming the foreground window
      EnableWindow(g_hwndMain, TRUE);
      DestroyWindow(g_hwndPropSheet);
      g_hwndPropSheet = NULL;
      }

   //use PropSheet_IsDialogMessage instead of IsDialogMessage
   if(!PropSheet_IsDialogMessage(g_hwndPropSheet, &msg))
      {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
      }
   }

return (int)msg.wParam;
}
int APIENTRY _tWinMain( HINSTANCE hInstance,
						HINSTANCE /*hPrevInstance*/,
						LPTSTR    lpCmdLine,
						int       nCmdShow)
{
	MSG msg;
	HACCEL hAccelTable;
	BOOL firstrun;

	InitCommonControls();
	CoInitialize ( NULL );

	firstrun = vdWindow.Start(hInstance, nCmdShow);
	if (!firstrun)
	{
		CommandLineParser parser;
		parser.ParseCommandLine(lpCmdLine);
		return -1;
	}

	// Load accelerators
	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_VIRTUALDIMENSION);

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (IsWindow(configBox) && IsDialogMessage(configBox, &msg))
		{
			if (NULL == PropSheet_GetCurrentPageHwnd(configBox))
			{
				DestroyWindow(configBox);
				configBox = NULL;
			}
		}
		else if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return (int) msg.wParam;
}
Exemple #11
0
/*
 * select_tools_proc - ツール選択ウィンドウプロシージャ
 */
static BOOL CALLBACK select_tools_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HWND pWnd;
	TOOL_INFO *ti;
	TCHAR buf[BUF_SIZE];
	static TCHAR lib_path[BUF_SIZE];
	int call_type;
	int i, j;
	static int old;

	switch (uMsg) {
	case WM_INITDIALOG:
		SetWindowText(hDlg, message_get_res(IDS_TOOL_SELECT_TITLE));
		SetWindowText(GetDlgItem(hDlg, IDC_STATIC_MSG), message_get_res(IDS_TOOL_SELECT_MSG));

		if (dll_to_list(hDlg, (TCHAR *)lParam, &old) == FALSE) {
			EndDialog(hDlg, FALSE);
			break;
		}
		// リストビューのスタイルの設定
		SetWindowLong(GetDlgItem(hDlg, IDC_LIST_HEADER), GWL_STYLE,
			GetWindowLong(GetDlgItem(hDlg, IDC_LIST_HEADER), GWL_STYLE) & ~LVS_SINGLESEL);

		lstrcpy(lib_path, (TCHAR *)lParam);

		EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
		break;

	case WM_CLOSE:
		EndDialog(hDlg, FALSE);
		break;

	case WM_NOTIFY:
		listview_notify_proc(hDlg, lParam, GetDlgItem(hDlg, IDC_LIST_HEADER));
		break;

	case WM_LV_EVENT:
		switch (wParam) {
		case LVN_ITEMCHANGED:
			if (ListView_GetSelectedCount(GetDlgItem(hDlg, IDC_LIST_HEADER)) <= 0) {
				EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
			} else {
				EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
			}
			break;
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			SendMessage(hDlg, WM_CLOSE, 0, 0);
			break;

		case IDC_BUTTON_EDIT:
		case IDOK:
			pWnd = PropSheet_GetCurrentPageHwnd(GetParent(hDlg));

			i = -1;
			while ((i = ListView_GetNextItem(GetDlgItem(hDlg, IDC_LIST_HEADER), i, LVNI_SELECTED)) != -1) {
				if ((ti = mem_calloc(sizeof(TOOL_INFO))) != NULL) {
					// 設定取得
					ti->lib_file_path = alloc_copy(lib_path);

					ListView_GetItemText(GetDlgItem(hDlg, IDC_LIST_HEADER), i, 0, buf, BUF_SIZE - 1);
					ti->title = alloc_copy(buf);
					ListView_GetItemText(GetDlgItem(hDlg, IDC_LIST_HEADER), i, 1, buf, BUF_SIZE - 1);
					ti->func_name = alloc_copy(buf);
					ListView_GetItemText(GetDlgItem(hDlg, IDC_LIST_HEADER), i, 2, buf, BUF_SIZE - 1);
					ti->cmd_line = alloc_copy(buf);

					call_type = listview_get_lparam(GetDlgItem(hDlg, IDC_LIST_HEADER), i);
					if (old == 1) {
						j = CALLTYPE_VIEWER;
						if (!(call_type & OLD_CALLTYPE_MENU)) {
							j |= CALLTYPE_MENU;
							ti->copy_paste = 1;
						}
						if (call_type & OLD_CALLTYPE_ADD_HISTORY) {
							j |= CALLTYPE_ADD_HISTORY;
						}
						if (call_type & OLD_CALLTYPE_ITEM_TO_CLIPBOARD) {
							j |= CALLTYPE_ITEM_TO_CLIPBOARD;
						}
						if (call_type & OLD_CALLTYPE_START) {
							j |= CALLTYPE_START;
						}
						if (call_type & OLD_CALLTYPE_END) {
							j |= CALLTYPE_END;
						}
						ti->call_type = j;
					} else {
						ti->copy_paste = (call_type & CALLTYPE_MENU_COPY_PASTE) ? 1 : 0;
						ti->call_type = call_type & ~CALLTYPE_MENU_COPY_PASTE;
					}
					ti->old = old;

					// 新規追加
					listview_set_tool(GetDlgItem(pWnd, IDC_LIST_TOOL), ti, FALSE);
				}
			}
			EndDialog(hDlg, TRUE);
			break;
		}
		break;

	case WM_GET_VERSION:
		// バージョン取得
		return APP_VAR;

	case WM_GET_WORKPATH:
		// 作業ディレクトリ取得
		if (lParam == 0) {
			break;
		}
		lstrcpy((TCHAR *)lParam, work_path);
		break;

	default:
		return FALSE;
	}
	return TRUE;
}
void CResizableSheetEx::PresetLayout()
{
	// set the initial size as the min track size
	CRect rc;
	GetWindowRect(&rc);
	SetMinTrackSize(rc.Size());

	// use *total* parent size to have correct margins
	CRect rectPage, rectSheet;
	GetTotalClientRect(&rectSheet);

	// get page area
	if (IsWizard() || IsWizard97())
	{
		HWND hPage = PropSheet_GetCurrentPageHwnd(m_hWnd);
		::GetWindowRect(hPage, &rectPage);
	}
	else
	{
		GetTabControl()->GetWindowRect(&rectPage);
	}
	::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectPage, 2);

	// calculate margins
	CRect rect;
	int cxDiff = rectSheet.right - rectPage.right;
	int cyDiff = 0;

	// try all possible buttons
	for (int i = 0; i < _propButtonsCount; i++)
	{
		CWnd* pWnd = GetDlgItem(_propButtons[i]);
		if (NULL != pWnd)
		{
			// move buttons if necessary
			if (GetStyle() & WS_CHILD)
			{
				pWnd->GetWindowRect(&rect);
				::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rect, 2);

				cyDiff = rectSheet.bottom - rect.bottom;
				rect.OffsetRect(cxDiff, cyDiff);

				pWnd->MoveWindow(&rect);
			}
			// add buttons to the layout manager
			AddAnchor(_propButtons[i], BOTTOM_RIGHT);
		}
	}

	// setup pages area
	if (IsWizard() || IsWizard97())
	{
		// move line and pages if necessary
		if (GetStyle() & WS_CHILD)
		{
			GetDlgItem(ID_WIZLINE)->GetWindowRect(&rect);
			::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rect, 2);

			rect.OffsetRect(0, cyDiff);
			rect.InflateRect(cxDiff, 0);

			GetDlgItem(ID_WIZLINE)->MoveWindow(&rect);

			rectPage.bottom += cyDiff;
			rectPage.left = 0;
			rectPage.top = 0;
			rectPage.right = rectSheet.right;
		}

		AddAnchor(ID_WIZLINE, BOTTOM_LEFT, BOTTOM_RIGHT);

		if (IsWizard97())	// add header line for wizard97 dialogs
			AddAnchor(ID_WIZLINEHDR, TOP_LEFT, TOP_RIGHT);

		// hide tab control
		GetTabControl()->ShowWindow(SW_HIDE);

		// pre-calculate margins
		m_sizePageTL = rectPage.TopLeft() - rectSheet.TopLeft();
		m_sizePageBR = rectPage.BottomRight() - rectSheet.BottomRight();
	}
	else
	{
		// grow tab to the available sheet space
		if (cyDiff > 0)
			rectSheet.bottom = rectPage.bottom + cyDiff;
		
		if (GetStyle() & WS_CHILD)
			GetTabControl()->MoveWindow(&rectSheet);

		AddAnchor(AFX_IDC_TAB_CONTROL, TOP_LEFT, BOTTOM_RIGHT);
	}

	// add a callback for active page (which can change at run-time)
	m_nCallbackID = AddAnchorCallback();

	// prevent flickering
	GetTabControl()->ModifyStyle(0, WS_CLIPSIBLINGS);
}
Exemple #13
0
/*
 * set_tool_item_proc - ツールの項目を設定
 */
static BOOL CALLBACK set_tool_item_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TOOL_INFO *ti;
	TCHAR buf[BUF_SIZE];
	int i;

	switch (uMsg) {
	case WM_INITDIALOG:
		if (lParam == 0) {
			// 新規追加
			SendMessage(hDlg, WM_COMMAND, IDC_CHECK_MENU, 0);
			SetWindowLong(hDlg, GWL_USERDATA, 0);
			break;
		}
		ti = (TOOL_INFO *)lParam;

		SendDlgItemMessage(hDlg, IDC_EDIT_TITLE, WM_SETTEXT, 0, (LPARAM)ti->title);
		SendDlgItemMessage(hDlg, IDC_EDIT_LIB_PATH, WM_SETTEXT, 0, (LPARAM)ti->lib_file_path);
		SendDlgItemMessage(hDlg, IDC_EDIT_HEADER, WM_SETTEXT, 0, (LPARAM)ti->func_name);
		SendDlgItemMessage(hDlg, IDC_EDIT_CMD_LINE, WM_SETTEXT, 0, (LPARAM)ti->cmd_line);

		set_call_type(hDlg, ti->call_type);
		CheckDlgButton(hDlg, IDC_CHECK_COPY_PATE, ti->copy_paste);
		CheckDlgButton(hDlg, IDC_CHECK_OLD, ti->old);

		i = 0;
		if (ti->modifiers & MOD_SHIFT) {
			i |= HOTKEYF_SHIFT;
		}
		if (ti->modifiers & MOD_CONTROL) {
			i |= HOTKEYF_CONTROL;
		}
		if (ti->modifiers & MOD_ALT) {
			i |= HOTKEYF_ALT;
		}
		if (ti->modifiers & MOD_WIN) {
			i |= HOTKEYF_WIN;
		}
		if (ti->virtkey != 0) {
			SendDlgItemMessage(hDlg, IDC_HOTKEY_TOOL, HKM_SETHOTKEY,
				(WPARAM)MAKEWORD(ti->virtkey, i), 0);
		}
		SendMessage(hDlg, WM_COMMAND, IDC_CHECK_MENU, 0);

		SetWindowLong(hDlg, GWL_USERDATA, lParam);
		break;

	case WM_CLOSE:
		EndDialog(hDlg, FALSE);
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CHECK_MENU:
			EnableWindow(GetDlgItem(hDlg, IDC_CHECK_COPY_PATE), IsDlgButtonChecked(hDlg, IDC_CHECK_MENU));
			EnableWindow(GetDlgItem(hDlg, IDC_HOTKEY_TOOL), IsDlgButtonChecked(hDlg, IDC_CHECK_MENU));
			break;

		case IDC_BUTTON_FILE_SELECT:
			// ファイル選択
			SetFocus(GetDlgItem(hDlg, IDC_EDIT_LIB_PATH));
			if (file_select(hDlg, TEXT("*.dll\0*.dll\0*.*\0*.*\0\0"), 1, buf) == -1) {
				break;
			}
			SendDlgItemMessage(hDlg, IDC_EDIT_LIB_PATH, WM_SETTEXT, 0, (LPARAM)buf);
			SendDlgItemMessage(hDlg, IDC_EDIT_HEADER, WM_SETTEXT, 0, (LPARAM)TEXT(""));

		case IDC_BUTTON_FUNC_SELECT:
			// ツール選択
			*buf = TEXT('\0');
			SendDlgItemMessage(hDlg, IDC_EDIT_LIB_PATH, WM_GETTEXT, BUF_SIZE - 1, (LPARAM)buf);
			if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOG_SELECT_FUNC), hDlg, select_tool_proc, (LPARAM)buf) == TRUE) {
				SendMessage(hDlg, WM_COMMAND, IDC_CHECK_MENU, 0);
			}
			break;

		case IDOK:
			*buf = TEXT('\0');
			SendDlgItemMessage(hDlg, IDC_EDIT_TITLE, WM_GETTEXT, BUF_SIZE - 1, (LPARAM)buf);
			if (*buf == TEXT('\0')) {
				MessageBox(hDlg, message_get_res(IDS_TOOL_ERR_TITLE), WINDOW_TITLE, MB_ICONEXCLAMATION);
				SetFocus(GetDlgItem(hDlg, IDC_EDIT_TITLE));
				break;
			}

			if ((ti = (TOOL_INFO *)GetWindowLong(hDlg, GWL_USERDATA)) == NULL) {
				ti = mem_calloc(sizeof(TOOL_INFO));
			}
			if (ti != NULL) {
				// 設定取得
				alloc_get_text(GetDlgItem(hDlg, IDC_EDIT_TITLE), &ti->title);
				alloc_get_text(GetDlgItem(hDlg, IDC_EDIT_LIB_PATH), &ti->lib_file_path);
				alloc_get_text(GetDlgItem(hDlg, IDC_EDIT_HEADER), &ti->func_name);
				alloc_get_text(GetDlgItem(hDlg, IDC_EDIT_CMD_LINE), &ti->cmd_line);
				
				ti->call_type = 0;
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_MENU) * CALLTYPE_MENU);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_VIEWER) * CALLTYPE_VIEWER);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_VIEWER_OPEN) * CALLTYPE_VIEWER_OPEN);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_VIEWER_CLOSE) * CALLTYPE_VIEWER_CLOSE);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_HISTORY) * CALLTYPE_ADD_HISTORY);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_CLIPBOARD) * CALLTYPE_ITEM_TO_CLIPBOARD);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_START) * CALLTYPE_START);
				ti->call_type |= (IsDlgButtonChecked(hDlg, IDC_CHECK_END) * CALLTYPE_END);

				ti->copy_paste = IsDlgButtonChecked(hDlg, IDC_CHECK_COPY_PATE);
				ti->old = IsDlgButtonChecked(hDlg, IDC_CHECK_OLD);

				i = SendDlgItemMessage(hDlg, IDC_HOTKEY_TOOL, HKM_GETHOTKEY, 0, 0);
				ti->virtkey = LOBYTE(i);
				i = HIBYTE(i);
				ti->modifiers = ((i & HOTKEYF_SHIFT) ? MOD_SHIFT : 0) |
					((i & HOTKEYF_CONTROL) ? MOD_CONTROL : 0) |
					((i & HOTKEYF_ALT) ? MOD_ALT : 0) |
					((i & HOTKEYF_WIN) ? MOD_WIN : 0);
			}

			if (GetWindowLong(hDlg, GWL_USERDATA) == 0) {
				// 新規
				HWND pWnd = PropSheet_GetCurrentPageHwnd(GetParent(hDlg));
				listview_set_tool(GetDlgItem(pWnd, IDC_LIST_TOOL), ti, FALSE);
			}
			EndDialog(hDlg, TRUE);
			break;

		case IDCANCEL:
			EndDialog(hDlg, FALSE);
			break;
		}
		break;

	default:
		return FALSE;
	}
	return TRUE;
}
static THREAD_ENTRY_DECLARE WINDOW_main(THREAD_ENTRY_PARAM)
{
/**************************************
 *
 *	W I N D O W _ m a i n
 *
 **************************************
 *
 * Functional description
 *
 *      This function is where the actual service code starts.
 * Do all the window init stuff, then fork off a thread for starting
 * the server.
 *
 **************************************/

	// If we're a service, don't create a window
	if (service_flag)
	{
		try
		{
			Thread::start(start_and_watch_server, 0, THREAD_medium, &watcher_thd);
		}
		catch (const Firebird::Exception&)
		{
			// error starting server thread
			char szMsgString[256];
			LoadString(hInstance_gbl, IDS_CANT_START_THREAD, szMsgString, 256);
			gds__log(szMsgString);
		}

		return 0;
	}

	// Make sure that there is only 1 instance of the guardian running
	HWND hWnd = FindWindow(GUARDIAN_CLASS_NAME, GUARDIAN_APP_NAME);
	if (hWnd)
	{
		char szMsgString[256];
		LoadString(hInstance_gbl, IDS_ALREADYSTARTED, szMsgString, 256);
		MessageBox(NULL, szMsgString, GUARDIAN_APP_LABEL, MB_OK | MB_ICONSTOP);
		gds__log(szMsgString);
		return 0;
	}

	// initialize main window
	WNDCLASS wcl;
	wcl.hInstance = hInstance_gbl;
	wcl.lpszClassName = GUARDIAN_CLASS_NAME;
	wcl.lpfnWndProc = WindowFunc;
	wcl.style = 0;
	wcl.hIcon = LoadIcon(hInstance_gbl, MAKEINTRESOURCE(IDI_IBGUARD));
	wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcl.lpszMenuName = NULL;
	wcl.cbClsExtra = 0;
	wcl.cbWndExtra = 0;
	wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

	if (!RegisterClass(&wcl))
	{
		char szMsgString[256];
		LoadString(hInstance_gbl, IDS_REGERROR, szMsgString, 256);
		MessageBox(NULL, szMsgString, GUARDIAN_APP_LABEL, MB_OK | MB_ICONSTOP);
		return 0;
	}

	hWnd = CreateWindowEx(0,
						  GUARDIAN_CLASS_NAME,
						  GUARDIAN_APP_NAME,
						  WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX,
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  CW_USEDEFAULT,
						  HWND_DESKTOP, NULL, hInstance_gbl, NULL);

	// Save the window handle for the thread
	hWndGbl = hWnd;

	// begin a new thread for calling the start_and_watch_server
	try
	{
		Thread::start(start_and_watch_server, 0, THREAD_medium, NULL);
	}
	catch (const Firebird::Exception&)
	{
		// error starting server thread
		char szMsgString[256];
		LoadString(hInstance_gbl, IDS_CANT_START_THREAD, szMsgString, 256);
		MessageBox(NULL, szMsgString, GUARDIAN_APP_LABEL, MB_OK | MB_ICONSTOP);
		gds__log(szMsgString);
		DestroyWindow(hWnd);
		return 0;
	}

	SendMessage(hWnd, WM_COMMAND, IDM_CANCEL, 0);
	UpdateWindow(hWnd);

	MSG message;
	while (GetMessage(&message, NULL, 0, 0))
	{
		if (hPSDlg)
		{
			// If property sheet dialog is open
			// Check if the message is property sheet dialog specific
			BOOL bPSMsg = PropSheet_IsDialogMessage(hPSDlg, &message);

			// Check if the property sheet dialog is still valid, if not destroy it
			if (!PropSheet_GetCurrentPageHwnd(hPSDlg))
			{
				DestroyWindow(hPSDlg);
				hPSDlg = NULL;
				if (swap_icons_thd)
				{
					CloseHandle(swap_icons_thd);
					swap_icons_thd = 0;
				};
			}
			if (bPSMsg)
				continue;
		}
		TranslateMessage(&message);
		DispatchMessage(&message);
	}
	return message.wParam;
}
Exemple #15
0
/*
	FileSave: Handles a request to save the currently open file.

	Parameters:
	HWND sheet: Handle to the property sheet.
	bool as:		Save or Save As?
*/
void FileSave(HWND sheet, bool as, bool write)
{
	int error;			//error value from Scenario::save()
	HWND cpage;			//the current property page
	HCURSOR previous;	//the mouse cursor before/after save operation
	OPENFILENAME ofn;
	char titleBuffer[100];
	Game startver;
	Game conv = NOCONV;
    SaveFlags::Value flags = SaveFlags::NONE;

    char w1[] = {84, 104, 105, 115, 32, 115, 99, 101, 110, 97, 114, 105, 111, 32, 105, 115, 32, 112, 114, 111, 116, 101, 99, 116, 101, 100, 0};
    char w2[] = {83, 99, 101, 110, 97, 114, 105, 111, 32, 105, 115, 32, 112, 114, 111, 116, 101, 99, 116, 101, 100, 0};
    if (setts.disabletips) {
        MessageBox(sheet, w1, w2, MB_ICONWARNING);
        return;
    }

	//init
	cpage = PropSheet_GetCurrentPageHwnd(sheet);

	//Save As: Ask for filename.
	if (as || *setts.ScenPath == '\0')
	{
		char dir[_MAX_PATH];
		strcpy(dir, setts.BasePath);
		strcat(dir, "Scenario");

		ofn.lStructSize = sizeof(OPENFILENAME);
		ofn.hwndOwner = sheet;
		ofn.lpstrFilter = extSave;
		ofn.lpstrCustomFilter = NULL;
		ofn.lpstrFile = setts.ScenPath;
		ofn.nMaxFile = _MAX_PATH;
		ofn.lpstrFileTitle = NULL;
		ofn.lpstrInitialDir = dir;
		ofn.lpstrTitle = NULL;
		ofn.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT;

	    startver = scen.game;

		if (scen.header.header_type == HT_AOE2SCENARIO) {
		    ofn.nFilterIndex =	6;
		    ofn.lpstrDefExt =	"aoe2scenario";
		} else {
		    switch (scen.game) {
		    case AOK:
		        ofn.nFilterIndex =	1;
		        ofn.lpstrDefExt =	"scn";
		        break;
		    case AOC:
		        ofn.nFilterIndex =	2;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case UP:
		        ofn.nFilterIndex =	3;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case AOHD:
		    case AOHD4:
		        ofn.nFilterIndex =	4;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case AOF:
		    case AOF4:
		        ofn.nFilterIndex =	5;
		        ofn.lpstrDefExt =	"scx2";
		        break;
		    case SWGB:
		        ofn.nFilterIndex =	7;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case SWGBCC:
		        ofn.nFilterIndex =	8;
		        ofn.lpstrDefExt =	"sc1";
		        break;
		    case AOHD6:
		        ofn.nFilterIndex =	9;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case AOF6:
		        ofn.nFilterIndex =	10;
		        ofn.lpstrDefExt =	"scx2";
		        break;
		    }
		}

		if (!GetSaveFileName(&ofn))
			return;

		switch (ofn.nFilterIndex) {
		case 1:
		    conv = AOK;
		    break;
		case 2:
		    conv = AOC;
		    break;
		case 3:
		    conv = UP;
		    break;
		case 4:
		    conv = AOHD4;
		    break;
		case 5:
		    conv = AOF4;
		    break;
		case 6:
	        scen.header.header_type = HT_AOE2SCENARIO;
		    conv = startver;
		    break;
		case 7:
		    conv = SWGB;
		    break;
		case 8:
		    conv = SWGBCC;
		    break;
		case 9:
		    conv = AOHD6;
		    break;
		case 10:
		    conv = AOF6;
		    break;
		}

		if (!*scen.origname)
			strcpy(scen.origname, setts.ScenPath + ofn.nFileOffset);

		/* Update window title since filename has probably changed */
		_snprintf(titleBuffer, sizeof(titleBuffer),
			"%s - %s", szTitle, setts.ScenPath + ofn.nFileOffset);
		SetWindowText(sheet, titleBuffer);
	} else {
	    conv = scen.game;
	}

    if (isHD(startver) && conv == UP) {
        if (setts.asktoconverteffects &&
            MessageBox(sheet, "Also convert HD effects to UserPatch?", "Convert", MB_YESNOCANCEL) == IDYES) {
            flags = (SaveFlags::Value)(flags | SaveFlags::CONVERT_EFFECTS);
        }
    }

    if (startver == UP && isHD(conv)) {
        if (setts.asktoconverteffects &&
            MessageBox(sheet, "Also convert UserPatch effects to HD?", "Convert", MB_YESNOCANCEL) == IDYES) {
            flags = (SaveFlags::Value)(flags | SaveFlags::CONVERT_EFFECTS);
        }
    }

	//update scenario data
	SendMessage(cpage, AOKTS_Saving, 0, 0);

	//perform before-saving operations
	previous = SetCursor(LoadCursor(NULL, IDC_WAIT));
	// Pretend we're "closing" the scenario because it may change during the
	// save.
	SendMessage(cpage, AOKTS_Closing, 0, 0);
	scen.clean_triggers();

	//save the scenario
	try
	{
 		error = scen.save(setts.ScenPath, setts.TempPath, write, conv, flags);
		SetCursor(previous);

	    struct RecentFile *file = NULL;	//the file info will be stored here one way or another
		struct RecentFile *r_parse;

		/* Now check if file is already on recent list. */
		r_parse = setts.recent_first;
		while (r_parse)
		{
			if (!strcmp(r_parse->path, setts.ScenPath))
			{
				file = r_parse;
				break;
			}
			r_parse = r_parse->next;
		}

        if (file) {
            file->game = (int)conv;
        } else {
		    file = setts.recent_getnext();
		    strcpy(file->path, setts.ScenPath);
		    strcpy(file->display, PathFindFileName(setts.ScenPath));
		    file->game = (int)conv;
	        setts.recent_push(file);
	    }
	    UpdateRecentMenu(propdata.menu);
	}
	catch (std::exception &ex)
	{
		// TODO: better atomic cursor handling?
		SetCursor(previous);
		MessageBox(sheet, ex.what(), "Scenario Save Error", MB_ICONWARNING);
	}

	//perform after-saving operations
	SendMessage(cpage, AOKTS_Loading, 0, 0);

	//report any errors
	if (error)
	{
		SetWindowText(propdata.statusbar, scen.msg);
		//MessageBox(sheet, scen.msg, "Save Error", MB_OK);
	}
}
Exemple #16
0
/*
	FileSave: Handles a request to save the currently open file.

	Parameters:
	HWND sheet: Handle to the property sheet.
	bool as:		Save or Save As?
*/
void FileSave(HWND sheet, bool as, bool write)
{
	int error;			//error value from Scenario::save()
	HWND cpage;			//the current property page
	HCURSOR previous;	//the mouse cursor before/after save operation
	OPENFILENAME ofn;
	char titleBuffer[100];
	Game startver;
	Game conv = NOCONV;
    SaveFlags::Value flags = SaveFlags::NONE;

	//init
	cpage = PropSheet_GetCurrentPageHwnd(sheet);

	//Save As: Ask for filename.
	if (as || *setts.ScenPath == '\0')
	{
		char dir[_MAX_PATH];
		strcpy(dir, setts.BasePath);
		strcat(dir, "Scenario");

		ofn.lStructSize = sizeof(OPENFILENAME);
		ofn.hwndOwner = sheet;
		ofn.lpstrFilter = extSave;
		ofn.lpstrCustomFilter = NULL;
		ofn.lpstrFile = setts.ScenPath;
		ofn.nMaxFile = _MAX_PATH;
		ofn.lpstrFileTitle = NULL;
		ofn.lpstrInitialDir = dir;
		ofn.lpstrTitle = NULL;
		ofn.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT;

	    startver = scen.game;

		switch (scen.game) {
		case AOK:
		    ofn.nFilterIndex =	1;
		    ofn.lpstrDefExt =	"scn";
		    break;
		case AOC:
		    ofn.nFilterIndex =	2;
		    ofn.lpstrDefExt =	"scx";
		    break;
		case UP:
		    ofn.nFilterIndex =	3;
		    ofn.lpstrDefExt =	"scx";
		    break;
		case AOHD:
		case AOHD4:
		    ofn.nFilterIndex =	4;
		    ofn.lpstrDefExt =	"scx";
		    break;
		case AOF:
		case AOF4:
		    ofn.nFilterIndex =	5;
		    ofn.lpstrDefExt =	"scx2";
		    break;
		case SWGB:
		    ofn.nFilterIndex =	6;
		    ofn.lpstrDefExt =	"scx";
		    break;
		case SWGBCC:
		    ofn.nFilterIndex =	7;
		    ofn.lpstrDefExt =	"sc1";
		    break;
		case AOHD6:
		    ofn.nFilterIndex =	8;
		    ofn.lpstrDefExt =	"scx";
		    break;
		case AOF6:
		    ofn.nFilterIndex =	9;
		    ofn.lpstrDefExt =	"scx2";
		    break;
		}

		if (!GetSaveFileName(&ofn))
			return;

		switch (ofn.nFilterIndex) {
		case 1:
		    conv = AOK;
		    break;
		case 2:
		    conv = AOC;
		    break;
		case 3:
		    conv = UP;
		    break;
		case 4:
		    conv = AOHD4;
		    break;
		case 5:
		    conv = AOF4;
		    break;
		case 6:
		    conv = SWGB;
		    break;
		case 7:
		    conv = SWGBCC;
		    break;
		case 8:
		    conv = AOHD6;
		    break;
		case 9:
		    conv = AOF6;
		    break;
		}

		if (!*scen.origname)
			strcpy(scen.origname, setts.ScenPath + ofn.nFileOffset);

		/* Update window title since filename has probably changed */
		_snprintf(titleBuffer, sizeof(titleBuffer),
			"%s - %s", szTitle, setts.ScenPath + ofn.nFileOffset);
		SetWindowText(sheet, titleBuffer);
	} else {
	    conv = scen.game;
	}

    if ((startver == AOHD || startver == AOF || startver == AOHD4 || startver == AOF4 || startver == AOHD6 || startver == AOF6) && conv == UP) {
        if (setts.asktoconverteffects &&
            MessageBox(sheet, "Also convert HD effects to UserPatch?", "Convert", MB_YESNOCANCEL) == IDYES) {
            flags = (SaveFlags::Value)(flags | SaveFlags::CONVERT_EFFECTS);
        }
    }

    if (startver == UP && (conv == AOHD || conv == AOF || conv == AOHD4 || conv == AOF4 || conv == AOHD6 || conv == AOF6)) {
        if (setts.asktoconverteffects &&
            MessageBox(sheet, "Also convert UserPatch effects to HD?", "Convert", MB_YESNOCANCEL) == IDYES) {
            flags = (SaveFlags::Value)(flags | SaveFlags::CONVERT_EFFECTS);
        }
    }

	//update scenario data
	SendMessage(cpage, AOKTS_Saving, 0, 0);

	//perform before-saving operations
	previous = SetCursor(LoadCursor(NULL, IDC_WAIT));
	// Pretend we're "closing" the scenario because it may change during the
	// save.
	SendMessage(cpage, AOKTS_Closing, 0, 0);
	scen.clean_triggers();

	//save the scenario
	try
	{
 		error = scen.save(setts.ScenPath, setts.TempPath, write, conv, flags);
		SetCursor(previous);
	}
	catch (std::exception &ex)
	{
		// TODO: better atomic cursor handling?
		SetCursor(previous);
		MessageBox(sheet, ex.what(), "Scenario Save Error", MB_ICONWARNING);
	}

	//perform after-saving operations
	SendMessage(cpage, AOKTS_Loading, 0, 0);

	//report any errors
	if (error)
	{
		SetWindowText(propdata.statusbar, scen.msg);
		//MessageBox(sheet, scen.msg, "Save Error", MB_OK);
	}
}
Exemple #17
0
/*
	PropSheetProc: Handles special messages pertaining to the property sheet.

	Note: See PropSheetProc in the Platform SDK docs for parameters and notes.
*/
int CALLBACK PropSheetProc(HWND sheet, UINT msgid, LPARAM lParam)
{
	switch (msgid)
	{
	case PSCB_PRECREATE:
		{
			DLGTEMPLATE *templ = (DLGTEMPLATE*)lParam;

			templ->cy += 5;

			//add a minimize box
			templ->style |= WS_MINIMIZEBOX;
		}
		break;

	case PSCB_INITIALIZED:
		{
			HWND tooltip;
			HICON icon;

			/* Add Menu. */
			propdata.menu = LoadMenu(aokts, (LPCSTR)IDM_MAIN);
			SetMenu(sheet, propdata.menu);
			//SetSaveState(sheet, MF_GRAYED);
	        scen.reset();
	        SendMessage(PropSheet_GetCurrentPageHwnd(sheet), AOKTS_Loading, 0, 0);
	        MapView_Reset(propdata.mapview, true);

			/* Enable appropriate recent file items. */
			UpdateRecentMenu(propdata.menu);

			/* Remove unused buttons. */
			for (int i = 0; i < sizeof(PropSheetButtons) / sizeof(WORD); i++)
			{
				HWND hWnd = GetDlgItem(sheet, PropSheetButtons[i]);
				if (hWnd != NULL)
				{
					ShowWindow(hWnd, SW_HIDE);
					EnableWindow(hWnd, FALSE);
				}
			}

			/* Add a tooltip window */
			tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, "AOKTS Tooltip", WS_POPUP,
				CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
				sheet, NULL, aokts, NULL);
			TooltipInit(tooltip);

			/* Set the big icon */
			icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LOGO));
			Window_SetIcon(sheet, ICON_BIG, icon);

            if (setts.editall) {
                CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND | MF_CHECKED);
            } else {
                CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND);
            }
		}
		break;
	}
	return 0;
}
Exemple #18
0
/*
	FileOpen: Handles a request to open a file. (Either by menu or generated by the app.)

	Parameters:
	HWND sheet: Handle to the property sheet.
	bool ask:	Should AOKTS ask the user which file?
	int recent:	Optionally open from one of the recent file entries. (-1 to disable.)
*/
void FileOpen(HWND sheet, bool ask, int recent)
{
	OPENFILENAME ofn;
	struct RecentFile *file = NULL;	//the file info will be stored here one way or another
	char titleBuffer[100];
	const char *filename;
	Game version = scen.game;

	HWND page = PropSheet_GetCurrentPageHwnd(sheet);

	//save the scenario if changes have been made (NOT FUNCTIONAL)
	if (scen.needsave())
	{
		int sel = MessageBox(sheet, askSaveChanges, "Save", MB_YESNOCANCEL);

		if (sel == IDYES)
			FileSave(sheet, false, true);

		else if (sel == IDCANCEL)
			return;	//stop closing
	}

    // Hint about whether to open as AOC or SGWB
	if (setts.recent_first) {
	     scen.game = (Game)setts.recent_first->game;
	}

	/* Using a recent file... */
	if (recent >= 0)
	{
		ofn.Flags = 0;	//make sure no random flags set
		file = setts.recent_first;

		/* Parse the linked list to find the one we want */
		while (recent--)
		{
			if (file)
				file = file->next;
			else
			{
				MessageBox(sheet,
					"Warning: Recent File open failed.",
					"Open Warning", MB_ICONWARNING);
			}
		}

		strcpy(setts.ScenPath, file->path);
		version = (Game)file->game;
	}
	/* Prompt the user for a filename. */
	else if (ask)
	{
		struct RecentFile *r_parse;
		char dir[_MAX_PATH];
		strcpy(dir, setts.BasePath);
		strcat(dir, "Scenario");

		ofn.lStructSize =	sizeof(OPENFILENAME);
		ofn.hwndOwner =		sheet;
		//ofn.hInstance unused
		ofn.lpstrFilter =	extOpen;
		ofn.lpstrCustomFilter = NULL;	//user should not set custom filters
		ofn.lpstrFile =		setts.ScenPath;
		ofn.nMaxFile =		_MAX_PATH;
		ofn.lpstrFileTitle = NULL;
		ofn.lpstrInitialDir = dir;
		ofn.lpstrTitle =	NULL;
		ofn.Flags =			OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON | OFN_NOCHANGEDIR;

		if (scen.header.header_type == HT_AOE2SCENARIO) {
		    ofn.nFilterIndex =	1;
		    ofn.lpstrDefExt =	"aoe2scenario";
		} else {
		    switch (scen.game) {
		    case AOK:
		    case AOC:
		    case AOHD:
		    case AOF:
		    case AOHD4:
		    case AOF4:
		    case AOHD6:
		    case AOF6:
		        ofn.nFilterIndex =	1;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case SWGB:
		    case SWGBCC:
		        ofn.nFilterIndex =	2;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    }
		}

		if (!GetOpenFileName(&ofn))
			return;

		switch (ofn.nFilterIndex) {
		case 1:
		    version = AOC;
		    printf_log("Selected %d, AOE 2.\n", ofn.nFilterIndex);
		    break;
		case 2:
		    version = SWGB;
		    printf_log("Selected %d, Star Wars.\n", ofn.nFilterIndex);
		    break;
		}

		/* Now check if selected file is already on recent list. */
		r_parse = setts.recent_first;
		while (r_parse)
		{
			if (!strcmp(r_parse->path, setts.ScenPath))
			{
				file = r_parse;
				break;
			}
			r_parse = r_parse->next;
		}
	}

	/* Open it! */
	SendMessage(page, AOKTS_Closing, 0, 0);
	// set hourglass, might take more than 1ms
	HCURSOR previous = SetCursor(LoadCursor(NULL, IDC_WAIT));
	scen.reset();
	try
	{
		version = scen.open(setts.ScenPath, setts.TempPath, version);

	    /* Handle recent file stuff */
	    if (!file)
	    {
		    file = setts.recent_getnext();
		    strcpy(file->path, setts.ScenPath);
		    strcpy(file->display, PathFindFileName(setts.ScenPath));
		    file->game = (int)version;
	    }
	    setts.recent_push(file);
	    UpdateRecentMenu(propdata.menu);

		SetCursor(previous);
		// for some reason this is always read only. on Wine at least
		//SetSaveState(sheet, ofn.Flags & OFN_READONLY ? MF_GRAYED : MF_ENABLED);
		SetSaveState(sheet, ofn.Flags & OFN_READONLY ? MF_ENABLED : MF_ENABLED);

		// set status bar text
		SetWindowTextW(propdata.statusbar, L"Scenario loaded successfully.");

	    SendMessage(page, AOKTS_Loading, 0, 0);
        SendMessageW(propdata.mapview, MAP_Recreate, 0, 0);
	    MapView_Reset(propdata.mapview, true);

	    filename = getFilenameFromPath(setts.ScenPath);

	    _snprintf(titleBuffer, sizeof(titleBuffer),
		        "%s - %s", szTitle, filename);

	    SetWindowText(sheet, titleBuffer);
	}
	catch (std::exception &ex)
	{
		// TODO: better atomic cursor handling?
		SetCursor(previous);

		// set status bar text
		SetWindowText(propdata.statusbar, ex.what());

		// report error to user
		std::string desc = "Failed to open as ";

        desc.append(gameName(scen.game));
		desc.append(" scenario file.\n");

		switch (scen.game) {
		case AOC:
		    desc.append("Try opening as a SWGB scx file instead\nusing File->Open\n");
		    break;
		case SWGB:
		    desc.append("Try opening as a Conquerors scx file instead\nusing File->Open\n");
		    break;
		}

		desc.append("\nThe problem: ");
		desc.append(ex.what());

		desc.append("\n\nIf the game is able to open the scenario,\nplease report this error. Thanks.");
		printf_log("User message: %s\n", desc.c_str());
		MessageBox(sheet, desc.c_str(), "Scenario Load Error", MB_ICONWARNING);

		// unless it's a debug build, clear the bad data
	#ifndef _DEBUG
		scen.reset();
		SendMessage(page, AOKTS_Closing, 0, 0);
	#endif

	    /* Updates*/
	    SendMessage(page, AOKTS_Loading, 0, 0);

	    _snprintf(titleBuffer, sizeof(titleBuffer),
		        "%s", szTitle);

	    SetWindowText(sheet, titleBuffer);
	}

	//report errors to logfile
	fflush(stdout);
}
// =========================================================================
// Returns 0 based index of current page specified
// Pass this the HWND for the *main* dialog
int _dlgCypherInfo_GetCurrPageIdx(HWND hDlg)
{
    return _dlgCypherInfo_GetPageIdxOfPage(PropSheet_GetCurrentPageHwnd(hDlg));
}
LRESULT CALLBACK MouseConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                    LPARAM lParam)
{
   static u8 cursel;
   static BOOL enablebuttons;
   static int controlmap[13];
   static int padnum;
   static HWND hParent;
   static int emulatetype;
   int i;

   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         padnum = (int)lParam;

         hParent = PropSheet_GetCurrentPageHwnd(GetParent(hDlg));
         emulatetype = ConvertEmulateTypeSelStringToID(hParent, IDC_PORT1ATYPECB+padnum);
         PERDXListDevices(GetDlgItem(hDlg, IDC_DXDEVICECB), emulatetype);

         // Load settings from ini here, if necessary
         PERDXInitControlConfig(hDlg, padnum, controlmap, inifilename);

         cursel = (u8)SendDlgItemMessage(hDlg, IDC_DXDEVICECB, CB_GETCURSEL, 0, 0);
         enablebuttons = cursel ? TRUE : FALSE;

         EnableWindow(GetDlgItem(hDlg, IDC_STARTPB), enablebuttons);
         EnableWindow(GetDlgItem(hDlg, IDC_APB), enablebuttons);
         EnableWindow(GetDlgItem(hDlg, IDC_BPB), enablebuttons);
         EnableWindow(GetDlgItem(hDlg, IDC_CPB), enablebuttons);
         return TRUE;
      }
      case WM_COMMAND:
      {
         switch (LOWORD(wParam))
         {
            case IDC_STARTPB:
            case IDC_APB:
            case IDC_BPB:
            case IDC_CPB:
            {
               DoControlConfig(hDlg, cursel-1, IDC_UPTEXT+(LOWORD(wParam)-IDC_UPPB), IDC_UPTEXT, controlmap);

               return TRUE;
            }
            case IDOK:
            {
               char string1[20];
               char string2[20];

               EndDialog(hDlg, TRUE);

               sprintf(string1, "Peripheral%d%C", ((padnum/6)+1), 'A'+(padnum%6));

               // Write GUID
               PERDXWriteGUID(cursel-1, padnum, inifilename);

               for (i = 0; i < 13; i++)
               {
                  sprintf(string2, "%d", controlmap[i]);
                  WritePrivateProfileStringA(string1, PerPadNames[i], string2, inifilename);
               }
               return TRUE;
            }
            case IDCANCEL:
            {
               EndDialog(hDlg, FALSE);
               return TRUE;
            }
            case IDC_DXDEVICECB:
            {
               switch(HIWORD(wParam))
               {
                  case CBN_SELCHANGE:
                  {
                     cursel = (u8)SendDlgItemMessage(hDlg, IDC_DXDEVICECB, CB_GETCURSEL, 0, 0);
                     enablebuttons = cursel ? TRUE : FALSE;

                     EnableWindow(GetDlgItem(hDlg, IDC_STARTPB), enablebuttons);
                     EnableWindow(GetDlgItem(hDlg, IDC_APB), enablebuttons);
                     EnableWindow(GetDlgItem(hDlg, IDC_BPB), enablebuttons);
                     EnableWindow(GetDlgItem(hDlg, IDC_CPB), enablebuttons);
                     break;
                  }
                  default: break;
               }
               break;
            }
            default: break;
         }

         break;
      }
      case WM_DESTROY:
      {
         break;
      }
   }

   return FALSE;
}
Exemple #21
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    MSG msg;
    HACCEL hAccelTable;

    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);
    UNREFERENCED_PARAMETER(nCmdShow);

    /*
     * Initialize this instance of MSConfig. Quit if we have
     * another instance already running.
     */
    if (!Initialize(hInstance))
        return -1;

    // hInst = hInstance;

    hMainWnd = CreatePropSheet(hInstance, NULL, szAppName);
    if (!hMainWnd)
    {
        /* We failed, cleanup and bail out */
        Cleanup();
        return -1;
    }

    hAccelTable = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_MSCONFIG));

    /* Message loop */
    while (IsWindow(hMainWnd) && GetMessageW(&msg, NULL, 0, 0))
    {
        /*
         * PropSheet_GetCurrentPageHwnd returns NULL when the user clicks the OK or Cancel button
         * and after all of the pages have been notified. Apply button doesn't cause this to happen.
         * We can then use the DestroyWindow function to destroy the property sheet.
         */
        if (PropSheet_GetCurrentPageHwnd(hMainWnd) == NULL)
            break;

        /* Process the accelerator table */
        if (!TranslateAcceleratorW(hMainWnd, hAccelTable, &msg))
        {
            /*
             * If e.g. an item on the tree view is being edited,
             * we cannot pass the event to PropSheet_IsDialogMessage.
             * Doing so causes the property sheet to be closed at Enter press
             * (instead of completing edit operation).
             */
            if (/*g_bDisableDialogDispatch ||*/ !PropSheet_IsDialogMessage(hMainWnd, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessageW(&msg);
            }
        }
    }

    // FIXME: Process the results of MSConfig !!

    /* Destroy the accelerator table and the window */
    if (hAccelTable != NULL)
        DestroyAcceleratorTable(hAccelTable);

    DestroyWindow(hMainWnd);

    /* Finish cleanup and return */
    Cleanup();
    return (int)msg.wParam;
}
Exemple #22
0
HWND PropertySheetDialog::GetCurrentPage()
{
	HWND hdlg = PropSheet_GetCurrentPageHwnd(_hwnd);
	return hdlg;
}
Exemple #23
0
/*
 * set_filter_item_proc - フィルタの項目を設定
 */
static BOOL CALLBACK set_filter_item_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HMENU hMenu;
	RECT button_rect;
	FILTER_INFO *fi;
	TCHAR buf[BUF_SIZE];
	DWORD ret;
	UINT format;
#ifdef OP_XP_STYLE
	static long hTheme;
#endif	// OP_XP_STYLE

	switch (uMsg) {
	case WM_INITDIALOG:
#ifdef OP_XP_STYLE
		// XP
		hTheme = open_theme(GetDlgItem(hDlg, IDC_BUTTON_FORMAT), L"SCROLLBAR");
#endif	// OP_XP_STYLE
		// スピンコントロールの設定
		SendDlgItemMessage(hDlg, IDC_SPIN_SIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(UD_MAXVAL, 0));

		if (lParam == 0) {
			// 新規追加
			if (*cmd_filter != TEXT('\0')) {
				SendDlgItemMessage(hDlg, IDC_EDIT_FORMAT_NAME, WM_SETTEXT, 0, (LPARAM)cmd_filter);
				*cmd_filter = TEXT('\0');
			}
			CheckDlgButton(hDlg, IDC_RADIO_ADD, 1);
			SetDlgItemInt(hDlg, IDC_EDIT_SIZE, 0, FALSE);
			SetWindowLong(hDlg, GWL_USERDATA, 0);
			break;
		}
		fi = (FILTER_INFO *)lParam;

		SendDlgItemMessage(hDlg, IDC_EDIT_FORMAT_NAME, WM_SETTEXT, 0, (LPARAM)fi->format_name);
		if (fi->action == FILTER_ACTION_ADD) {
			CheckDlgButton(hDlg, IDC_RADIO_ADD, 1);
		} else {
			CheckDlgButton(hDlg, IDC_RADIO_IGNORE, 1);
		}
		CheckDlgButton(hDlg, IDC_CHECK_NOSAVE, !fi->save);
		SetDlgItemInt(hDlg, IDC_EDIT_SIZE, fi->limit_size, FALSE);

		EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOSAVE), IsDlgButtonChecked(hDlg, IDC_RADIO_ADD));
		EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SIZE), IsDlgButtonChecked(hDlg, IDC_RADIO_ADD));

		SetWindowLong(hDlg, GWL_USERDATA, lParam);
		break;

	case WM_CLOSE:
#ifdef OP_XP_STYLE
		if (hTheme != 0) {
			close_theme(hTheme);
		}
#endif	// OP_XP_STYLE
		EndDialog(hDlg, FALSE);
		break;

	case WM_DRAWITEM:
		// ボタンの描画
#ifdef OP_XP_STYLE
		if (hTheme != 0) {
			draw_theme_scroll((LPDRAWITEMSTRUCT)lParam, DFCS_SCROLLRIGHT, hTheme);
		} else {
			draw_scroll_sontrol((LPDRAWITEMSTRUCT)lParam, DFCS_SCROLLRIGHT);
		}
#else	// OP_XP_STYLE
		draw_scroll_sontrol((LPDRAWITEMSTRUCT)lParam, DFCS_SCROLLRIGHT);
#endif	// OP_XP_STYLE
		break;

#ifdef OP_XP_STYLE
	case WM_THEMECHANGED:
		// テーマの変更
		if (hTheme != 0) {
			close_theme(hTheme);
		}
		hTheme = open_theme(GetDlgItem(hDlg, IDC_BUTTON_FORMAT), L"SCROLLBAR");
		break;
#endif	// OP_XP_STYLE

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_BUTTON_FORMAT:
			// 形式選択
			if (OpenClipboard(hDlg) == FALSE) {
				break;
			}
			// メニューの作成
			hMenu = CreatePopupMenu();
			format = 0;
			ret = 1;
			while ((format = EnumClipboardFormats(format)) != 0) {
				clipboard_get_format(format, buf);
				AppendMenu(hMenu, MF_STRING, ret++, buf);
			}
			CloseClipboard();
			if (ret == 1) {
				DestroyMenu(hMenu);
				break;
			}

			// メニューの表示
			GetWindowRect(GetDlgItem(hDlg, LOWORD(wParam)), (LPRECT)&button_rect);
			ret = TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_RETURNCMD, button_rect.right, button_rect.top, 0, hDlg, NULL);
			if (ret > 0) {
				GetMenuString(hMenu, ret, buf, BUF_SIZE - 1, MF_BYCOMMAND);
				SendDlgItemMessage(hDlg, IDC_EDIT_FORMAT_NAME, EM_REPLACESEL, 0, (LPARAM)buf);
			}
			DestroyMenu(hMenu);
			break;

		case IDC_RADIO_ADD:
		case IDC_RADIO_IGNORE:
			EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOSAVE), IsDlgButtonChecked(hDlg, IDC_RADIO_ADD));
			EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SIZE), IsDlgButtonChecked(hDlg, IDC_RADIO_ADD));
			break;

		case IDOK:
			*buf = TEXT('\0');
			SendDlgItemMessage(hDlg, IDC_EDIT_FORMAT_NAME, WM_GETTEXT, BUF_SIZE - 1, (LPARAM)buf);
			if (*buf == TEXT('\0')) {
				MessageBox(hDlg, message_get_res(IDS_FILTER_ERR_NAME), WINDOW_TITLE, MB_ICONEXCLAMATION);
				SetFocus(GetDlgItem(hDlg, IDC_EDIT_FORMAT_NAME));
				break;
			}

			if ((fi = (FILTER_INFO *)GetWindowLong(hDlg, GWL_USERDATA)) == NULL) {
				fi = mem_calloc(sizeof(FILTER_INFO));
			}
			if (fi != NULL) {
				// 設定取得
				alloc_get_text(GetDlgItem(hDlg, IDC_EDIT_FORMAT_NAME), &fi->format_name);
				fi->action = IsDlgButtonChecked(hDlg, IDC_RADIO_IGNORE);
				fi->save = !IsDlgButtonChecked(hDlg, IDC_CHECK_NOSAVE);
				fi->limit_size = GetDlgItemInt(hDlg, IDC_EDIT_SIZE, NULL, FALSE);
			}

			if (GetWindowLong(hDlg, GWL_USERDATA) == 0) {
				// 新規
				HWND pWnd = PropSheet_GetCurrentPageHwnd(GetParent(hDlg));
				listview_set_filter(GetDlgItem(pWnd, IDC_LIST_FILTER), fi, FALSE);
			}
#ifdef OP_XP_STYLE
			if (hTheme != 0) {
				close_theme(hTheme);
			}
#endif	// OP_XP_STYLE
			EndDialog(hDlg, TRUE);
			break;

		case IDCANCEL:
#ifdef OP_XP_STYLE
			if (hTheme != 0) {
				close_theme(hTheme);
			}
#endif	// OP_XP_STYLE
			EndDialog(hDlg, FALSE);
			break;
		}
		break;

	default:
		return FALSE;
	}
	return TRUE;
}
Exemple #24
0
/*
	Sheet_HandleCommand: Handles all commands routed to property sheet (mostly menuitem stuff).
*/
bool Sheet_HandleCommand(HWND sheet, WORD code, WORD id, HWND control)
{
	bool ret = true;
	Player *p = propdata.p;

	switch (id)
	{
	case ID_FILE_REOPEN:
		FileOpen(sheet, false, 0);
		break;

	case ID_TS_FILE_OPEN:
		FileOpen(sheet, true, -1);
		break;

	case ID_TS_FILE_NEW:
	case ID_TS_FILE_CLOSE:
		FileClose(sheet, control);
		break;

	case ID_TS_APP_EXIT:
		if (scen.needsave())
		{
			int sel = MessageBox(sheet, "Do you want to save your changes?", "Save", MB_YESNOCANCEL);
			if (sel == IDYES)
				FileSave(sheet, false, true);
			else if (sel == IDCANCEL)
				break;	//stop closing
		}
		DestroyWindow(sheet);
		break;

	case ID_TS_FILE_SAVE:
		FileSave(sheet, false, true);
		break;

	case ID_TS_FILE_SAVE_AS:
		FileSave(sheet, true, true);
		break;

	case ID_TS_FILE_SAVE_AS2:
		FileSave(sheet, true, false);

	case ID_FILE_DUMP:
		if (!scen.exFile("dump", -1))
		{
			MessageBox(sheet, "Dump failed.", "Scenario Dump", MB_ICONWARNING);
		} else {
		    SetWindowText(propdata.statusbar, "Per files saved to disk");
		}
		break;

	case IDC_U_CLEARAICPVC:
	    scen.clearaicpvc();
		SetWindowText(propdata.statusbar, "Removed All AI, City Plan and VC files");
	    SendMessage(PropSheet_GetCurrentPageHwnd(sheet), AOKTS_Loading, 0, 0);
		break;

	case IDC_U_RANDOMIZE_ROT:
	    scen.randomize_unit_frames();
		SetWindowText(propdata.statusbar, "Randomized unit frames and rotations");
		break;

	case ID_UNITS_TERRAIN_ELEV:
	    scen.set_unit_z_to_map_elev();
		SetWindowText(propdata.statusbar, "Unit z positions set to terrain elevation");
		break;

	case ID_UNITS_DELETE_ALL:
		scen.delete_player_units(propdata.pindex);
		SetWindowText(propdata.statusbar, "Player's units deleted");
	    SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_MAP_WATER_CLIFF_INVISIBLE:
		scen.water_cliffs_visibility(FALSE);
		SetWindowText(propdata.statusbar, "Water cliffs are now invisible");
		break;

	case ID_MAP_WATER_CLIFF_VISIBLE:
		scen.water_cliffs_visibility(TRUE);
		SetWindowText(propdata.statusbar, "Water cliffs are now visible");
		break;

	case ID_TRIGGERS_SORT_CONDS_EFFECTS:
		scen.sort_conds_effects();
		SetWindowText(propdata.statusbar, "Trigger contitions and effects sorted alphanumerically");
		break;

	case ID_TRIGGERS_NOINSTRUCTIONSSOUND:
		scen.instructions_sound_text_set();
		SetWindowText(propdata.statusbar, "Sound text set to null");
		break;

	case ID_TRIGGERS_NOINSTRUCTIONSSOUNDID:
		scen.instructions_sound_id_set(-1);
		SetWindowText(propdata.statusbar, "Sound ID set to -1 for all display instructions effects");
		break;

	case ID_TRIGGERS_ZEROINSTRUCTIONSSOUNDID:
		scen.instructions_sound_id_set(0);
		SetWindowText(propdata.statusbar, "Sound ID set to 0 for all display instructions effects");
		break;

	case ID_TRIGGERS_NOPANEL:
		scen.instructions_panel_set(-1);
		SetWindowText(propdata.statusbar, "Panel ID removed from all display instructions effects");
		break;

	case ID_TRIGGERS_ZEROPANEL:
		scen.instructions_panel_set(0);
		SetWindowText(propdata.statusbar, "Panel ID set to 0 for all display instructions effects");
		break;

	case ID_TRIGGERS_ZERODI:
		scen.instructions_string_zero();
		SetWindowText(propdata.statusbar, "String ID set to 0 for all display instructions effects");
		break;

	case ID_TRIGGERS_RESETDI:
		scen.instructions_string_reset();
		SetWindowText(propdata.statusbar, "String ID set to -1 for all display instructions effects");
		break;

	case ID_TRIGGERS_HIDENAMES:
		scen.remove_trigger_names();
		SetWindowText(propdata.statusbar, "Trigger names removed");
		break;

	case ID_TRIGGERS_COPY_SCRAWL:
	    {
            std::ostringstream ss;
	        scen.accept(TrigScrawlVisitor(ss));
            std::string scrawl = std::string("");
	        scrawl.append(ss.str());

	        const char* output = scrawl.c_str();
            const size_t len = strlen(output) + 1;
            HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
            memcpy(GlobalLock(hMem), output, len);
            GlobalUnlock(hMem);
            OpenClipboard(0);
            EmptyClipboard();
            SetClipboardData(CF_TEXT, hMem);
            CloseClipboard();
		    SetWindowText(propdata.statusbar, "Copied trigger scrawl");
		}
		break;

	case ID_TRIGGERS_SAVE_PSEUDONYMS:
		scen.save_pseudonyms();
		SetWindowText(propdata.statusbar, "Pseudonyms saved");
		break;

	case ID_TRIGGERS_PREFIX_DISPLAY_ORDER:
		scen.prefix_display_order();
		SetWindowText(propdata.statusbar, "Prefixing display order to trigger names");
		break;

	case ID_TRIGGERS_REMOVE_DISPLAY_ORDER_PREFIX:
		scen.remove_display_order_prefix();
		SetWindowText(propdata.statusbar, "Prefixing display order to trigger names");
		break;

	case ID_TRIGGERS_HIDE_DESCRIPTIONS:
		scen.remove_trigger_descriptions();
		SetWindowText(propdata.statusbar, "Trigger descriptions removed");
		break;

	case ID_TRIGGERS_SWAP_NAMES_DESCRIPTIONS:
		scen.swap_trigger_names_descriptions();
		SetWindowText(propdata.statusbar, "Trigger names swapped with descriptions");
		break;

	case ID_TRIGGERS_FIXTRIGGEROUTLIERS:
		scen.fix_trigger_outliers();
		SetWindowText(propdata.statusbar, "Triggers outside of map have been put within the boundaries");
		break;

	case ID_FILE_TRIGWRITE:
		OnFileTrigWrite(sheet);
		break;

	case ID_FILE_TRIGREAD:
		OnFileTrigRead(sheet);
		break;

	case IDC_P_TOUP:
        if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) {
		    scen.hd_to_up();
		    SetWindowText(propdata.statusbar, "Trigger effects converted from AoHD to UserPatch");
		}
		break;

	case IDC_P_TOHD:
        if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) {
		    scen.up_to_hd();
		    SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to AoHD");
		}
		break;

	case IDC_P_TOAOFE:
        if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) {
		    scen.up_to_aofe();
		    SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to AoFE");
		}
		break;

	case IDC_P_TO1C:
        if (MessageBox(sheet, "Normally, you will be asked to do this later when you save the scenario to a different format.\nThis menu for fixing broken scenarios. Are you sure you want to do this?", "Convert", MB_YESNOCANCEL) == IDYES) {
		    scen.up_to_10c();
		    SetWindowText(propdata.statusbar, "Trigger effects converted from UserPatch to 1.0c");
		}
		break;

	case ID_FILE_RECENT1:
	case ID_FILE_RECENT2:
	case ID_FILE_RECENT3:
	case ID_FILE_RECENT4:
		FileOpen(sheet, false, id - ID_FILE_RECENT1);
		break;

	case IDCANCEL:
	case IDOK:
		assert(true);
		break;

	case ID_VIEW_STATISTICS:
		DialogBoxParam(aokts, MAKEINTRESOURCE(IDD_STATS), sheet, StatsDialogProc, 0);
		break;

	case ID_VIEW_STAT_BAR:
		if (GetMenuState(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND) & MF_CHECKED)
		{
			ShowWindow(propdata.statusbar, SW_HIDE);
			CheckMenuItem(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND);
		}
		else
		{
			ShowWindow(propdata.statusbar, SW_SHOW);
			CheckMenuItem(GetMenu(sheet), ID_VIEW_STAT_BAR, MF_BYCOMMAND | MF_CHECKED);
		}
		break;

	case ID_VIEW_MAP:
		if (GetMenuState(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND) & MF_CHECKED)
		{
			// hide window
			ShowWindow(propdata.mapview, SW_HIDE);
			// clear check
			CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND);
		}
		else
		{
			ShowWindow(propdata.mapview, SW_SHOW);
			CheckMenuItem(GetMenu(sheet), ID_VIEW_MAP, MF_BYCOMMAND | MF_CHECKED);
		}
		break;

	case ID_DRAW_TERRAIN:
		if (GetMenuState(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.drawterrain = false;
			// clear check
			CheckMenuItem(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND);
		}
		else
		{
		    setts.drawterrain = true;
			// clear check
			CheckMenuItem(GetMenu(sheet), ID_DRAW_TERRAIN, MF_BYCOMMAND | MF_CHECKED);
		}
		SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_DRAW_ELEVATION:
		if (GetMenuState(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.drawelevation = false;
			// clear check
			CheckMenuItem(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND);
		}
		else
		{
		    setts.drawelevation = true;
			// clear check
			CheckMenuItem(GetMenu(sheet), ID_DRAW_ELEVATION, MF_BYCOMMAND | MF_CHECKED);
		}
		SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_DRAW_TRIGGERS:
		if (GetMenuState(GetMenu(sheet), ID_DRAW_TRIGGERS, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.drawconds = false;
		    setts.draweffects = false;
		    setts.drawlocations = false;
		}
		else
		{
		    setts.drawconds = true;
		    setts.draweffects = true;
		    setts.drawlocations = true;
		}
		SetDrawTriggerCheckboxes(sheet);
		SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_DRAW_CONDITIONS:
		if (GetMenuState(GetMenu(sheet), ID_DRAW_CONDITIONS, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.drawconds = false;
		}
		else
		{
		    setts.drawconds = true;
		}
		SetDrawTriggerCheckboxes(sheet);
		SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_DRAW_EFFECTS:
		if (GetMenuState(GetMenu(sheet), ID_DRAW_EFFECTS, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.draweffects = false;
		}
		else
		{
		    setts.draweffects = true;
		}
		SetDrawTriggerCheckboxes(sheet);
		SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_DRAW_LOCATIONS:
		if (GetMenuState(GetMenu(sheet), ID_DRAW_LOCATIONS, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.drawlocations = false;
		}
		else
		{
		    setts.drawlocations = true;
		}
		SetDrawTriggerCheckboxes(sheet);
		SendMessage(propdata.mapview, MAP_Reset, 0, 0);
		break;

	case ID_EDIT_ALL:
		if (GetMenuState(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND) & MF_CHECKED)
		{
		    setts.editall = false;
			// clear check
			CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND);
		}
		else
		{
		    setts.editall = true;
			CheckMenuItem(GetMenu(sheet), ID_EDIT_ALL, MF_BYCOMMAND | MF_CHECKED);
		}
		break;

	case ID_TOOLS_COMPRESS:
		OnCompressOrDecompress(sheet, true);
		break;

	case ID_TOOLS_DECOMPRESS:
		OnCompressOrDecompress(sheet, false);
		break;

	case ID_TS_HELP:
		WinHelp(sheet, "ts.hlp", HELP_CONTENTS, 0);
		break;

	case ID_TS_APP_ABOUT:
		DialogBoxParam(aokts, (LPCSTR)IDD_ABOUT, sheet, DefaultDialogProc, 0L);
		break;

	default:
		ret = false;
	}

	return ret;
}
Exemple #25
0
BOOLEAN PhModalPropertySheet(
    _Inout_ PROPSHEETHEADER *Header
    )
{
    // PropertySheet incorrectly discards WM_QUIT messages in certain cases, so we will use our own
    // message loop. An example of this is when GetMessage (called by PropertySheet's message loop)
    // dispatches a message directly from kernel-mode that causes the property sheet to close.
    // In that case PropertySheet will retrieve the WM_QUIT message but will ignore it because of
    // its buggy logic.

    // This is also a good opportunity to introduce an auto-pool.

    PH_AUTO_POOL autoPool;
    HWND oldFocus;
    HWND topLevelOwner;
    HWND hwnd;
    BOOL result;
    MSG message;

    PhInitializeAutoPool(&autoPool);

    oldFocus = GetFocus();
    topLevelOwner = Header->hwndParent;

    while (topLevelOwner && (GetWindowLong(topLevelOwner, GWL_STYLE) & WS_CHILD))
        topLevelOwner = GetParent(topLevelOwner);

    if (topLevelOwner && (topLevelOwner == GetDesktopWindow() || EnableWindow(topLevelOwner, FALSE)))
        topLevelOwner = NULL;

    Header->dwFlags |= PSH_MODELESS;
    hwnd = (HWND)PropertySheet(Header);

    if (!hwnd)
    {
        if (topLevelOwner)
            EnableWindow(topLevelOwner, TRUE);

        return FALSE;
    }

    while (result = GetMessage(&message, NULL, 0, 0))
    {
        if (result == -1)
            break;

        if (!PropSheet_IsDialogMessage(hwnd, &message))
        {
            TranslateMessage(&message);
            DispatchMessage(&message);
        }

        PhDrainAutoPool(&autoPool);

        // Destroy the window when necessary.
        if (!PropSheet_GetCurrentPageHwnd(hwnd))
            break;
    }

    if (result == 0)
        PostQuitMessage((INT)message.wParam);
    if (Header->hwndParent && GetActiveWindow() == hwnd)
        SetActiveWindow(Header->hwndParent);
    if (topLevelOwner)
        EnableWindow(topLevelOwner, TRUE);
    if (oldFocus && IsWindow(oldFocus))
        SetFocus(oldFocus);

    DestroyWindow(hwnd);
    PhDeleteAutoPool(&autoPool);

    return TRUE;
}