Esempio n. 1
0
int mainSetupAndRun() {
    try {
        int colour_depth = GetOptionsDB().Get<int>("color-depth");
        bool fullscreen = GetOptionsDB().Get<bool>("fullscreen");
        bool fake_mode_change = GetOptionsDB().Get<bool>("fake-mode-change");

        std::pair<int, int> width_height = HumanClientApp::GetWindowWidthHeight();
        int width(width_height.first), height(width_height.second);
        std::pair<int, int> left_top = HumanClientApp::GetWindowLeftTop();
        int left(left_top.first), top(left_top.second);

        int fullscreen_monitor_id = GetOptionsDB().Get<int>("fullscreen-monitor-id");

#ifdef FREEORION_WIN32
#  ifdef IDI_ICON1
        // set window icon to embedded application icon
        HWND hwnd;
        window->getCustomAttribute("WINDOW", &hwnd);
        HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL);
        SetClassLong (hwnd, GCL_HICON,
            (LONG)LoadIcon (hInst, MAKEINTRESOURCE (IDI_ICON1)));
#  endif
#endif

        parse::init();
        HumanClientApp app(width_height.first, width_height.second, true, "FreeOrion " + FreeOrionVersionString(),
                           left, top, fullscreen, fake_mode_change);

        if (GetOptionsDB().Get<bool>("quickstart")) {
            // immediately start the server, establish network connections, and
            // go into a single player game, using default universe options (a
            // standard quickstart, without requiring the user to click the
            // quickstart button).
            app.NewSinglePlayerGame(true);  // acceptable to call before app()
        }

        std::string load_filename = GetOptionsDB().Get<std::string>("load");
        if (!load_filename.empty()) {
            // immediately start the server, establish network connections, and
            // go into a single player game, loading the indicated file
            // (without requiring the user to click the load button).
            app.LoadSinglePlayerGame(load_filename);  // acceptable to call before app()
        }

        // run rendering loop
        app();  // calls GUI::operator() which calls SDLGUI::Run() which starts rendering loop

    } catch (const HumanClientApp::CleanQuit&) {
        // do nothing
        std::cout << "mainSetupAndRun caught CleanQuit" << std::endl;
    } catch (const std::invalid_argument& e) {
        ErrorLogger() << "main() caught exception(std::invalid_argument): " << e.what();
        std::cerr << "main() caught exception(std::invalid_arg): " << e.what() << std::endl;
    } catch (const std::runtime_error& e) {
        ErrorLogger() << "main() caught exception(std::runtime_error): " << e.what();
        std::cerr << "main() caught exception(std::runtime_error): " << e.what() << std::endl;
    } catch (const  boost::io::format_error& e) {
        ErrorLogger() << "main() caught exception(boost::io::format_error): " << e.what();
        std::cerr << "main() caught exception(boost::io::format_error): " << e.what() << std::endl;
    } catch (const GG::ExceptionBase& e) {
        ErrorLogger() << "main() caught exception(" << e.type() << "): " << e.what();
        std::cerr << "main() caught exception(" << e.type() << "): " << e.what() << std::endl;
    } catch (const std::exception& e) {
        ErrorLogger() << "main() caught exception(std::exception): " << e.what();
        std::cerr << "main() caught exception(std::exception): " << e.what() << std::endl;
    } catch (...) {
        ErrorLogger() << "main() caught unknown exception.";
        std::cerr << "main() caught unknown exception." << std::endl;
    }

    return 0;
}
Esempio n. 2
0
	INT_PTR CSettingsDialog::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
	{
		switch (uMsg) {
		case WM_INITDIALOG:
			{
				::SetWindowText(hDlg,GetTitle());

				DeleteAllPages();
				for (int i=0;;i++) {
					CPage *pPage=CreatePage(i);
					if (pPage==nullptr)
						break;

					m_PageList.push_back(pPage);

					::SendDlgItemMessage(hDlg,IDC_SETTINGS_LIST,LB_ADDSTRING,0,i);
				}

				int Page=0;
				if (m_StartPage>=0 && m_StartPage<(int)m_PageList.size())
					Page=m_StartPage;
				else if (m_CurrentPage>=0 && m_CurrentPage<(int)m_PageList.size())
					Page=m_CurrentPage;
				m_CurrentPage=-1;

				if (SetPage(Page)) {
					::SendDlgItemMessage(hDlg,IDC_SETTINGS_LIST,LB_SETCURSEL,Page,0);
				}

				m_himlIcons=::ImageList_LoadImage(m_hinst,MAKEINTRESOURCE(IDB_SETTINGS),16,1,
												  CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION);

				LRESULT ItemHeight=::SendDlgItemMessage(hDlg,IDC_SETTINGS_LIST,LB_GETITEMHEIGHT,0,0);
				if (ItemHeight<16+8)
					::SendDlgItemMessage(hDlg,IDC_SETTINGS_LIST,LB_SETITEMHEIGHT,0,16+8);

				AdjustPos();
			}
			return TRUE;

		case WM_DRAWITEM:
			{
				LPDRAWITEMSTRUCT pdis=reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);

				if (wParam==IDC_SETTINGS_LIST) {
					if (pdis->itemData>=m_PageList.size())
						break;

					const CPage *pPage=m_PageList[pdis->itemData];
					const bool fSelected=(pdis->itemState&ODS_SELECTED)!=0;
					COLORREF crText,crOldText;
					int OldBkMode;
					RECT rcBack,rcText;

					rcBack=pdis->rcItem;
					rcBack.left+=4+16+4;
					if (fSelected) {
						RECT rc=pdis->rcItem;
						rc.right=rcBack.left;
						::FillRect(pdis->hDC,&rc,
								   reinterpret_cast<HBRUSH>(COLOR_WINDOW+1));
						FillGradient(pdis->hDC,rcBack,
									 RGB(0,0,0),pPage->GetTitleColor());
						crText=RGB(255,255,255);
					} else {
						::FillRect(pdis->hDC,&pdis->rcItem,
								   reinterpret_cast<HBRUSH>(COLOR_WINDOW+1));
						crText=::GetSysColor(COLOR_WINDOWTEXT);
					}
					::ImageList_Draw(m_himlIcons,pPage->GetIcon(),pdis->hDC,
									 pdis->rcItem.left+4,
									 rcBack.top+((rcBack.bottom-rcBack.top)-16)/2,
									 ILD_TRANSPARENT);
					rcText=rcBack;
					rcText.left+=4;
					rcText.right-=4;
					crOldText=::SetTextColor(pdis->hDC,crText);
					OldBkMode=::SetBkMode(pdis->hDC,TRANSPARENT);
					::DrawText(pdis->hDC,pPage->GetTitle(),-1,
							   &rcText,DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);
					::SetTextColor(pdis->hDC,crOldText);
					::SetBkMode(pdis->hDC,OldBkMode);
					if ((pdis->itemState & (ODS_FOCUS | ODS_NOFOCUSRECT))==ODS_FOCUS) {
						::DrawFocusRect(pdis->hDC,&rcBack);
					}
				} else if (wParam==IDC_SETTINGS_TITLE) {
					if (m_CurrentPage<0 || (size_t)m_CurrentPage>=m_PageList.size())
						break;

					CPage *pPage=m_PageList[m_CurrentPage];
					RECT rc;

					FillGradient(pdis->hDC,pdis->rcItem,
								 RGB(0,0,0),pPage->GetTitleColor());
					LOGFONT lf;
					::GetObject(reinterpret_cast<HFONT>(::SendMessage(hDlg,WM_GETFONT,0,0)),sizeof(lf),&lf);
					lf.lfWeight=FW_BOLD;
					HFONT hfont=::CreateFontIndirect(&lf);
					HFONT hfontOld=SelectFont(pdis->hDC,hfont);
					COLORREF crOldText=::SetTextColor(pdis->hDC,RGB(255,255,255));
					int OldBkMode=::SetBkMode(pdis->hDC,TRANSPARENT);
					rc.left=pdis->rcItem.left+2;
					rc.top=pdis->rcItem.top;
					rc.right=pdis->rcItem.right-2;
					rc.bottom=pdis->rcItem.bottom;
					::DrawText(pdis->hDC,pPage->GetTitle(),-1,
							   &rc,DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
					SelectFont(pdis->hDC,hfontOld);
					::DeleteObject(hfont);
					::SetTextColor(pdis->hDC,crOldText);
					::SetBkMode(pdis->hDC,OldBkMode);
				}
			}
			return TRUE;

		case WM_COMMAND:
			switch (LOWORD(wParam)) {
			case IDC_SETTINGS_LIST:
				if (HIWORD(wParam)==LBN_SELCHANGE) {
					int Page=(int)::SendDlgItemMessage(hDlg,IDC_SETTINGS_LIST,LB_GETCURSEL,0,0);

					if (Page>=0)
						SetPage(Page);
				}
				return TRUE;

			case IDOK:
				if (QueryOK() && OnOK()) {
					End(IDOK);
				}
				return TRUE;

			case IDCANCEL:
				OnCancel();
				End(IDCANCEL);
				return TRUE;
			}
			return TRUE;

		case WM_APP_SET_PAGE:
			SetPage((int)wParam);
			return TRUE;

		case WM_DESTROY:
			{
				m_StartPage=m_CurrentPage;

				DeleteAllPages();

				if (m_himlIcons!=nullptr) {
					::ImageList_Destroy(m_himlIcons);
					m_himlIcons=nullptr;
				}

				m_Core.RemoveModelessDialog(this);
			}
			return TRUE;
		}

		return FALSE;
	}
Esempio n. 3
0
int APIENTRY
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
        int nCmdShow)
{
    INITCOMMONCONTROLSEX InitCtrls;
    int argc;
    char *argv[MAX_CMDLINE_PARAM];
    size_t len;
    TCHAR *p;
    TCHAR wbuf[BUFSZ];
    char buf[BUFSZ];
    DWORD major, minor;
    boolean resuming;
    /* OSVERSIONINFO osvi; */

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

    sys_early_init();

    /* ensure that we don't access violate on a panic() */
    windowprocs.win_raw_print = mswin_raw_print;
    windowprocs.win_raw_print_bold = mswin_raw_print_bold;

    /* init applicatio structure */
    _nethack_app.hApp = hInstance;
    _nethack_app.hAccelTable =
        LoadAccelerators(hInstance, (LPCTSTR) IDC_NETHACKW);
    _nethack_app.hMainWnd = NULL;
    _nethack_app.hPopupWnd = NULL;
    _nethack_app.bmpTiles = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TILES));
    if (_nethack_app.bmpTiles == NULL)
        panic("cannot load tiles bitmap");
    _nethack_app.bmpPetMark =
        LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PETMARK));
    if (_nethack_app.bmpPetMark == NULL)
        panic("cannot load pet mark bitmap");
#ifdef USE_PILEMARK
    _nethack_app.bmpPileMark =
        LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PILEMARK));
    if (_nethack_app.bmpPileMark == NULL)
        panic("cannot load pile mark bitmap");
#endif
    _nethack_app.bmpRip = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_RIP));
    if (_nethack_app.bmpRip == NULL)
        panic("cannot load rip bitmap");
    _nethack_app.bmpSplash =
        LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_SPLASH));
    if (_nethack_app.bmpSplash == NULL)
        panic("cannot load splash bitmap");
    _nethack_app.bmpMapTiles = _nethack_app.bmpTiles;
    _nethack_app.mapTile_X = TILE_X;
    _nethack_app.mapTile_Y = TILE_Y;
    _nethack_app.mapTilesPerLine = TILES_PER_LINE;

    _nethack_app.bNoHScroll = FALSE;
    _nethack_app.bNoVScroll = FALSE;
    _nethack_app.saved_text = strdup("");

    _nethack_app.bAutoLayout = TRUE;
    _nethack_app.bWindowsLocked = TRUE;

    _nethack_app.bNoSounds = FALSE;

#if 0  /* GdiTransparentBlt does not render spash bitmap for whatever reason */
    /* use system-provided TransparentBlt for Win2k+ */
    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&osvi);
    if (osvi.dwMajorVersion >= 5)
        _nethack_app.lpfnTransparentBlt = GdiTransparentBlt;
    else
#endif
        _nethack_app.lpfnTransparentBlt = _nhapply_image_transparent;

    // init controls
    if (FAILED(GetComCtlVersion(&major, &minor))) {
        char buf[TBUFSZ];
        Sprintf(buf, "Cannot load common control library.\n%s\n%s",
                "For further information, refer to the installation notes at",
                INSTALL_NOTES);
        panic(buf);
    }
    if (major < MIN_COMCTLMAJOR
        || (major == MIN_COMCTLMAJOR && minor < MIN_COMCTLMINOR)) {
        char buf[TBUFSZ];
        Sprintf(buf, "Common control library is outdated.\n%s %d.%d\n%s\n%s",
                "NetHack requires at least version ", MIN_COMCTLMAJOR,
                MIN_COMCTLMINOR,
                "For further information, refer to the installation notes at",
                INSTALL_NOTES);
        panic(buf);
    }
    ZeroMemory(&InitCtrls, sizeof(InitCtrls));
    InitCtrls.dwSize = sizeof(InitCtrls);
    InitCtrls.dwICC = ICC_LISTVIEW_CLASSES;
    InitCommonControlsEx(&InitCtrls);

    /* get command line parameters */
    p = _get_cmd_arg(GetCommandLine());
    p = _get_cmd_arg(NULL); /* skip first paramter - command name */
    for (argc = 1; p && argc < MAX_CMDLINE_PARAM; argc++) {
        len = _tcslen(p);
        if (len > 0) {
            argv[argc] = _strdup(NH_W2A(p, buf, BUFSZ));
        } else {
            argv[argc] = "";
        }
        p = _get_cmd_arg(NULL);
    }
    GetModuleFileName(NULL, wbuf, BUFSZ);
    argv[0] = _strdup(NH_W2A(wbuf, buf, BUFSZ));

    if (argc == 2) {
        TCHAR *savefile = strdup(argv[1]);
        TCHAR *plname;
        for (p = savefile; *p && *p != '-'; p++)
            ;
        if (*p) {
            /* we found a '-' */
            plname = p + 1;
            for (p = plname; *p && *p != '.'; p++)
                ;
            if (*p) {
                if (strcmp(p + 1, "NetHack-saved-game") == 0) {
                    *p = '\0';
                    argv[1] = "-u";
                    argv[2] = _strdup(plname);
                    argc = 3;
                }
            }
        }
        free(savefile);
    }
    resuming = pcmain(argc, argv);

    moveloop(resuming);

    return 0;
}
Esempio n. 4
0
void CSetBugTraqAdv::OnOK()
{
	UpdateData();

	if (m_sPath.IsEmpty() || !PathIsDirectory(m_sPath) || PathIsRelative(m_sPath))
	{
		ShowEditBalloon(IDC_BUGTRAQPATH, (LPCTSTR)CFormatMessageWrapper(ERROR_PATH_NOT_FOUND), CString(MAKEINTRESOURCE(IDS_ERR_ERROR)), TTI_ERROR);
		return;
	}

	m_provider_clsid = GUID_NULL;

	int index = m_cProviderCombo.GetCurSel();
	if (index != CB_ERR)
	{
		CBugTraqProvider *provider = (CBugTraqProvider *)m_cProviderCombo.GetItemDataPtr(index);
		m_provider_clsid = provider->clsid;
	}

	CComPtr<IBugTraqProvider> pProvider;
	HRESULT hr = pProvider.CoCreateInstance(m_provider_clsid);

	if (FAILED(hr))
	{
		m_tooltips.ShowBalloon(IDC_BUGTRAQPROVIDERCOMBO, IDS_ERR_MISSING_PROVIDER, IDS_ERR_ERROR, TTI_ERROR);
		return;
	}

	VARIANT_BOOL valid;
	ATL::CComBSTR parameters(m_sParameters);
	hr = pProvider->ValidateParameters(GetSafeHwnd(), parameters, &valid);
	if (FAILED(hr))
	{
		ShowEditBalloon(IDC_BUGTRAQPARAMETERS, IDS_ERR_PROVIDER_VALIDATE_FAILED, IDS_ERR_ERROR, TTI_ERROR);
		return;
	}

	if (valid != VARIANT_TRUE)
		return;	// It's assumed that the provider will have done this.

	CResizableStandAloneDialog::OnOK();
}
Esempio n. 5
0
static int OnInitDialog(HWND hDlg, LPARAM lParam)
{
    TFileTestData * pData;
    PROPSHEETPAGE * pPage = (PROPSHEETPAGE *)lParam;
    HWND hCombo = GetDlgItem(hDlg, IDC_CREATE_DISPOSITION);

    SetDialogData(hDlg, pPage->lParam);
    pData = (TFileTestData *)pPage->lParam;

    // Configure dialog resizing
    if(pData->bEnableResizing)
    {
        pAnchors = new TAnchors();
        pAnchors->AddAnchor(hDlg, IDC_MAIN_FRAME, akAll);
        pAnchors->AddAnchor(hDlg, IDC_DIRECTORY_NAME, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_DIRECTORY_NAME_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_FILE_NAME, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_FILE_NAME_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_OBJ_ATTR_FLAGS, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_OBJ_ATTR_FLAGS_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_DESIRED_ACCESS, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_DESIRED_ACCESS_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_ALLOCATION_SIZE, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_ALLOCATION_SIZE_UPDOWN, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_FILE_ATTRIBUTES, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_FILE_ATTRIBUTES_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_SHARE_ACCESS, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_SHARE_ACCESS_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_CREATE_DISPOSITION, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_CREATE_OPTIONS, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_CREATE_OPTIONS_BROWSE, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_EXTENDED_ATTRIBUTES, akLeft | akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_EXTENDED_ATTRIBUTES_EDIT, akTop | akRight);
        pAnchors->AddAnchor(hDlg, IDC_TRANSACTED, akLeft | akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_VIRTUALIZATION, akLeft | akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_BREAKPOINT, akLeft | akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_PRIVILEGES, akLeft | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_MAKE_DIRECTORY, akLeft | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_CREATE_FILE, akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_CLOSE_HANDLE, akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_RESULT_FRAME, akLeft | akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_RESULT_STATUS_TITLE, akLeft | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_RESULT_STATUS, akLeft | akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_HANDLE_TITLE, akLeft | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_HANDLE, akLeft | akRight | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_NTCREATE_RESULT_TITLE, akLeft | akBottom);
        pAnchors->AddAnchor(hDlg, IDC_NTCREATE_RESULT, akLeft | akRight | akBottom);
    }

    // Initialize the "Relative File" hyperlink
    InitURLButton(hDlg, IDC_RELATIVE_FILE_HELP, FALSE);

    // Initialize the combo box
    InitDialogControls(hDlg, MAKEINTRESOURCE(IDD_PAGE02_NTCREATE));
    if(hCombo != NULL)
        ComboBox_SetCurSel(hCombo, pData->dwCreateDisposition2);

    // If we have a tooltip window, init tooltips 
    g_Tooltip.AddToolTip(hDlg, IDC_OBJ_ATTR_FLAGS, ObjAttrFlagsValues);
    g_Tooltip.AddToolTip(hDlg, IDC_DESIRED_ACCESS, DesiredAccessValues);
    g_Tooltip.AddToolTip(hDlg, IDC_FILE_ATTRIBUTES, FileAttributesValues);
    g_Tooltip.AddToolTip(hDlg, IDC_SHARE_ACCESS, ShareAccessValues);
    g_Tooltip.AddToolTip(hDlg, IDC_CREATE_OPTIONS, CreateOptionsValues);

    // On pre-Vista, disable the virtualization button
    if(g_dwWinVer < 0x0600)
        EnableDlgItems(hDlg, FALSE, IDC_VIRTUALIZATION, 0);

    return TRUE;
}
Esempio n. 6
0
intptr_t CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
		{
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));

			if (IsWindowsSevenOrHigher())
				SendMessage(GetDlgItem(hDlg, IDC_CUSTOM_TREE), TVM_SETEXTENDEDSTYLE, TVS_EX_DOUBLEBUFFER, TVS_EX_DOUBLEBUFFER);

			SetWindowTheme(GetDlgItem(hDlg, IDC_CUSTOM_TREE), L"Explorer", NULL);

			TREEFOLDER **folders;
			int num_folders = 0;
			TVINSERTSTRUCT tvis;
			TVITEM tvi;
			bool first_entry = true;
			HIMAGELIST treeview_icons = GetTreeViewIconList();

			// current game passed in using DialogBoxParam()
			driver_index = lParam;
			(void)TreeView_SetImageList(GetDlgItem(hDlg, IDC_CUSTOM_TREE), treeview_icons, LVSIL_NORMAL);
			GetFolders(&folders, &num_folders);

			// insert custom folders into our tree view
			for (int i = 0; i < num_folders; i++)
			{
				if (folders[i]->m_dwFlags & F_CUSTOM)
				{
					HTREEITEM hti;

					if (folders[i]->m_nParent == -1)
					{
						memset(&tvi, 0, sizeof(TVITEM));
						tvis.hParent = TVI_ROOT;
						tvis.hInsertAfter = TVI_SORT;
						tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
						tvi.pszText = folders[i]->m_lptTitle;
						tvi.lParam = (LPARAM)folders[i];
						tvi.iImage = GetTreeViewIconIndex(folders[i]->m_nIconId);
						tvi.iSelectedImage = 0;
						tvis.item = tvi;

						hti = TreeView_InsertItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), &tvis);

						/* look for children of this custom folder */
						for (int jj = 0; jj < num_folders; jj++)
						{
							if (folders[jj]->m_nParent == i)
							{
								HTREEITEM hti_child;
								tvis.hParent = hti;
								tvis.hInsertAfter = TVI_SORT;
								tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
								tvi.pszText = folders[jj]->m_lptTitle;
								tvi.lParam = (LPARAM)folders[jj];
								tvi.iImage = GetTreeViewIconIndex(folders[jj]->m_nIconId);
								tvi.iSelectedImage = 0;
								tvis.item = tvi;

								hti_child = TreeView_InsertItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), &tvis);

								if (folders[jj] == default_selection)
									(void)TreeView_SelectItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), hti_child);
							}
						}

						/*TreeView_Expand(GetDlgItem(hDlg,IDC_CUSTOM_TREE),hti,TVE_EXPAND);*/
						if (first_entry || folders[i] == default_selection)
						{
							(void)TreeView_SelectItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE),hti);
							first_entry = false;
						}
					}
				}
			}

			winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_CUSTOMFILE_GAME), GetDriverGameTitle(driver_index));
			return true;
		}

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_COMMAND:
			switch (GET_WM_COMMAND_ID(wParam, lParam))
			{
				case IDOK:
				{
					TVITEM tvi;
					tvi.hItem = TreeView_GetSelection(GetDlgItem(hDlg, IDC_CUSTOM_TREE));
					tvi.mask = TVIF_PARAM;

					if (TreeView_GetItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE),&tvi) == true)
					{
						/* should look for New... */
						default_selection = (LPTREEFOLDER)tvi.lParam; 	/* start here next time */
						AddToCustomFolder((LPTREEFOLDER)tvi.lParam, driver_index);
					}

					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;
				}

				case IDCANCEL:
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;
			}

			break;
	}

	return false;
}
Esempio n. 7
0
void CMobileOpalDlg::OnCancel()
{
  CString msg(MAKEINTRESOURCE(IDS_ASK_EXIT));
  if (MessageBox(msg, NULL, MB_YESNO|MB_ICONQUESTION) == IDYES)
    OnExit();
}
Esempio n. 8
0
/////////////////////////////////////////////////////////////////////////////
// ULONG CS3Dialog::Display
//
/////////////////////////////////////////////////////////////////////////////
INT_PTR CS3Dialog::Display()
{
    //Create a modal dialog box
    return DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_TO_INFO), NULL, (DLGPROC)DlgProc, (LPARAM)this);
}
Esempio n. 9
0
#include "menu.h"
#include "np2class.h"
#include "dialog.h"
#include "dialogs.h"
#include "pccore.h"
#include "iocore.h"
#include "sound.h"
#include "fmboard.h"
#include "s98.h"
#include "tms3631.h"
#include "dipswbmp.h"
#include "recvideo.h"

static const CBPARAM cpIO26[] =
{
	{MAKEINTRESOURCE(IDS_0088),		0x00},
	{MAKEINTRESOURCE(IDS_0188),		0x10},
};

static const CBPARAM cpIO86[] =
{
	{MAKEINTRESOURCE(IDS_0188),		0x01},
	{MAKEINTRESOURCE(IDS_0288),		0x00},
};

static const CBPARAM cpInt26[] =
{
	{MAKEINTRESOURCE(IDS_INT0),		0x00},
	{MAKEINTRESOURCE(IDS_INT41),	0x80},
	{MAKEINTRESOURCE(IDS_INT5),		0xc0},
	{MAKEINTRESOURCE(IDS_INT6),		0x40},
Esempio n. 10
0
bool BaseManager::create()
{
    Ogre::String pluginsPath;

#ifndef OGRE_STATIC_LIB
    pluginsPath = mResourcePath + mPluginCfgName;
#endif

    mRoot = new Ogre::Root(pluginsPath, mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");

    setupResources();

    // попробуем завестись на дефолтных
    if (!mRoot->restoreConfig())
    {
        // ничего не получилось, покажем диалог
        if (!mRoot->showConfigDialog()) return false;
    }

    mWindow = mRoot->initialise(true);


#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
    // вытаскиваем дискриптор окна
    size_t hWnd = 0;
    mWindow->getCustomAttribute("WINDOW", &hWnd);
    // берем имя нашего экзешника
    char buf[MAX_PATH];
    ::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
    // берем инстанс нашего модуля
    HINSTANCE instance = ::GetModuleHandleA(buf);
    // побыстрому грузим иконку
    HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
    if (hIcon)
    {
        ::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
        ::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
    }
#endif

    mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "BaseSceneManager");

    mCamera = mSceneManager->createCamera("BaseCamera");
    mCamera->setNearClipDistance(5);
    mCamera->setPosition(400, 400, 400);
    mCamera->lookAt(0, 150, 0);

    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio((float)vp->getActualWidth() / (float)vp->getActualHeight());

    // Set default mipmap level (NB some APIs ignore this)
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

    mSceneManager->setAmbientLight(Ogre::ColourValue::White);
    Ogre::Light* light = mSceneManager->createLight("MainLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    Ogre::Vector3 vec(-0.3, -0.3, -0.3);
    vec.normalise();
    light->setDirection(vec);

    // Load resources
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    mRoot->addFrameListener(this);
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

    size_t handle = 0;
    mWindow->getCustomAttribute("WINDOW", &handle);

    createGui();

    createInput(handle);

    createPointerManager(handle);

    createScene();

    windowResized(mWindow);

    return true;
}
Esempio n. 11
0
/******************************************************************************
 * FontEditCommand(hBox, id)
 *
 * purpose: interprets menu id and calls appropriate function to do the task
 *
 * params:  HWND hBox : handle to main window
 *          WORD id   : menu command id
 * returns: none
 *
 * side effects: plenty
 *
 *****************************************************************************/
VOID
FontEditCommand(
	HWND hBox,
	WORD id
	)
{
	CHAR * szError;                 /* String for error messages */
	LONG w; 
	DWORD y, i, j;
	BOOL fRepaint = FALSE;
	HMENU hMenu;
	DLGPROC lpprocAboutDlg;
	MSG message;

	szError = "";               /* No Errors yet */

	switch (id) {
	    case FONT_EXIT:
		if (!CheckSave())    /* See if any files need saving */
			break;
		/* Window's being destroyed. */
		if (fLoaded)         /* 4/8/87 Linsh added */
			DeleteBitmap(); /* Get rid of memory DC */
		PostQuitMessage(0);  /* Cause application to be terminated */
                break;

            case FONT_HELP_CONTENTS:
                WinHelp(hFont, gszHelpFile, HELP_CONTENTS, 0L);
                break;

            case FONT_HELP_SEARCH:
                /*
                 * Tell winhelp to be sure this app's help file is current,
                 * then invoke a search with an empty starting key.
                 */
                WinHelp(hFont, gszHelpFile, HELP_FORCEFILE, 0);
                WinHelp(hFont, gszHelpFile, HELP_PARTIALKEY, (DWORD)(LPSTR)"");
                break;

	    case FONT_ABOUT:
		lpprocAboutDlg = (DLGPROC)AboutDlg;
		DialogBox (hInst, vszABOUT, hBox, lpprocAboutDlg);
		FreeProcInstance (lpprocAboutDlg);
		break;

	    case FONT_LOAD:             /*  Check File Name  */
	    case FONT_NEW :
		if (!CheckSave())       /*  See if current font needs saving */
			return;
	/* to prevent scrambling of Show window chars, Bring back Show
        ** window to parent window's client area before invoking the dialog */

		if (CommDlgOpen(hBox,&ofstrFile,szNewFile,szExt,szFontFile,id)
				== FALSE) {

			InvalidateRect(hFont, (LPRECT)NULL, FALSE);
			UpdateWindow(hFont);
			return;
		}
		/* else drop thru */

	    case FONT_START:	/*  Here if file name passed as argument */
		InvalidateRect(hFont, (LPRECT)NULL, FALSE);
		UpdateWindow(hFont);

		szError = FontLoad (szNewFile, &ofstrFile);

	/* Hack : needed to remove umwanted WM_MOUSEMOVE messages from the 
         * queue.
         * Apparently, Windows needs to reposition the mouse after a dialog
         * is ended with a mouse double-click (releases mouse capture?) for
         * which a couple of WM_MOUSEMOVEs may get sent to parent app.
         * These mess with the edit box below the dialog if they happen to 
         * overlap.
         */
		PeekMessage((LPMSG) &message, hBox, WM_MOUSEMOVE, WM_MOUSEMOVE,
		    PM_REMOVE);

		if (fLoaded)    /* If loaded then do a few things */ {
		    jChar = iChar = 65;                 /* Show an A */
		    if ((BYTE)iChar > (BYTE)font.LastChar)
			jChar = iChar = font.FirstChar; /* .. if we can */
		    swH = 15;                   /* Good bet to make A visible */
		    fEdited = fChanged = FALSE;
		    ResizeShow();               /* Set Box to proper size */
		    ScrollFont();               /* Set thumb */
		    CharToBox(iChar);
		}
		FontRename(szError);
		SetFocus(hBox);
		return;

	    case FONT_SAVE:
		if (!NewFile) {
		    if (fLoaded && fChanged) {
			lstrcpy((LPSTR)szNewFile, (LPSTR)szFontFileFull);
			BoxToChar(iChar);           /* Just in case */
			szError = FontSave (szNewFile, &ofstrFile);
			FontRename(szError);        /* Rename or Print Error */
			return;
		    }
		    else
			return;
		}
	/* else file has been opened by selecting NEW... on menu.
         * Fall thro' and bring up SaveAs dialog minus default
         * filename in edit window */

	    case FONT_SAVEAS:
		BoxToChar(iChar);               /* Just in case */

		if (CommDlgSaveAs (hInst, hBox, &ofstrFile, szNewFile, szExt,
				szFontFile) == TRUE) {

		    szError = FontSave (szNewFile, &ofstrFile);
		    FontRename (szError);          /* Rename or Print Error */
		}

		/* to prevent scrambling of Show window chars,
           repaint show window after dialog is brought down */
		InvalidateRect (hFont, (LPRECT)NULL, TRUE);
		UpdateWindow (hFont);
		return;

	    case FONT_HEADER:
		/* to prevent scrambling of Show window chars,
		 * repaint show window after dialog is invoked */
		DialogBox(hInst, (LPSTR)vszDHeader, hBox, lpHeaderProc);
		InvalidateRect(hFont, (LPRECT)NULL, TRUE);
		UpdateWindow(hFont);
		return;

	    case FONT_RESIZE:
		/* to prevent scrambling of Show window chars,
		   repaint show window after dialog is brought down */
		if (DialogBox(hInst, (LPSTR)vszDResize, hBox, lpReSizeProc)) {
		    /* BoxToChar(iChar);*/ /* save current before resizing */
		    ResizeShow();       /* New Font Display Size */
		    CharToBox(iChar);               /* New Box display */
		}
		InvalidateRect(hFont, (LPRECT)NULL, TRUE);
		UpdateWindow(hFont);
		return;

	    case FONT_COPY:                     /* Copy to Clipboard */
		BoxToChar(iChar);               /* Just in case */
		ToClipboard(iChar, wBox, kBox);
		break;

	    case FONT_PASTE:            /* Paste in Character form Clipboard */
		BoxBackup();            /* In case we change our minds */
		ptA.x = ptA.y = 0;
		wBox = ClipboardToBox(ptA, wBox, kBox, TRUE);
		fRepaint = TRUE;
		break;

	    case WIDER_LEFT:
	    case WIDER_RIGHT:
	    case WIDER_BOTH:
	    case NARROWER_LEFT:
	    case NARROWER_RIGHT:
	    case NARROWER_BOTH:
	    case WIDTH:
		w = newWidth = wBox;
		if (font.Family & 1)            /* Variable width or else */ {
		    switch (id) {
			case WIDER_BOTH:
			    w++;
			case WIDER_LEFT:
			case WIDER_RIGHT:
			    w++;
			    break;
			case NARROWER_BOTH:
			    w--;
			case NARROWER_LEFT:
			case NARROWER_RIGHT:
			    w--;
			    break;
			case WIDTH:
			    if (DialogBox(hInst,
					(LPSTR)vszDWidth, hBox, lpWidthProc))
				w = newWidth;
			    break;
		    }

		    if (w < 0 || w >= wBoxLim) {
			MessageBox(hBox,
				(LPSTR)vszEdLimits0To64,
				(LPSTR)szAppName,
				MB_OK | MB_ICONASTERISK);
			break;                  /* Out of range! quit */
		    }
		    if (w > (LONG) font.MaxWidth) {
			if (IDOK == MessageBox(hBox,
					    (LPSTR)vszMaxWidthIncrease,
					    (LPSTR)szAppName,
					    MB_OKCANCEL | MB_ICONQUESTION))
			    font.MaxWidth = (WORD)w;
			else
			    break;
		    }
		    BoxBackup();                /* In case we change our minds */
		    wBox = (WORD)w;             /* Reset width */
		    fRepaint = TRUE;            /* Signal redraw */
		    switch (id) {
		    case WIDER_LEFT:
#ifdef DBCS	//DBCS_FIX
			DupCol(0, kBoxLim - 1);
			for (y = 0; y < kBoxLim; y++)
			    matBox[0][y] = FALSE;       /* Clear left column */
			break;
#endif
		    case WIDER_BOTH:            /* Shift character one right */
			DupCol(0, kBoxLim - 1);
			for (y = 0; y < kBoxLim; y++)
			    matBox[wBox -1][y] = FALSE; /* Clear right column */
			for (y = 0; y < kBoxLim; y++)
			    matBox[0][y] = FALSE;       /* Clear left column */
			break;
		    case NARROWER_LEFT:
		    case NARROWER_BOTH:	/* Shift character one left */
			if (wBox) {	/* .. unless width is already 0 */
			    for (j = 0; j <= kBox - 1; j++)
				for (i = 0; i <= wBox - 1; i++)
				    matBox[i][j] = matBox[i + 1][j];
			    break;
			}
		    }
		}
		else {
		    MessageBox(hBox,
			    (LPSTR)vszCannotChangeWidth,
			    (LPSTR)szAppName,
			    MB_OK | MB_ICONASTERISK);
		}
		break;

	    case ROW_ADD:
	    case ROW_DEL:
	    case COL_ADD:
	    case COL_DEL:
		/* set cursor to "+" shaped cursor */
		SetCapture (hBox); /* so that cursor doesn't get restored
				      before we are done */
		hOldCursor = SetCursor (LoadCursor (NULL, IDC_CROSS));
		fCaptured = TRUE;
		cursor = id;
		break;

	    case BOX_CLEAR:
	    case BOX_FILL:
	    case BOX_INV:
	    case BOX_HATCH:
	    case BOX_LEFTRIGHT:
	    case BOX_TOPBOTTOM:
	    case BOX_COPY:
	    case BOX_PASTE:
		/* Get one o' da funky cursors */
		SetCapture(hBox);
		hOldCursor = SetCursor(LoadCursor(hInst, MAKEINTRESOURCE(id)));
		fStartRubberBand = TRUE;
		CharRectDimensions((LPRECT)&FontRect);
		cursor = id;
		break;

	    case BOX_REFRESH:           /* Go get old version of character */
		BoxBackup();            /* In case we change our minds */
		CharToBox(iChar);
		hMenu = GetMenu(hBox);
		EnableMenuItem(hMenu, BOX_UNDO, MF_ENABLED);    /* Can Unrefresh! */
		break;
	    case BOX_UNDO:
		BoxRestore();
		hMenu = GetMenu(hBox);
		EnableMenuItem(hMenu, BOX_REFRESH, MF_ENABLED);
		fRepaint = TRUE;
		break;
	}
	if (fRepaint) {
		fEdited = fChanged = TRUE;
		InvalidateRect(hBox, (LPRECT)NULL, TRUE);
	}
}
Esempio n. 12
0
// Handle message for the hidden dialog
// Show text on main dialog
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR text1[] = _T("mMouse v0.2d");
	TCHAR text2[] = _T("Touchpad fix for windows 10 Asus laptop, which");
	TCHAR text3[] = _T("ASUS not-so-Smart gesture epically fails for advanced");
	TCHAR text4[] =	_T("user like yourself.");
	TCHAR text5[] = _T("How does it work?");
	TCHAR text6[] = _T("This app will intercept messages that generated by");
	TCHAR text7[] = _T("ASUS not-so-Smart gesture and then send the Middle");
	TCHAR text8[] = _T("mouse button or Backward / Forward button instead");
	TCHAR text0[] = _T("ceezblog.info - 2016");

	TCHAR texta[] = _T("ASUS not-so-Smart gesture");
	TCHAR textb[] = _T("not-so");

	switch (message)
	{
	case WM_KEYDOWN: // same effect as OK = default button
		if (wParam == VK_RETURN || wParam == VK_ESCAPE)
			ShowWindow(hHiddenDialog, SW_HIDE);
		break;

	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		HICON hIcon;

		hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
		DrawIcon(hdc, 10, 5, hIcon);

		SetTextColor(hdc, RGB(30,160,10)); //green-ish
		TextOut(hdc, 50, 15, text1, _tcslen(text1));
		SetTextColor(hdc, RGB(10,20,130)); //blue-ish
		TextOut(hdc, 10, 110, text5, _tcslen(text5));
		SetTextColor(hdc, RGB(10,10,10)); //black-ish
		TextOut(hdc, 10, 45, text2, _tcslen(text2));
		TextOut(hdc, 10, 65, text3, _tcslen(text3));
		TextOut(hdc, 10, 85, text4, _tcslen(text4));
		TextOut(hdc, 10, 130, text6, _tcslen(text6));
		TextOut(hdc, 10, 150, text7, _tcslen(text7));
		TextOut(hdc, 10, 170, text8, _tcslen(text8));
		TextOut(hdc, 220, 195, text0, _tcslen(text0));		
		SetTextColor(hdc, RGB(180,80,80)); //red-ish
		TextOut(hdc, 10, 65, texta, _tcslen(texta));
		TextOut(hdc, 10, 150, texta, _tcslen(texta));
		SetTextColor(hdc, RGB(140,140,140)); //gray-ish
		TextOut(hdc, 50, 65, textb, _tcslen(textb));
		TextOut(hdc, 50, 150, textb, _tcslen(textb));

		EndPaint(hWnd, &ps);
		break;

	case SWM_TRAYMSG:
		switch(lParam)
		{
		case WM_LBUTTONDBLCLK:
			ShowWindow(hHiddenDialog, SW_SHOW);
			break;
		case WM_RBUTTONDOWN:
		case WM_CONTEXTMENU:
			ShowContextMenu(hWnd);
			break;
		}
		break;
	
	case WM_CLOSE:
		ShowWindow(hHiddenDialog, SW_HIDE);
		break;

	case WM_DESTROY:
		UnhookWindowsHookEx(kbhHook);
		UnhookWindowsHookEx(mousehHook);
		PostQuitMessage(0);
		break;
		
	case WM_TIMER:
		timerTick();
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case SM_DESTROY:
			niData.uFlags = 0;
			Shell_NotifyIcon(NIM_DELETE,&niData);
			PostQuitMessage(0);
			break;
		case SM_THREEMOUSE_TAP:
			ThreeFingerTap = !ThreeFingerTap;
			if (ThreeFingerTap) 
			{ 
				mousehHook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)MouseHookProc, hInst, NULL); 
			}
			else { UnhookWindowsHookEx(mousehHook); }
			break;
		case SM_THREEMOUSE_SWIPE:
			ThreeFingerSwipe = !ThreeFingerSwipe;
			break;
		case SM_THREEMOUSE_SWIPE_UP:
			ThreeFingerSwipeUp = !ThreeFingerSwipeUp;
			break;
		case SM_ABOUTAPP:
			ShowWindow(hHiddenDialog, SW_SHOW);
			break;
		case SM_CLOSE:
			ShowWindow(hHiddenDialog, SW_HIDE);
			break;
		}

	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	return 0;
}
Esempio n. 13
0
// Start point of the program
// Start keyboard hook, init config dialog and notification icon
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style          = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc    = WndProc;
	wcex.cbClsExtra     = 0;
	wcex.cbWndExtra     = 0;
	wcex.hInstance      = hInstance;
	wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
	wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName   = NULL;
	wcex.lpszClassName  = szWindowClass;
	wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

	if (!RegisterClassEx(&wcex)) return 1;

	hInst = hInstance; // Store instance handle in our global variable
	
	// a dummy hidden dialog to receive the message
	hHiddenDialog = CreateWindow(szWindowClass,	szTitle, WS_TILED|WS_CAPTION|WS_THICKFRAME| WS_MINIMIZEBOX , CW_USEDEFAULT, CW_USEDEFAULT,390, 310, NULL,NULL,hInstance,NULL);
	
	if (!hHiddenDialog)	return 1;

	// add button OK
	HMENU OKButtonID = reinterpret_cast<HMENU>(static_cast<DWORD_PTR>(SM_CLOSE));
	HWND hButton = CreateWindowExW(0, L"Button", L"OK", WS_TABSTOP | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_DEFPUSHBUTTON, 140, 228, 100, 25, hHiddenDialog, OKButtonID, hInst, nullptr);
	SetWindowLongPtr(hButton, GWLP_ID, static_cast<LONG_PTR>(static_cast<DWORD_PTR>(SM_CLOSE)));
		
	// setup the icon
	ZeroMemory(&niData,sizeof(NOTIFYICONDATA));
	niData.cbSize = sizeof(NOTIFYICONDATA);
	niData.uID = TRAY_ICON_ID;
	niData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;

	// load the icon
	niData.hIcon = (HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON1),
		IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),
		LR_DEFAULTCOLOR);

	niData.hWnd = hHiddenDialog;
	niData.uCallbackMessage = SWM_TRAYMSG;

	// tooltip message
	copyString(niData.szTip, szTip);
	Shell_NotifyIcon(NIM_ADD,&niData);

	// free icon handle
	if (niData.hIcon && DestroyIcon(niData.hIcon)) niData.hIcon = NULL;
	
	// setup keyboard hook
	kbhHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC) KBHookProc, hInst, NULL);  

	// setup mouse hook
	if (ThreeFingerTap) {mousehHook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)MouseHookProc, hInst, NULL); }

	// Reposition the window
	int ScreenX=0;
	int ScreenY=0;
	int WinX=0;
	int WinY=0;
	RECT wnd;
	GetWindowRect(hHiddenDialog, &wnd);
	WinX = wnd.right - wnd.left;
	WinY = wnd.bottom - wnd.top;
	ScreenX = GetSystemMetrics(SM_CXSCREEN);
	ScreenY = GetSystemMetrics(SM_CYSCREEN);
	ScreenX = (ScreenX / 2) - ((int)WinX / 2);
	ScreenY = (ScreenY / 2) - ((int)WinY / 2);
	SetWindowPos(hHiddenDialog,HWND_TOP, ScreenX, ScreenY, (int)WinX,(int)WinY,NULL);
		
	// Main message loop:
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int) msg.wParam; // program end here
}
Esempio n. 14
0
//
//  関数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的:  メイン ウィンドウのメッセージを処理します。
//
//  WM_COMMAND	- アプリケーション メニューの処理
//  WM_PAINT	- メイン ウィンドウの描画
//  WM_DESTROY	- 中止メッセージを表示して戻る
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	int id;
	static MCI_OPEN_PARMS op;
	//MCI_OPRNコマンドのパラメータ
	MCI_STATUS_PARMS sp;
	//MCI_STATUSコマンドのパラメータ
	static HWND hPlay, hStop;
	static BOOL bPlay = FALSE;
	MCIERROR err;
	TCHAR szErr[1024];

	switch (message)
	{
	case WM_CREATE:
		// CDオーディオデバイスをオープン
		op.lpstrDeviceType = TEXT("cdaudio");
		err = mciSendCommand(NULL,	//デバイス識別子, MCI_OPENコマンドを送るときはNULL
			MCI_OPEN,	//コマンド
			MCI_OPEN_TYPE | MCI_WAIT,	//フラグ
			(DWORD_PTR)&op);	//パラメータを保持している構造体

		//エラー処理
		if (err != 0) {
			mciGetErrorString(err, szErr, (UINT)sizeof(szErr));	//エラーの内容,err:エラーコード,szErr:エラー文字列のバッファ
			MessageBox(hWnd, szErr, TEXT("エラー"), MB_OK);
			break;
		}

		hPlay = CreateWindow(TEXT("BUTTON"),	//PLAYボタンを子ウインドウとして作る
			TEXT("PLAY"), WS_CHILD | WS_VISIBLE,
			10, 10, 100, 30, hWnd, (HMENU)ID_PLAY, hInst, NULL);
		hStop = CreateWindow(TEXT("BUTTON"),	//STOPボタンを子ウインドウとして作る
			TEXT("STOP"), WS_CHILD | WS_VISIBLE,
			10, 50, 100, 30, hWnd, (HMENU)ID_STOP, hInst, NULL);
		EnableWindow(hStop, FALSE);
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 選択されたメニューの解析:
		switch (wmId)
		{
		case ID_PLAY:	//PLAYボタンの処理
			//CDの有無をチェック
			sp.dwItem = MCI_STATUS_MEDIA_PRESENT;
			err = mciSendCommand(op.wDeviceID,
				MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT,
				(DWORD_PTR)&sp);

			if (err != 0){
			mciGetErrorString(err, szErr, (UINT)sizeof(szErr));
			MessageBox(hWnd, szErr, TEXT("エラー"), MB_OK);
			break;
			}

			if (!sp.dwReturn) {
			MessageBox(hWnd, TEXT("CDがセットされていません"), TEXT("エラー"), MB_OK);
			break;
			}

			//CDを再生
			err = mciSendCommand(op.wDeviceID, MCI_PLAY, 0, 0);
			if (err != 0){
			mciGetErrorString(err, szErr, (UINT)sizeof(szErr));
			MessageBox(hWnd, szErr, TEXT("エラー"), MB_OK);
			break;
			}

			EnableWindow(hPlay, FALSE);
			EnableWindow(hStop, TRUE);
			bPlay = TRUE;
			break;
		case ID_STOP:	//STOPボタンの処理
			//CDの再生を中止
			err = mciSendCommand(op.wDeviceID, MCI_STOP, 0, 0);
			if (err != 0){
			mciGetErrorString(err, szErr, (UINT)sizeof(szErr));
			MessageBox(hWnd, szErr, TEXT("エラー"), MB_OK);
			break;
			}
			EnableWindow(hPlay, TRUE);
			EnableWindow(hStop, FALSE);
			bPlay = FALSE;
			break;
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;

	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 描画コードをここに追加してください...
		EndPaint(hWnd, &ps);
		break;
	case WM_CLOSE:
		id = MessageBox(hWnd, TEXT("終了してよろしいですか"),
			TEXT("終了確認"), MB_YESNO);
		if (id == IDYES) {
			if (bPlay) {
				//再生中であれば再生を中止
				mciSendCommand(op.wDeviceID, MCI_STOP, 0, 0);
			}
			//デバイスをクローズ
			mciSendCommand(op.wDeviceID, MCI_CLOSE, 0, 0);

			//リソースを開放
			DestroyWindow(hPlay);
			DestroyWindow(hStop);
			DestroyWindow(hWnd);
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Esempio n. 15
0
intptr_t CALLBACK InterfaceDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

	switch (uMsg)
	{
		case WM_INITDIALOG:
		{
			char buffer[200];
			int value = 0;
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));
			DisableVisualStylesInterface(hDlg);
			Button_SetCheck(GetDlgItem(hDlg, IDC_JOY_GUI), GetJoyGUI());
			Button_SetCheck(GetDlgItem(hDlg, IDC_DISABLE_TRAY_ICON), GetMinimizeTrayIcon());
			Button_SetCheck(GetDlgItem(hDlg, IDC_DISPLAY_NO_ROMS), GetDisplayNoRomsGames());
			Button_SetCheck(GetDlgItem(hDlg, IDC_EXIT_DIALOG), GetExitDialog());
			Button_SetCheck(GetDlgItem(hDlg, IDC_USE_BROKEN_ICON), GetUseBrokenIcon());
			Button_SetCheck(GetDlgItem(hDlg, IDC_STRETCH_SCREENSHOT_LARGER), GetStretchScreenShotLarger());
			Button_SetCheck(GetDlgItem(hDlg, IDC_FILTER_INHERIT), GetFilterInherit());
			Button_SetCheck(GetDlgItem(hDlg, IDC_ENABLE_FASTAUDIT), GetEnableFastAudit());
			Button_SetCheck(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP), GetEnableSevenZip());
			// Get the current value of the control
			SendMessage(GetDlgItem(hDlg, IDC_CYCLETIMESEC), TBM_SETRANGE, true, MAKELPARAM(0, 60)); /* [0, 60] */
			SendMessage(GetDlgItem(hDlg, IDC_CYCLETIMESEC), TBM_SETTICFREQ, 5, 0);
			value = GetCycleScreenshot();
			SendMessage(GetDlgItem(hDlg, IDC_CYCLETIMESEC), TBM_SETPOS, true, value);
			snprintf(buffer, WINUI_ARRAY_LENGTH(buffer), "%d", value);		
			winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_CYCLETIMESECTXT), buffer);

			for (int i = 0; i < NUMHISTORYTAB; i++)
			{
				(void)ComboBox_InsertString(GetDlgItem(hDlg, IDC_HISTORY_TAB), i, g_ComboBoxHistoryTab[i].m_pText);
				(void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), i, g_ComboBoxHistoryTab[i].m_pData);
			}

			if (GetHistoryTab() < MAX_TAB_TYPES) 
				(void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB), GetHistoryTab());
			else 
				(void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB), GetHistoryTab() - TAB_SUBTRACT);

			SendMessage(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZE), TBM_SETRANGE, true, MAKELPARAM(0, 50)); /* [0, 50] */
			SendMessage(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZE), TBM_SETTICFREQ, 5, 0);
			value = GetScreenshotBorderSize();
			SendMessage(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZE), TBM_SETPOS, true, value);
			snprintf(buffer, WINUI_ARRAY_LENGTH(buffer), "%d", value);		
			winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZETXT), buffer);
			EnableWindow(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP), GetEnableFastAudit() ? true : false);
			break;
		}

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_HSCROLL:
			HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OnHScroll);
			break;

		case WM_COMMAND:
			switch (GET_WM_COMMAND_ID(wParam, lParam))
			{
				case IDC_SCREENSHOT_BORDERCOLOR:
				{
					CHOOSECOLOR cc;
					COLORREF choice_colors[16];			

					for (int i = 0; i < 16; i++)
						choice_colors[i] = GetCustomColor(i);

					cc.lStructSize = sizeof(CHOOSECOLOR);
					cc.hwndOwner = hDlg;
					cc.lpfnHook = &CCHookProc;
					cc.rgbResult = GetScreenshotBorderColor();
					cc.lpCustColors = choice_colors;
					cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK;

					if (!ChooseColor(&cc))
						return true;

					for (int i = 0; i < 16; i++)
						SetCustomColor(i,choice_colors[i]);

					SetScreenshotBorderColor(cc.rgbResult);
					UpdateScreenShot();
					return true;
				}

				case IDC_ENABLE_FASTAUDIT:
				{
					bool enabled = Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_FASTAUDIT));
					EnableWindow(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP), enabled ? true : false);
					return true;
				}

				case IDOK:
				{
					bool bRedrawList = false;
					bool checked = false;
					int value = 0;

					SetJoyGUI(Button_GetCheck(GetDlgItem(hDlg, IDC_JOY_GUI)));
					SetMinimizeTrayIcon(Button_GetCheck(GetDlgItem(hDlg, IDC_DISABLE_TRAY_ICON)));
					SetExitDialog(Button_GetCheck(GetDlgItem(hDlg, IDC_EXIT_DIALOG)));
					SetEnableFastAudit(Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_FASTAUDIT)));
					SetEnableSevenZip(Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP)));

					if (Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_PLAYCOUNT)))
					{
						for (int i = 0; i < driver_list::total(); i++)
							ResetPlayCount(i);

						bRedrawList = true;
					}

					if (Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_PLAYTIME)))
					{
						for (int i = 0; i < driver_list::total(); i++)
							ResetPlayTime(i);

						bRedrawList = true;
					}

					value = SendDlgItemMessage(hDlg, IDC_CYCLETIMESEC, TBM_GETPOS, 0, 0);

					if (GetCycleScreenshot() != value)
						SetCycleScreenshot(value);

					value = SendDlgItemMessage(hDlg, IDC_SCREENSHOT_BORDERSIZE, TBM_GETPOS, 0, 0);

					if (GetScreenshotBorderSize() != value)
					{
						SetScreenshotBorderSize(value);
						UpdateScreenShot();
					}

					checked = Button_GetCheck(GetDlgItem(hDlg, IDC_STRETCH_SCREENSHOT_LARGER));

					if (checked != GetStretchScreenShotLarger())
					{
						SetStretchScreenShotLarger(checked);
						UpdateScreenShot();
					}

					checked = Button_GetCheck(GetDlgItem(hDlg, IDC_FILTER_INHERIT));

					if (checked != GetFilterInherit())
					{
						SetFilterInherit(checked);
						bRedrawList = true;
					}

					checked = Button_GetCheck(GetDlgItem(hDlg, IDC_USE_BROKEN_ICON));

					if (checked != GetUseBrokenIcon())
					{
						SetUseBrokenIcon(checked);
						bRedrawList = true;
					}

					checked = Button_GetCheck(GetDlgItem(hDlg, IDC_DISPLAY_NO_ROMS));

					if (checked != GetDisplayNoRomsGames())
					{
						SetDisplayNoRomsGames(checked);
						bRedrawList = true;
					}

					int nCurSelection = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB));
					int nHistoryTab = 0;

					if (nCurSelection != CB_ERR)
						nHistoryTab = ComboBox_GetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nCurSelection);

					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);

					if(GetHistoryTab() != nHistoryTab)
					{
						SetHistoryTab(nHistoryTab, true);
						ResizePickerControls(GetMainWindow());
						UpdateScreenShot();
					}

					if(bRedrawList)
						UpdateListView();

					SaveInternalUI();
					return true;
				}

				case IDCANCEL:
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;
			}

			break;
	}

	return false;
}
Esempio n. 16
0
//
//  FUNCIÓN: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PROPÓSITO: procesar mensajes de la ventana principal.
//
//  WM_COMMAND	: procesar el menú de aplicación
//  WM_PAINT	: pintar la ventana principal
//  WM_DESTROY	: enviar un mensaje de finalización y volver
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Analizar las selecciones de menú:
		switch (wmId)
		{
		case IDM_BLIST:
				serverManager.ReadBlackList(BLISTFILE);
			break;
		case IDM_SLIST:
				serverManager.ReadList(SLISTFILE);
			break;
		case IDM_ULIST:
				serverManager.ReadUpdateConfig();
			break;

		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
		case WM_TIMER:
			switch ( wParam )
			{
				case WM_LOG_PAINT:
					{
						RECT rect;
						HDC hdc = GetDC(hWnd);
						GetClientRect(hWnd, &rect);
						FillRect(hdc, &rect, (HBRUSH)GetStockObject(0));
						ReleaseDC(hWnd, hdc);

						if ( LogTextPaint != NULL )
							LogTextPaint(hWnd);

						//g_ServerInfoDisplayer.Run(hWnd);
					}
					break;
				case WM_LOG_DATE_CHANGE:
					LogDateChange();
					break;
				case WM_SECONDPROC:
				{
					OBJSecondProc();
				}break;
			}
		break;
	//case WM_PAINT:
	//	hdc = BeginPaint(hWnd, &ps);
	//	// TODO: agregar código de dibujo aquí...
	//	EndPaint(hWnd, &ps);
	//	break;
	case WM_DESTROY:
		DestroyIocp();
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Esempio n. 17
0
intptr_t CALLBACK FilterDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
		{
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));
			DisableVisualStylesFilters(hDlg);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPTREEFOLDER lpParent = NULL;
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();
			dwFilters = 0;

			if (folder != NULL)
			{
				char tmp[80];
				winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText);
				Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
				// Mask out non filter flags
				dwFilters = folder->m_dwFlags & F_MASK;
				// Display current folder name in dialog titlebar
				snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle);
				winui_set_window_text_utf8(hDlg, tmp);

				if (GetFilterInherit())
				{
					lpParent = GetFolder(folder->m_nParent);
					bool bShowExplanation = false;

					if (lpParent)
					{
						char strText[24];
						/* Check the Parent Filters and inherit them on child,
						* No need to promote all games to parent folder, works as is */
						dwpFilters = lpParent->m_dwFlags & F_MASK;
						/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/

						if ((dwpFilters & F_CLONES) && !(dwFilters & F_CLONES))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_RASTER) && !(dwFilters & F_RASTER))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_WORKING) && !(dwFilters & F_WORKING))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText);
							bShowExplanation = true;
						}

						if ((dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText, 20);
							strcat(strText, " (*)");
							winui_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText);
							bShowExplanation = true;
						}
						/*Do not or in the Values of the parent, so that the values of the folder still can be set*/
						//dwFilters |= dwpFilters;
					}

					if(bShowExplanation)
					{
						ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), true);
					}
				}
				else
				{
					ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false);
				}

				// Find the matching filter record if it exists
				lpFilterRecord = FindFilter(folder->m_nFolderId);

				// initialize and disable appropriate controls
				for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
				{
					DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters);
				}
			}

			SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT));
			return false;
		}

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_COMMAND:
		{
			WORD wID = GET_WM_COMMAND_ID(wParam, lParam);
			WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();

			switch (wID)
			{
				case IDOK:
					dwFilters = 0;
					winui_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText, FILTERTEXT_LEN);

					// see which buttons are checked
					for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
					{
						if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID)))
							dwFilters |= g_lpFilterList[i].m_dwFilterType;
					}

					// Mask out invalid filters
					dwFilters = ValidateFilters(lpFilterRecord, dwFilters);
					// Keep non filter flags
					folder->m_dwFlags &= ~F_MASK;
					// put in the set filters
					folder->m_dwFlags |= dwFilters;
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 1);
					return true;

				case IDCANCEL:
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;

				default:
					// Handle unchecking mutually exclusive filters
					if (wNotifyCode == BN_CLICKED)
						EnableFilterExclusions(hDlg, wID);
			}

			break;
		}
	}

	return false;
}
Esempio n. 18
0
//----------------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR acArgument, int)
{
    FWinApplication* pkTheApp = FWinApplication::GetApplication();
    assert( pkTheApp );
    if ( !pkTheApp )
        return -1;

    gs_hInstance = hInstance;

    if ( acArgument && strlen(acArgument) > 0 )
    {
        char* acProcessed = ProcessArgument(acArgument);
        pkTheApp->SetCommand(new Command(acProcessed));
        delete[] acProcessed;
    }

    if ( !pkTheApp->OnPrecreate() )
        return -2;

    // register the window class
    WNDCLASS kWC;
    kWC.style         = CS_HREDRAW | CS_VREDRAW;
    kWC.lpfnWndProc   = WinProc;
    kWC.cbClsExtra    = 0;
    kWC.cbWndExtra    = 0;
    kWC.hInstance     = hInstance;
    kWC.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
    kWC.hCursor       = LoadCursor(NULL,IDC_ARROW);
    kWC.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    kWC.lpszClassName = gs_acWindowClassName;
    if ( pkTheApp->GetMenuID() )
        kWC.lpszMenuName  = MAKEINTRESOURCE(pkTheApp->GetMenuID());
    else
        kWC.lpszMenuName = 0;

    RegisterClass(&kWC);

    // require the window to have the specified client area
    RECT kRect = { 0, 0, pkTheApp->GetWidth()-1, pkTheApp->GetHeight()-1 };
    AdjustWindowRect(&kRect,gs_dwWindowStyle,pkTheApp->GetMenuID());

    // create the application window
    int iXPos = CW_USEDEFAULT;
    int iYPos = CW_USEDEFAULT;
    int iXSize = kRect.right - kRect.left + 1;
    int iYSize = kRect.bottom - kRect.top + 1;
    HWND hWnd = CreateWindow(gs_acWindowClassName,pkTheApp->GetCaption(),
        gs_dwWindowStyle,iXPos,iYPos,iXSize,iYSize,0,0,hInstance,0);

    pkTheApp->SetWindowHandle(hWnd);

    // create status window
    if ( pkTheApp->GetStatusPaneQuantity() )
    {
        InitCommonControls();

        HWND hStatusWnd = CreateWindow(STATUSCLASSNAME,"",
            WS_CHILD | WS_VISIBLE,0,0,0,0,hWnd,0,hInstance,0);

        pkTheApp->SetStatusWindowHandle(hStatusWnd);
    }

    // display the window
    ShowWindow(hWnd,SW_SHOW);
    UpdateWindow(hWnd);

    // allow the application to initialize before starting the message pump
    if ( !pkTheApp->OnInitialize() )
        return -3;

    MSG kMsg;
    while ( true )
    {
        if ( PeekMessage(&kMsg,0,0,0,PM_REMOVE) )
        {
            if ( kMsg.message == WM_QUIT )
                break;

            HACCEL hAccel = 0;
            if ( !TranslateAccelerator(hWnd,hAccel,&kMsg) )
            {
                TranslateMessage(&kMsg);
                DispatchMessage(&kMsg);
            }
        }
        else
        {
            pkTheApp->OnIdle();
        }
    }

    pkTheApp->OnTerminate();

    UnregisterClass(gs_acWindowClassName,hInstance);

    return 0;
}
Esempio n. 19
0
intptr_t CALLBACK ResetDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));
			DisableVisualStylesReset(hDlg);
			return true;

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	
		
		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_COMMAND:
			switch (GET_WM_COMMAND_ID(wParam, lParam))
			{
				case IDOK:
				{
					bool resetFilters = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_FILTERS));
					bool resetGames = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_GAMES));
					bool resetDefaults = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_DEFAULT));
					bool resetUI = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_UI));
					bool resetInternalUI = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_MAME_UI));

					if (resetFilters || resetGames || resetUI || resetDefaults || resetInternalUI)
					{
						char temp[512];
						strcpy(temp, MAMEUINAME);
						strcat(temp, " will now reset the following\n");
						strcat(temp, "to the default settings:\n\n");

						if (resetDefaults)
							strcat(temp, "Global games options\n");

						if (resetInternalUI)
							strcat(temp, "Internal MAME interface options\n");

						if (resetGames)
							strcat(temp, "Individual game options\n");

						if (resetFilters)
							strcat(temp, "Custom folder filters\n");

						if (resetUI)
						{
							strcat(temp, "User interface settings\n\n");
							strcat(temp, "Resetting the user interface options\n");
							strcat(temp, "requires exiting ");
							strcat(temp, MAMEUINAME);
							strcat(temp, ".\n");
						}

						strcat(temp, "\nDo you wish to continue?");

						if (winui_message_box_utf8(hDlg, temp, "Restore settings", MB_ICONQUESTION | MB_YESNO) == IDYES)
						{
							DestroyIcon(hIcon);
							DeleteObject(hBrush);

							if (resetFilters)
								ResetFilters();

							if (resetGames)
								ResetAllGameOptions();

							if (resetDefaults)
								ResetGameDefaults();

							if (resetInternalUI)
								ResetInternalUI();

							// This is the only case we need to exit and restart for.
							if (resetUI)
							{
								ResetInterface();
								EndDialog(hDlg, 1);
								return true;
							}
							else 
							{
								EndDialog(hDlg, 0);
								return true;
							}
						}
						else 
							// Give the user a chance to change what they want to reset.
							break;
					}
				}
		
				// Nothing was selected but OK, just fall through
				case IDCANCEL:
					DeleteObject(hBrush);
					DestroyIcon(hIcon);
					EndDialog(hDlg, 0);
					return true;
			}

			break;
	}

	return false;
}
Esempio n. 20
0
//---------------------------------------------------------------------------------------
LRESULT OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
   LRESULT lr = 0;
   PNOTIFYICONDATA pTrayIcon = (PNOTIFYICONDATA)malloc(sizeof(NOTIFYICONDATA));

   if(pTrayIcon)
   {
      ZeroMemory(pTrayIcon,  sizeof(NOTIFYICONDATA));
      HMODULE hMod = LoadLibrary(_T("shell32.dll"));

      if(hMod)
      {
         FNDllGetVersion pfnDllGetVersion = (FNDllGetVersion)GetProcAddress(hMod, "DllGetVersion");

         if(pfnDllGetVersion)
         {
            DLLVERSIONINFO VerInfo = {0};
            VerInfo.cbSize = sizeof(VerInfo);
            pfnDllGetVersion(&VerInfo);

            if(VerInfo.dwMajorVersion == 6)
            {
               if(VerInfo.dwBuildNumber > 6)
                  pTrayIcon->cbSize = sizeof(NOTIFYICONDATA);
               else
                  pTrayIcon->cbSize = NOTIFYICONDATA_V3_SIZE;

               pTrayIcon->uVersion = NOTIFYICON_VERSION_4;
            }
            else if(VerInfo.dwMajorVersion == 5)
            {
               pTrayIcon->cbSize = NOTIFYICONDATA_V2_SIZE;
               pTrayIcon->uVersion = NOTIFYICON_VERSION;
            }
            else
            {
               pTrayIcon->cbSize = NOTIFYICONDATA_V1_SIZE;
            }
         }

         FreeLibrary(hMod);
         hMod = NULL;
      }

      pTrayIcon->hWnd = hWnd;
      pTrayIcon->uFlags = NIF_INFO | NIF_TIP | NIF_ICON | NIF_MESSAGE;
      pTrayIcon->dwInfoFlags = NIIF_USER;
      pTrayIcon->uCallbackMessage = WM_TRAY;
      pTrayIcon->uTimeout = 10000;

      pTrayIcon->hIcon = (HICON)LoadImage(GetModuleHandle(NULL),
                                          MAKEINTRESOURCE(IDI_OPENNMS_TRAY),
                                          IMAGE_ICON, 0, 0, 0);

      hMod = GetResourceHandle();

      if(hMod)
      {
         TCHAR szBuf[MAX_PATH] = _T("");
         LoadString(hMod, IDS_TRAY_TIP, szBuf, MAX_PATH);
         _tcsncpy_s(pTrayIcon->szTip, ARRAYSIZE(pTrayIcon->szTip), szBuf, _TRUNCATE);

         LoadString(hMod, IDS_TRAY_INFOTITLE, szBuf, MAX_PATH);
         _tcsncpy_s(pTrayIcon->szInfoTitle, ARRAYSIZE(pTrayIcon->szInfoTitle), szBuf, _TRUNCATE);

         LoadString(hMod, IDS_TRAY_INFOTEXT, szBuf, MAX_PATH);
         _tcsncpy_s(pTrayIcon->szInfo, ARRAYSIZE(pTrayIcon->szInfo), szBuf, _TRUNCATE);

         FreeResourceHandle(hMod);
      }

      Sleep(5000);
      Shell_NotifyIcon(NIM_ADD, pTrayIcon);
      SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pTrayIcon);
   }

   return lr;
}
Esempio n. 21
0
int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) 
{
	GCHOOK *gch = (GCHOOK*) lParam;
	if (!gch)
		return 1;

	if (_stricmp(gch->pDest->pszModule, m_szModuleName)) return 0;

	switch (gch->pDest->iType) 
	{
		case GC_SESSION_TERMINATE: 
		{
 			ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
			if (thread != NULL) 
				thread->sendTerminate();
			break;
		}

		case GC_USER_MESSAGE:
			if (gch->ptszText && gch->ptszText[0]) 
			{
				ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
				if (thread)
				{
					rtrim(gch->ptszText); // remove the ending linebreak
					TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText));
					thread->sendMessage('N', NULL, NETID_MSN, UTF8(pszMsg), 0);

					DBVARIANT dbv;
					int bError = getTString("Nick", &dbv);

					GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE };
					gcd.ptszID = gch->pDest->ptszID;

					GCEVENT gce = {0};
					gce.cbSize = sizeof(GCEVENT);
					gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
					gce.pDest = &gcd;
					gce.ptszNick = bError ? _T("") : dbv.ptszVal;
					gce.ptszUID = mir_a2t(MyOptions.szEmail);
					gce.time = time(NULL);
					gce.ptszText = gch->ptszText;
					gce.bIsMe = TRUE;
					CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);

					mir_free((void*)gce.ptszUID);
					if (!bError)
						MSN_FreeVariant(&dbv);
				}
			}
			break;

		case GC_USER_CHANMGR: 
			DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, 
				LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this)));
			break;

		case GC_USER_PRIVMESS: 
		{
			char *email = mir_t2a(gch->ptszUID);
			HANDLE hContact = MSN_HContactFromEmail(email);
			MSN_CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
			mir_free(email);
			break;
		}

		case GC_USER_LOGMENU:
			switch(gch->dwData) 
			{
			case 10: 
				DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, 
					LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this)));
				break;

			case 20:
				MSN_KillChatSession(gch->pDest->ptszID);
				break;
			}
			break;

		case GC_USER_NICKLISTMENU: 
		{
			char *email = mir_t2a(gch->ptszUID);
			HANDLE hContact = MSN_HContactFromEmail(email);
			mir_free(email);

			switch(gch->dwData) 
			{
			case 10:
				MSN_CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
				break;

			case 20:
				MSN_CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0);
				break;

			case 110:
				MSN_KillChatSession(gch->pDest->ptszID);
				break;
			}
			break;
		}
/*	haven't implemented in chat.dll
		case GC_USER_TYPNOTIFY: 
		{
			int chatID = atoi(p);
			ThreadData* thread = MSN_GetThreadByContact((HANDLE)-chatID);
			for (int j=0; j < thread->mJoinedCount; j++) 
			{
				if ((long)thread->mJoinedContacts[j] > 0)
					CallService(MS_PROTO_SELFISTYPING, (WPARAM) thread->mJoinedContacts[j], (LPARAM) PROTOTYPE_SELFTYPING_ON);
			}
			break;
		}
*/
	}

	return 0;
}
Esempio n. 22
0
BOOL CTrayNotifyIcon::SetStandardIcon(UINT nIDResource)
{
	HICON hIcon = LoadIcon(NULL, MAKEINTRESOURCE(nIDResource));
	
	return SetIcon(hIcon);
}
Esempio n. 23
0
int do_install_dialog(char *path_param)
{
	extern HINSTANCE ghinstance;
	return DialogBoxParam(ghinstance,MAKEINTRESOURCE(IDD_INSTALL_DIALOG),NULL,install_proc,(LPARAM)path_param);
}
Esempio n. 24
0
/////////////////////////////////////////////////////////////////
// WinDEUApp
// ---------
//
bool WinDEUApp::ProcessAppMsg (MSG& msg)
{
#if 0

	BOOL result;

	if (msg.message == WM_COMMAND)
	{
		if (ContextHelp || (GetKeyState(VK_F1) < 0))
		{
			ContextHelp = FALSE;
			GetMainWindow()->WinHelp(HelpFileName, HELP_CONTEXT, msg.wParam);
			return TRUE;
		}
	}
	else
	{
		switch (msg.message)
		{
		case WM_KEYDOWN:
			if (msg.wParam == VK_F1)
			{
				// If the Shift/F1 then set the help cursor and turn on the modal help state.
				if (::GetKeyState(VK_SHIFT) < 0)
				{
					ContextHelp = TRUE;
					HelpCursor = ::LoadCursor(GetMainWindow()->GetModule()->GetInstance(), MAKEINTRESOURCE(IDC_HELPCURSOR));
					::SetCursor(HelpCursor);
					return TRUE;        // Gobble up the message.
				}
				else
				{
					// If F1 w/o the Shift key then bring up help's main index.
					// GetMainWindow()->WinHelp(HelpFileName, HELP_INDEX, 0L);
					GetMainWindow()->WinHelp(HelpFileName, HelpContext, 0L);
					return TRUE;        // Gobble up the message.
				}
			}
			else
			{
				if (ContextHelp && (msg.wParam == VK_ESCAPE))
				{
					if (HelpCursor)
						::DestroyCursor(HelpCursor);
					ContextHelp = FALSE;
					HelpCursor = 0;
					GetMainWindow()->SetCursor(0, IDC_ARROW);
					return TRUE;    // Gobble up the message.
				}
			}
			break;

		case WM_MOUSEMOVE:
		case WM_NCMOUSEMOVE:
			if (ContextHelp)
			{
				::SetCursor(HelpCursor);
				return TRUE;        // Gobble up the message.
			}
			break;

		case WM_INITMENU:
			if (ContextHelp)
			{
				::SetCursor(HelpCursor);
				return TRUE;        // Gobble up the message.
			}
			break;

		case WM_ENTERIDLE:
			if (msg.wParam == MSGF_MENU)
			{
				if (GetKeyState(VK_F1) < 0)
				{
					ContextHelp = TRUE;
					GetMainWindow()->PostMessage(WM_KEYDOWN, VK_RETURN, 0L);
					return TRUE;       // Gobble up the message.
				}
			}
			break;

		default:
			;
		}  // End of switch
	}

#endif
	return TApplication::ProcessAppMsg(msg);
}
Esempio n. 25
0
static int OnBrowseDirClick(HWND hDlg)
{
    BrowseForDirectory(hDlg, MAKEINTRESOURCE(IDC_DIRECTORY_NAME), IDS_SELECT_DIRECTORY);
    ConvertToNtName(hDlg, IDC_DIRECTORY_NAME);
    return TRUE;
}
Esempio n. 26
0
INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param)
{
	// Check mandatory parameters
	if (param->pstrResult == nullptr)
	{
		::SetLastError(ERROR_INVALID_PARAMETER);
		return 0;
	}

	LPDLGTEMPLATE dlgTemplate;

	if (param->DlgTemplateName != 0)
	{
		HMODULE hModule = (HMODULE)param->hInstance;
#ifdef __MINGW32__
		HRSRC rcDlg = ::FindResource(hModule, (LPWSTR)(ULONG_PTR)(size_t)(param->DlgTemplateName), RT_DIALOG);
#else
		HRSRC rcDlg = ::FindResource(hModule, MAKEINTRESOURCE(param->DlgTemplateName), RT_DIALOG);
#endif
		if (rcDlg == nullptr)
			return 0;

		HGLOBAL hglobalDlg = ::LoadResource(hModule, rcDlg);
		if (hglobalDlg == nullptr)
			return 0;

		dlgTemplate = (LPDLGTEMPLATE)hglobalDlg;
	}
	else if (param->DlgTemplateData != 0)
	{
		dlgTemplate = (LPDLGTEMPLATE)param->DlgTemplateData;
	}

	MSDN_DLGTEMPLATEEX *dlgTemplateEx =
		IsDlgTemplateExtended((LPDLGTEMPLATE)dlgTemplate) ? (MSDN_DLGTEMPLATEEX *)dlgTemplate : 0;

	if (dlgTemplateEx != 0)
	{
		dlgTemplateEx->exStyle |= param->dwExStylesPlus;
		dlgTemplateEx->style |= param->dwStylesPlus;
		dlgTemplateEx->exStyle &= param->dwExStylesMinus;
		dlgTemplateEx->style &= param->dwStylesMinus;

		if (param->bCenter)
			dlgTemplateEx->style |= DS_CENTER;

		if (param->xPos != -1)
			dlgTemplateEx->x = param->xPos;
		if (param->yPos != -1)
			dlgTemplateEx->y = param->yPos;
	}
	else
	{
		dlgTemplate->dwExtendedStyle |= param->dwExStylesPlus;
		dlgTemplate->style |= param->dwStylesPlus;
		dlgTemplate->dwExtendedStyle &= param->dwExStylesMinus;
		dlgTemplate->style &= param->dwStylesMinus;

		if (param->bCenter)
			dlgTemplate->style |= DS_CENTER;

		if (param->xPos != -1)
			dlgTemplate->x = param->xPos;

		if (param->yPos != -1)
			dlgTemplate->y = param->yPos;
	}

	CWin32InputBox inputbox(param);
	s_win32InputBox = &inputbox;

	// Resize dialog and SHOW or HIDE multiline
	INT_PTR r = ::DialogBoxIndirectParam(param->hInstance, dlgTemplate, param->hwndOwner, (DLGPROC)DlgProc, (LPARAM)&inputbox);
	param->hDlg = NULL;
	s_win32InputBox = nullptr;

	return r;
}
Esempio n. 27
0
	bool CSettingsDialog::Show(HWND hwndOwner,HINSTANCE hinst)
	{
		m_hinst=hinst;

		return ShowDialog(hwndOwner,hinst,MAKEINTRESOURCE(IDD_SETTINGS))==IDOK;
	}
Esempio n. 28
0
void plComponentBase::CreateRollups()
{
    if (!fCompPB)
        return;

    ParamBlockDesc2 *pd = fCompPB->GetDesc();
    plComponentClassDesc *cd = (plComponentClassDesc*)pd->cd;

    // This is a plAutoUIComp, we need to treat it differently
    if (cd->IsAutoUI())
    {
        plAutoUIClassDesc *cd = (plAutoUIClassDesc*)pd->cd;
        cd->CreateAutoRollup(fCompPB);
    }
    // We're using a normal param block with auto UI
    else if (pd->flags & P_AUTO_UI)
    {
        if (pd->flags & P_MULTIMAP)
        {
            int nMaps = pd->map_specs.Count();
            for (int i = 0; i < nMaps; i++)
            {
                ParamBlockDesc2::map_spec spec = pd->map_specs[i];

                // Create the rollout
                IParamMap2 *map = CreateCPParamMap2(spec.map_id,
                                                    fCompPB,
                                                    GetCOREInterface(),
                                                    hInstance,
                                                    MAKEINTRESOURCE(spec.dlg_template),
                                                    GetString(spec.title),
                                                    spec.rollup_flags,
                                                    spec.dlgProc,
                                                    NULL,
                                                    ROLLUP_CAT_STANDARD);

                // Save the rollout in the paramblock
                fCompPB->SetMap(map, spec.map_id);
            }
        }
        else
        {
            // Create the rollout
            IParamMap2 *map = CreateCPParamMap2(0,
                                                fCompPB,
                                                GetCOREInterface(),
                                                hInstance,
                                                MAKEINTRESOURCE(pd->dlg_template),
                                                GetString(pd->title),
                                                pd->flags,
                                                pd->dlgProc,
                                                NULL,
                                                ROLLUP_CAT_STANDARD);

            // Save the rollout in the paramblock
            fCompPB->SetMap(map);
        }
    }

    fCompPB->ReleaseDesc();
}
Esempio n. 29
0
void load_key_file(HWND hwnd, struct MainDlgState *state,
		   Filename filename, int was_import_cmd)
{
    char passphrase[PASSPHRASE_MAXLEN];
    int needs_pass;
    int type, realtype;
    int ret;
    char *comment;
    struct PassphraseProcStruct pps;
    struct RSAKey newkey1;
    struct ssh2_userkey *newkey2 = NULL;

    type = realtype = key_type(&filename);
    if (type != SSH_KEYTYPE_SSH1 &&
	type != SSH_KEYTYPE_SSH2 &&
	!import_possible(type)) {
	char msg[256];
	sprintf(msg, "Couldn't load private key (%s)",
		key_type_to_str(type));
	MessageBox(NULL, msg,
		   "PuTTYgen Error", MB_OK | MB_ICONERROR);
	return;
    }

    if (type != SSH_KEYTYPE_SSH1 &&
	type != SSH_KEYTYPE_SSH2) {
	realtype = type;
	type = import_target_type(type);
    }

    comment = NULL;
    if (realtype == SSH_KEYTYPE_SSH1)
	needs_pass = rsakey_encrypted(&filename, &comment);
    else if (realtype == SSH_KEYTYPE_SSH2)
	needs_pass =
	ssh2_userkey_encrypted(&filename, &comment);
    else
	needs_pass = import_encrypted(&filename, realtype,
				      &comment);
    pps.passphrase = passphrase;
    pps.comment = comment;
    do {
	if (needs_pass) {
	    int dlgret;
	    dlgret = DialogBoxParam(hinst,
				    MAKEINTRESOURCE(210),
				    NULL, PassphraseProc,
				    (LPARAM) & pps);
	    if (!dlgret) {
		ret = -2;
		break;
	    }
	} else
	    *passphrase = '\0';
	if (type == SSH_KEYTYPE_SSH1) {
	    if (realtype == type)
		ret = loadrsakey(&filename, &newkey1,
				 passphrase, NULL);
	    else
		ret = import_ssh1(&filename, realtype,
				  &newkey1, passphrase);
	} else {
	    if (realtype == type)
		newkey2 = ssh2_load_userkey(&filename,
					    passphrase, NULL);
	    else
		newkey2 = import_ssh2(&filename, realtype,
				      passphrase);
	    if (newkey2 == SSH2_WRONG_PASSPHRASE)
		ret = -1;
	    else if (!newkey2)
		ret = 0;
	    else
		ret = 1;
	}
    } while (ret == -1);
    if (comment)
	sfree(comment);
    if (ret == 0) {
	MessageBox(NULL, "Couldn't load private key.",
		   "PuTTYgen Error", MB_OK | MB_ICONERROR);
    } else if (ret == 1) {
	/*
	 * Now update the key controls with all the
	 * key data.
	 */
	{
	    SetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
			   passphrase);
	    SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
			   passphrase);
	    if (type == SSH_KEYTYPE_SSH1) {
		char buf[128];
		char *savecomment;

		state->ssh2 = FALSE;
		state->commentptr = &state->key.comment;
		state->key = newkey1;

		/*
		 * Set the key fingerprint.
		 */
		savecomment = state->key.comment;
		state->key.comment = NULL;
		rsa_fingerprint(buf, sizeof(buf),
				&state->key);
		state->key.comment = savecomment;

		SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
		/*
		 * Construct a decimal representation
		 * of the key, for pasting into
		 * .ssh/authorized_keys on a Unix box.
		 */
		setupbigedit1(hwnd, IDC_KEYDISPLAY,
			      IDC_PKSTATIC, &state->key);
	    } else {
		char *fp;
		char *savecomment;

		state->ssh2 = TRUE;
		state->commentptr =
		    &state->ssh2key.comment;
		state->ssh2key = *newkey2;	/* structure copy */
		sfree(newkey2);

		savecomment = state->ssh2key.comment;
		state->ssh2key.comment = NULL;
		fp =
		    state->ssh2key.alg->
		    fingerprint(state->ssh2key.data);
		state->ssh2key.comment = savecomment;

		SetDlgItemText(hwnd, IDC_FINGERPRINT, fp);
		sfree(fp);

		setupbigedit2(hwnd, IDC_KEYDISPLAY,
			      IDC_PKSTATIC, &state->ssh2key);
	    }
	    SetDlgItemText(hwnd, IDC_COMMENTEDIT,
			   *state->commentptr);
	}
	/*
	 * Finally, hide the progress bar and show
	 * the key data.
	 */
	ui_set_state(hwnd, state, 2);
	state->key_exists = TRUE;

	/*
	 * If the user has imported a foreign key
	 * using the Load command, let them know.
	 * If they've used the Import command, be
	 * silent.
	 */
	if (realtype != type && !was_import_cmd) {
	    char msg[512];
	    sprintf(msg, "Successfully imported foreign key\n"
		    "(%s).\n"
		    "To use this key with PuTTY, you need to\n"
		    "use the \"Save private key\" command to\n"
		    "save it in PuTTY's own format.",
		    key_type_to_str(realtype));
	    MessageBox(NULL, msg, "PuTTYgen Notice",
		       MB_OK | MB_ICONINFORMATION);
	}
    }
}
Esempio n. 30
0
INT_PTR Meta_AddTo(WPARAM wParam, LPARAM lParam)
{
	HWND clui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
	DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_METASELECT), clui, &Meta_SelectDialogProc, (LPARAM)wParam);
	return 0;
}