Esempio n. 1
0
PGPError SCSetProgressAVI(HPRGDLG hPrgDlg,DWORD dwAVIClip)
{
	HWND hwndAVI;

	hwndAVI=GetDlgItem(hPrgDlg->hwnd,IDC_PRGAVI);

	hPrgDlg->dwAVIClip=dwAVIClip;

	if(hPrgDlg->dwAVIClip!=0)
	{
		hPrgDlg->bAVIPlaying=TRUE;
		
		Animate_Open(hwndAVI,
			MAKEINTRESOURCE(hPrgDlg->dwAVIClip));
		ShowWindow(hwndAVI,SW_SHOW);
	}
	else
	{
		hPrgDlg->bAVIPlaying=FALSE;

		ShowWindow(hwndAVI,SW_HIDE);
		Animate_Close(hwndAVI);
	}
	
	return kPGPError_NoErr;
}
Esempio n. 2
0
File: qa.c Progetto: mingpen/OpenNT
/*----------------------------------------------------------------------------*\
|   AppOpenFile()							       |
|                                                                              |
|   Description:                                                               |
|	open a file stupid						       |
|                                                                              |
\*----------------------------------------------------------------------------*/
void AppOpenFile(HWND hwnd, LPTSTR szFileName)
{
    if (!Animate_Open(hwndA, szFileName))
    {
        AppSetText(NULL);
        ErrMsg(TEXT("Cant open %s"), szFileName);
    }
    else
    {
        AppSetText(TEXT("%s"), szFileName);
        InvalidateRect(hwnd, NULL, TRUE);
    }
}
Esempio n. 3
0
//=--------------------------------------------------------------------------=
// CPatchDialog::OnInitDialog
//=--------------------------------------------------------------------------=
// Message handler for WM_INITDIALOG
//
// Parameters:
//	uMsg	    Windows Message
//	wParam	    WPARAM
//	lParam	    LPARAM
//	bHandled    FALSE if not handled
//
// Output:
//	LRESULT	    
//
// Notes:
//
LRESULT CPatchDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    // Change caption
    TCHAR szMsg[BUFFER_SIZE], szCaptionText[BUFFER_SIZE];

    ::LoadString(_Module.GetResourceInstance(), IDS_CAPTION_UPDATE, szMsg, BUFFER_SIZE);
    wsprintf(szCaptionText, szMsg, "{" NEW_IMAGE_FULLVERSION "}");
    SetWindowText(szCaptionText);

    // Start animation
    Animate_Open(GetDlgItem(IDC_UPDATE_ANIMATE), MAKEINTRESOURCE(IDR_JAVAAVI));

    // Create a new thread for patch update
    DWORD dwThreadId = NULL;
    ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) PatchUpdateThreadProc, this, 0, &dwThreadId);
	
    return 1;  // Let the system set the focus
}
Esempio n. 4
0
/*
 * DownloadDialogProc:  Dialog procedure for displaying downloading progress.
 */
BOOL CALLBACK DownloadDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
   int fraction, i;
   HWND hGraph;
   BOOL bResult = FALSE;
   char temp[256];

   switch (message)
   {
   case WM_INITDIALOG:
      CenterWindow(hDlg, hMain);
      if (!advert)
      {
	 ShowWindow(hMain, SW_HIDE);
      }
      hDownloadDialog = hDlg;
      
      // Set up graph bar limits
      hGraph = GetDlgItem(hDlg, IDC_GRAPH);
      SendMessage(hGraph, GRPH_RANGESET, 0, 100);
      SendMessage(hGraph, GRPH_POSSET, 0, 0);
      SendMessage(hGraph, GRPH_COLORSET, GRAPHCOLOR_BAR, GetColor(COLOR_BAR1));
      SendMessage(hGraph, GRPH_COLORSET, GRAPHCOLOR_BKGND, GetColor(COLOR_BAR2));

      hGraph = GetDlgItem(hDlg, IDC_FILEGRAPH);
      SendMessage(hGraph, GRPH_RANGESET, 0, 100);
      SendMessage(hGraph, GRPH_POSSET, 0, 0);
      SendMessage(hGraph, GRPH_COLORSET, GRAPHCOLOR_BAR, GetColor(COLOR_BAR1));
      SendMessage(hGraph, GRPH_COLORSET, GRAPHCOLOR_BKGND, GetColor(COLOR_BAR2));

      hGraph = GetDlgItem(hDlg, IDC_ANIMATE1);
      bResult = Animate_Open(hGraph, MAKEINTRESOURCE(IDA_DOWNLOAD));

      abort_download = False;
      PostMessage(hDlg, BK_TRANSFERSTART, 0, 0);

      GetDlgItemText(hDlg, IDC_FILESIZE, format, sizeof(format));
      sprintf(temp, format, (int)0, (int)0);
      SetDlgItemText(hDlg, IDC_FILESIZE, temp);

      return TRUE;

   case WM_DESTROY:
      if (!advert)
      {
	 ShowWindow(hMain, SW_SHOW);
	 UpdateWindow(hMain);
      }
      hDownloadDialog = NULL;
      return TRUE;

   case BK_TRANSFERSTART:
      info->hPostWnd = hDlg;
      hThread = (HANDLE)(unsigned long)_beginthread(TransferStart, 0, info);
      TransferMessage(GetString(hInst, IDS_CONNECTING), info->machine);
      return TRUE;

   case BK_FILESIZE:  // wParam is file index, lParam is file size
      if (wParam == 0)
	 TransferMessage(GetString(hInst, IDS_RETRIEVING));

      SetDlgItemText(hDlg, IDC_FILENAME, info->files[wParam].filename);
      total = lParam;
      sprintf(temp, format, 0, total);
      SetDlgItemText(hDlg, IDC_FILESIZE, temp);
      SendDlgItemMessage(hDlg, IDC_GRAPH, GRPH_POSSET, 0, 0);
      SendDlgItemMessage(hDlg, IDC_GRAPH, GRPH_RANGESET, 0, total);
      return TRUE;

   case BK_PROGRESS:

      // Update this file's progress indicator.
      SendDlgItemMessage(hDlg, IDC_GRAPH, GRPH_POSSET, 0, lParam);

      // Update this file's progress text message.
      sprintf(temp, format, (int)lParam, (int)total);
      SetDlgItemText(hDlg, IDC_FILESIZE, temp);

      // Compute the fraction for the overall graph.
      fraction = 0;
      if (total != 0)
	 fraction = lParam * 100 / total;
      fraction = (fraction + 100 * info->current_file) / info->num_files;

      // Update overall progress indicator.
      SendDlgItemMessage(hDlg, IDC_FILEGRAPH, GRPH_POSSET, 0, fraction);

      return TRUE;

   case BK_FILEDONE:  /* lParam is index of file in info */
      if (abort_download)
      {
	 AbortDownloadDialog();
	 return TRUE;
      }

      if (DownloadDone(&info->files[lParam]))
      {
	 if (abort_download)
	 {
	    AbortDownloadDialog();
	    return TRUE;
	 }

	 // Set download time
	 DownloadSetTime(info->files[lParam].time);

	 // If we're a guest, there may be additional files that we are supposed to skip.
	 // If so, we should set our download time to the last file, so that we will skip
	 // the download on the next entry into the game.
	 if (config.guest)
	    for (i = lParam + 1; i < info->num_files; i++)
	    {
	       if (info->files[i].flags & DF_GUEST)
		  break;
	       DownloadSetTime(info->files[i].time);
	    }

	 info->current_file++;

	 // Tell transfer thread to continue
	 TransferContinue();

	 TransferMessage(GetString(hInst, IDS_RETRIEVING));
      }
      else AbortDownloadDialog();
      return TRUE;

   case BK_TRANSFERDONE: 
      EndDialog(hDlg, IDOK);
      return TRUE;

   case WM_COMMAND:
      switch(GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDCANCEL:
         abort_download = True;
	 EndDialog(hDlg, IDCANCEL);
	 return TRUE;
      }
   }
   return FALSE;
}
Esempio n. 5
0
INT_PTR
CALLBACK
IntPage1DlgProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
)

/*++

Routine Description:

    This function is the dialog procedure for the first interior wizard page.
    This page updates the drivers for any existing (present) devices, or
    installs the INF if there aren't any present devices.

Arguments:

    hwndDlg - Supplies a handle to the dialog box window

    uMsg - Supplies the message

    wParam - Supplies the first message parameter

    lParam - Supplies the second message parameter

Return Value:

    This dialog procedure always returns zero.

--*/

{
    LPSHAREDWIZDATA pdata;
    LPNMHDR lpnm;
    HANDLE hThread;
    HKEY hKey;
    DWORD UserPrompted;

    UNREFERENCED_PARAMETER( wParam );

    //
    // Retrieve the shared user data from GWL_USERDATA
    //
    pdata = (LPSHAREDWIZDATA) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

    switch(uMsg) {

    case WM_INITDIALOG :
        //
        // Get the PROPSHEETPAGE lParam value and load it into GWL_USERDATA
        //
        pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam;
        SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) pdata);
        break;

    case WM_NOTIFY :

        lpnm = (LPNMHDR)lParam;

        switch(lpnm->code) {

        case PSN_SETACTIVE :
            //
            // If we're coming here from the intro page, then disable
            // the Back and Next buttons (we're going to be busy for a
            // little bit updating drivers).
            //
            // If we're coming to this page from anywhere else,
            // immediately jump to the intro page.
            //
            if(pdata->DoDriverUpdatePage) {
                //
                // Reset our flag so that we won't try this again if we
                // go to later pages, then come back to this one.  (We
                // only do anything when the wizard page is accessed in
                // the forward direction, from the Intro page.)
                //
                pdata->DoDriverUpdatePage = FALSE;

                //
                // Set our "UserPrompted" registry flag so the
                // co-installer won't popup its own value-add software
                // chooser page during driver update.
                //
                if(ERROR_SUCCESS == RegCreateKeyEx(
                            HKEY_LOCAL_MACHINE,
                            TEXT("SOFTWARE\\Microsoft\\Toaster"),
                            0,
                            NULL,
                            REG_OPTION_NON_VOLATILE,
                            KEY_READ | KEY_WRITE,
                            NULL,
                            &hKey,
                            NULL)) {

                    UserPrompted = 1;
                    RegSetValueEx(hKey,
                                  TEXT("User Prompted"),
                                  0,
                                  REG_DWORD,
                                  (PBYTE)&UserPrompted,
                                  sizeof(UserPrompted)
                                 );

                    RegCloseKey(hKey);
                }

                //
                // Disable Next, Back, and Cancel
                //
                PropSheet_SetWizButtons(GetParent(hwndDlg), 0);
                EnableWindow(GetDlgItem(GetParent(hwndDlg), IDCANCEL), FALSE);

                //
                // Show "searching" animation...
                //
                ShowWindow(GetDlgItem(hwndDlg, IDC_ANIMATE1), SW_SHOW);
                Animate_Open(GetDlgItem(hwndDlg, IDC_ANIMATE1), MAKEINTRESOURCE(IDA_SEARCHING));
                Animate_Play(GetDlgItem(hwndDlg, IDC_ANIMATE1), 0, -1, -1);

                //
                // Create a thread to do the work of updating the
                // driver, etc.
                //
                pdata->hwndDlg = hwndDlg;

                hThread = CreateThread(NULL,
                                       0,
                                       UpdateDriverThreadProc,
                                       pdata,
                                       0,
                                       NULL
                                      );

                if(hThread) {
                    //
                    // Thread launched successfully--close the handle,
                    // then just wait to be notified of thread's
                    // completion.
                    //
                    CloseHandle(hThread);

                } else {
                    //
                    // Couldn't launch the thread--just move on to the
                    // value-add software page.
                    //
                    PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
                    PropSheet_PressButton(GetParent(hwndDlg), PSBTN_NEXT);
                }

            } else {
                //
                // We're coming "back" to this page.  Skip it, and go
                // to the intro page.
                //
                PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK);
                PropSheet_PressButton(GetParent(hwndDlg), PSBTN_BACK);
            }
            break;

        case PSN_WIZNEXT :
            //Handle a Next button click, if necessary
            break;

        case PSN_WIZBACK :
            //Handle a Back button click, if necessary
            break;

        case PSN_RESET :
            //Handle a Cancel button click, if necessary
            break;

        default :
            break;
        }
        break;

    case WMX_UPDATE_DRIVER_DONE :
        //
        // Stop "searching" animation...
        //
        Animate_Stop(GetDlgItem(hwndDlg, IDC_ANIMATE1));
        ShowWindow(GetDlgItem(hwndDlg, IDC_ANIMATE1), SW_HIDE);

        //
        // Regardless of whether we succeeded in upgrading any drivers, we'll
        // go ahead and proceed to the value-add software page.
        //
        PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
        EnableWindow(GetDlgItem(GetParent(hwndDlg), IDCANCEL), TRUE);

        PropSheet_PressButton(GetParent(hwndDlg), PSBTN_NEXT);

        break;

    default:
        break;
    }

    return 0;
}
Esempio n. 6
0
int CALLBACK LongDialogProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) {
    sDIALOG_long * dlg;
    HWND hwnd2;

    switch (message)
    {
    case WM_INITDIALOG:
        SetWindowPos(hwnd , HWND_TOP , 0 , 0 , 0 , 0 , SWP_NOMOVE | SWP_NOSIZE);
        dlg = (sDIALOG_long*)lParam;
        dlg->cancel = false;
        dlg->handle = hwnd;
        LongDialogProc(hwnd , MYWM_DLGLONGSET , 0 , lParam);
//                SetTimer(hwnd , 1 , 500 , (TIMERPROC)LongTimerProc);
//                SetProp(hwnd , "DLGTIMER" , timer);
        SendMessage(GetDlgItem(hwnd , IDC_PROGRESS) , PBM_SETRANGE32 , 0 , dlg->progress>0 ? dlg->progress : 100);
        if (dlg->progress > 0) dlg->progress = 0;
        break;
    case WM_CLOSE:
//                KillTimer(hwnd , 1);
//                timer = GetProp(hwnd , "DLGTIMER");
//                CancelWaitableTimer(timer);
//                CloseHandle(timer);
        DestroyWindow(hwnd);
        break;
    case WM_DESTROY:
        RemoveProp(hwnd , "DLG");
//                RemoveProp(hwnd , "DLGTIMER");
        break;
    case MYWM_DLGLONGSET:
        if (!wParam) wParam = -1;
        dlg = (sDIALOG_long*)lParam;
        SetProp(hwnd , "DLG" , dlg);
        if (wParam & DSET_TITLE) SetWindowText(hwnd , dlg->title);
        if (wParam & DSET_INFO ) SetDlgItemText(hwnd , IDC_STATIC , dlg->info);
        if (wParam & DSET_BUTTONS) ShowWindow(GetDlgItem(hwnd , IDCANCEL) , dlg->flag & DLONG_CANCEL ? SW_SHOW:SW_HIDE);

        if (wParam & DSET_ANIM)
            switch (dlg->flag & 0xFF0) {
            case DLONG_ASEND:
                Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONGSEND));
            case DLONG_ARECV:
                Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONGRECV));
            case DLONG_AINET:
                Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONGINET));
            case 0:
                Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONG));
//                      HINSTANCE hlib = LoadLibrary("shell32.dll");
//                      Animate_OpenEx(GetDlgItem(hwnd , IDC_ANIMATE) , hlib , MAKEINTRESOURCE(152));
//                      FreeLibrary(hlib);
                break;
            }
        if (wParam & DSET_PROGRESS) {
            hwnd2 = GetDlgItem(hwnd , IDC_PROGRESS);
            if (dlg->progress>=0 && !IsWindowVisible(hwnd2)) ShowWindow(hwnd2 , SW_SHOW);
            else if (dlg->progress<0 && IsWindowVisible(hwnd2)) ShowWindow(hwnd2 , SW_HIDE);
            SendMessage(hwnd2 , PBM_SETPOS , dlg->progress , 0);
        }
        break;
    case WM_COMMAND:
        dlg = (sDIALOG_long*) GetProp(hwnd , "DLG");
        if (HIWORD(wParam)!=BN_CLICKED) return 0;
        switch (LOWORD(wParam))
        {
        case IDCANCEL:
            IMLOG("- Cancel@LongProc pressed");
            if (!dlg->cancelProc) {
                dlg->cancel = true;
                ShowWindow(hwnd , SW_HIDE);
            }
            else if (dlg->cancelProc(dlg))
                dlg->cancel = true;
            return TRUE;
        }

    }
    return 0;
}
Esempio n. 7
0
BOOL CALLBACK PrgDlgProc (HWND hDlg, 
							  UINT uMsg, 
							  WPARAM wParam,
							  LPARAM lParam)
{
	HPRGDLG hPrgDlg;

	switch (uMsg) 
	{
		case WM_INITDIALOG:
		{    
			RECT rc;

			SetWindowLong (hDlg, GWL_USERDATA, lParam);
			hPrgDlg=(HPRGDLG)lParam;
			hPrgDlg->hwnd=hDlg;

			// Spawn work thread
			CreateThread (NULL, 0, PrgDlgThreadRoutine, 
				(LPVOID)hPrgDlg, 0, &(hPrgDlg->dwThreadID));

			// Initialize GUI elements
			SendDlgItemMessage (hDlg, IDC_PROGRESS, PBM_SETRANGE, 
				0, MAKELPARAM(0, 100));
			SendDlgItemMessage (hDlg, IDC_PROGRESS, PBM_SETPOS,
				(WPARAM)hPrgDlg->dwBar, 0);

			if(hPrgDlg->szTitle)
				SetWindowText(hDlg,hPrgDlg->szTitle);

			if(hPrgDlg->szFile)
				SetWindowText(GetDlgItem(hPrgDlg->hwnd,IDC_PRGFILE),hPrgDlg->szFile);

			if(hPrgDlg->szInfo)
				SetWindowText(GetDlgItem(hPrgDlg->hwnd,IDC_PRGINFO),hPrgDlg->szInfo);

			if(hPrgDlg->dwAVIClip!=0)
			{
				hPrgDlg->bAVIPlaying=TRUE;
				Animate_Open(GetDlgItem(hPrgDlg->hwnd,IDC_PRGAVI),
					MAKEINTRESOURCE(hPrgDlg->dwAVIClip));
			}

			// Create update timer
			SetTimer(hDlg,UPDATETIMERID,UPDATETIME,NULL);

			// Center window and set to foreground
 			GetWindowRect (hDlg, &rc);
			SetWindowPos (hDlg, NULL,
				(GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
				(GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2,
				0, 0, SWP_NOSIZE | SWP_NOZORDER);
			SetForegroundWindow(hDlg);
			return TRUE;
		}

		case WM_CTLCOLOR:
		{          
 			if(wParam!=0)
			{ 
				DWORD color;

				color=GetSysColor(COLOR_BTNFACE);
				
			  	SetBkColor ((HDC)wParam, color);
			  	SetTextColor ((HDC)wParam, GetSysColor (COLOR_WINDOWTEXT));
			  	return (BOOL)CreateSolidBrush (color);
			} 	 
			break;
		}

		case WM_TIMER:
		{
			BOOL bWindowEnabled;

			hPrgDlg = (HPRGDLG) GetWindowLong(hDlg, GWL_USERDATA);

			if(hPrgDlg->dwAVIClip!=0)
			{
				bWindowEnabled=IsWindowEnabled(hPrgDlg->hwnd);

				if((!bWindowEnabled)&&(hPrgDlg->bAVIPlaying))
				{
					hPrgDlg->bAVIPlaying=FALSE;
					Animate_Stop(GetDlgItem(hPrgDlg->hwnd,IDC_PRGAVI));
				}

				if((bWindowEnabled)&&(!hPrgDlg->bAVIPlaying))
				{
					hPrgDlg->bAVIPlaying=TRUE;
					Animate_Play(GetDlgItem(hPrgDlg->hwnd,IDC_PRGAVI), 0, -1, -1);
				}
			}

			// If there has been a change, process it
			if(hPrgDlg->dwNewValue!=hPrgDlg->dwOldValue)
			{
				hPrgDlg->dwOldValue=hPrgDlg->dwNewValue;

				SendDlgItemMessage (hDlg, IDC_PROGRESS, PBM_SETPOS,
					(WPARAM)hPrgDlg->dwNewValue, 0);
			}

			break;
		}

		case WM_CLOSE:
		case WM_QUIT:
		case WM_DESTROY:
		{
			EndDialog(hDlg, FALSE);
			break;
		}

		case WM_COMMAND:
		{
			switch(LOWORD (wParam)) 
			{
				case IDCANCEL:
				{
					hPrgDlg = (HPRGDLG) GetWindowLong(hDlg, GWL_USERDATA);
					ShowWindow(hDlg,SW_HIDE);

					hPrgDlg->bCancel=TRUE;
					break;
				}
			}
			break;
		}
	}
	return FALSE;
}
Esempio n. 8
0
BOOL CALLBACK PickCharDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
   static HWND hList;
   int index, i;
   Character *c;

   switch (message)
   {
   case WM_INITDIALOG:
      CenterWindow(hDlg, GetParent(hDlg));
      hList = GetDlgItem(hDlg, IDC_CHARLIST);
      info = (PickCharStruct *) lParam;

      /* Display characters in list */
      for (i=0; i < info->num_characters; i++)
      {
 	 // For new characters, show a special string
  	 if (info->characters[i].flags == 1)
	   index = ListBox_AddString(hList, GetString(hInst, IDS_NEWCHARACTER));
	   else index = ListBox_AddString(hList, info->characters[i].name);
	 ListBox_SetItemData(hList, index, i);
      }

      /* Select first char */
      ListBox_SetCurSel(hList, 0);

      // Show message of the day
      Edit_SetText(GetDlgItem(hDlg, IDC_MOTD), info->motd);  

      // Display advertisements
      for (i=0; i < info->num_ads; i++)
      {
	 char filename[MAX_PATH + FILENAME_MAX];
	 sprintf(filename, "%s\\%s", ad_directory, info->ads[i].filename);
	 Animate_Open(GetDlgItem(hDlg, animation_controls[i]), filename);
      }

      hPickCharDialog = hDlg;
      return TRUE;

   case WM_COMPAREITEM:
      return ItemListCompareItem(hDlg, (const COMPAREITEMSTRUCT *) lParam);
   case WM_MEASUREITEM:
      ItemListMeasureItem(hDlg, (MEASUREITEMSTRUCT *) lParam);
      return TRUE;
   case WM_DRAWITEM:
      return ItemListDrawItem(hDlg, (const DRAWITEMSTRUCT *) lParam);

      HANDLE_MSG(hDlg, WM_LBUTTONDOWN, CharPickLButtonDown);
	 
      HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor);
      HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor);
      HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor);
      HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor);

   case WM_COMMAND:
      switch(GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDC_RESET:
	 /* Get currently chosen character's name */
	 if ((index = ListBox_GetCurSel(hList)) == LB_ERR)
	    return TRUE;

	 index = ListBox_GetItemData(hList, index);

	 c = &info->characters[index];
	 
	 if (!AreYouSure(hInst, hDlg, NO_BUTTON, IDS_DELETECHAR, c->name))
	    return TRUE;

	 char_to_use = c->id;
	 strcpy(name_to_use, c->name);
	 EndDialog(hDlg, IDC_RESET);
	 return TRUE;
	 
      case IDOK:
	 /* Tell server that we want to use selected character */
	 if ((index = ListBox_GetCurSel(hList)) == LB_ERR)
	    return TRUE;

	 index = ListBox_GetItemData(hList, index);

	 c = &info->characters[index];
	 
	 char_to_use = c->id;
	 strcpy(name_to_use, c->name);

	 // If this character hasn't been used before, go to char creation
	 if (c->flags == 1)
	    EndDialog(hDlg, IDC_RESET);
	 else EndDialog(hDlg, IDOK);
	 return TRUE;
	 
      case IDCANCEL:
	 /* If user verifies, ask to leave game */	 
	 if (!AreYouSure(cinfo->hInst, hDlg, NO_BUTTON, IDS_LOGOFF))
	    break;
	 Logoff();

	 EndDialog(hDlg, IDCANCEL);
	 return TRUE;
      }
      break;

   case WM_DESTROY:
      hPickCharDialog = NULL;
      if (exiting)
	 PostMessage(cinfo->hMain, BK_MODULEUNLOAD, 0, MODULE_ID);
      break;
   }
   return FALSE;
}
Esempio n. 9
0
BOOL WINAPI _RtkGuiWaitDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static WAITDLG_CONTEXT *ctx;
//	static HBRUSH hBrush = NULL;
	
    switch(uMsg)
    {
		case WM_SHOWWINDOW:
		{
			HWND hState, hTimeLeft, hTimeRemain, 
				 hProgress, hCancel, hPause, hAnimate;
			
			hPause      = GetDlgItem(hDlg, IDPAUSE);
			hCancel     = GetDlgItem(hDlg, IDCANCEL);
			hState      = GetDlgItem(hDlg, IDC_STATE);
			hAnimate    = GetDlgItem(hDlg, IDC_ANIMATE);
			hProgress   = GetDlgItem(hDlg, IDC_PROGRESS);
			hTimeLeft   = GetDlgItem(hDlg, IDC_TIMELEFT);
			hTimeRemain = GetDlgItem(hDlg, IDC_TIMEREMAIN);

			ctx = (LPWAITDLG_CONTEXT)GetWindowLong(hDlg, GWL_USERDATA);
			ctx->dwLastTime = GetTickCount();
		
			if (ctx->uType & WDS_STATE) {
				ShowWindow(hState, SW_SHOW);
			}

			if (ctx->uType & WDS_ANIMATE) {
				ShowWindow(hAnimate, SW_SHOW);
				Animate_Open(hAnimate, MAKEINTRESOURCE(IDR_WAIT));
			}

			 if (ctx->uType & WDS_CANCEL) {
				ShowWindow(hCancel, SW_SHOW);
			}
			
			if (ctx->uType & WDS_PAUSE) {
				ShowWindow(hPause, SW_SHOW);
			}

			if (ctx->uType & WDS_TIMELEFT) {
				ShowWindow(hTimeLeft, SW_SHOW);
			}

			if (ctx->uType & WDS_TIMEREMAIN) {
				ShowWindow(hTimeRemain, SW_SHOW);
			}
			
			if (ctx->uType & WDS_PROGRESS) {
				ShowWindow(hProgress, SW_SHOW);
			}
			/* 
				土办法,为每种组合调整一次位置,在没有想到更好的方法的时候,
				只好做此下策
				目前支持几种组合是
				1:带cancel按钮和进度条和状态文本
				2:带cancel按钮和进度条和状态文本和时间(剩余时间和已过去时间)
				3:带cancel按钮和进度条和动画和状态文本
				4:带cancel按钮和进度条和动画和状态文本和时间
				
				5:带cancel,pause按钮和进度条和状态文本
				6:带cancel,pause按钮和进度条和动画和状态文本
				7:对于显示不显示timeleft和timeremain就不需要调整位置了
			*/
			switch (ctx->uType)
			{
				case WDS_CANCEL|WDS_PROGRESS|WDS_STATE:
						SetWindowPos(hState, NULL, 6, 10, 0, 0, SWP_NOSIZE);
						SetWindowPos(hProgress, NULL, 6, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hCancel, NULL, 270, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hDlg, NULL, 0, 0, 360, 96, SWP_NOMOVE);
					break;
				
				case WDS_CANCEL|WDS_PROGRESS|WDS_STATE|WDS_TIMELEFT:
						SetWindowPos(hState, NULL, 6, 10, 0, 0, SWP_NOSIZE);
						SetWindowPos(hProgress, NULL, 6, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hCancel, NULL, 270, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hTimeLeft, NULL, 6, 60, 0, 0, SWP_NOSIZE);
						SetWindowPos(hDlg, NULL, 0, 0, 360, 110, SWP_NOMOVE);
					break;
				
				case WDS_CANCEL|WDS_PROGRESS|WDS_STATE|WDS_TIMEREMAIN:
						SetWindowPos(hState, NULL, 6, 10, 0, 0, SWP_NOSIZE);
						SetWindowPos(hProgress, NULL, 6, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hCancel, NULL, 270, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hTimeRemain, NULL, 6, 60, 0, 0, SWP_NOSIZE);
						SetWindowPos(hDlg, NULL, 0, 0, 360, 110, SWP_NOMOVE);
					break;

				case WDS_CANCEL|WDS_PROGRESS|WDS_STATE|WDS_TIMEREMAIN|WDS_TIMELEFT:
						SetWindowPos(hState, NULL, 6, 10, 0, 0, SWP_NOSIZE);
						SetWindowPos(hProgress, NULL, 6, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hCancel, NULL, 270, 30, 0, 0, SWP_NOSIZE);
						SetWindowPos(hTimeLeft, NULL, 6, 60, 0, 0, SWP_NOSIZE);
						SetWindowPos(hTimeRemain, NULL, 215, 60, 0, 0, SWP_NOSIZE);
						SetWindowPos(hDlg, NULL, 0, 0, 360, 110, SWP_NOMOVE);
					break;
			
				case WDS_CANCEL|WDS_PROGRESS|WDS_ANIMATE|WDS_STATE:
						SetWindowPos(hAnimate, NULL, 6, 0, 0, 0, SWP_NOSIZE);
						SetWindowPos(hState, NULL, 10, 70, 0, 0, SWP_NOSIZE);
						SetWindowPos(hProgress, NULL, 6, 90, 0, 0, SWP_NOSIZE);
						SetWindowPos(hCancel, NULL, 270, 90, 0, 0, SWP_NOSIZE);
						SetWindowPos(hDlg, NULL, 0, 0, 360, 156, SWP_NOMOVE);
					break;
			
				case WDS_CANCEL|WDS_PAUSE|WDS_PROGRESS:
					break;

				case WDS_CANCEL|WDS_PAUSE|WDS_PROGRESS|WDS_ANIMATE:
					break;

				default:
					break;
			}

		}	
		return TRUE;
        break;

	case WM_TIMER:
		{
			char szTimeRemain[MAX_PATH], szTimeLeft[MAX_PATH];
		
			if (!ctx->nPos)
			{
				return TRUE;
			}
			if (!ctx->bPause)
			{
				ctx->dwTimeLeft  += GetTickCount() - ctx->dwLastTime;
				ctx->dwLastTime   = GetTickCount();
				ctx->dwTimeRemain = ctx->dwTimeLeft / ctx->nPos * (100 - ctx->nPos);
	
				sprintf(szTimeRemain, 
						"%02d:%02d:%02d", 
						(ctx->dwTimeRemain / 1000) / 3600,
						(ctx->dwTimeRemain / 1000) % 3600 / 60,
						(ctx->dwTimeRemain / 1000) % 60);
				sprintf(szTimeLeft,   
						"%02d:%02d:%02d", 
						(ctx->dwTimeLeft / 1000) / 3600,
						(ctx->dwTimeLeft / 1000) % 3600 / 60,
						(ctx->dwTimeLeft / 1000) % 60);
				
				Static_SetText(GetDlgItem(ctx->hWaitDlg, IDC_TIMEREMAIN), szTimeRemain); 
				Static_SetText(GetDlgItem(ctx->hWaitDlg, IDC_TIMELEFT), szTimeLeft); 
				_ResizeStatic(GetDlgItem(ctx->hWaitDlg, IDC_TIMEREMAIN), szTimeRemain);
				_ResizeStatic(GetDlgItem(ctx->hWaitDlg, IDC_TIMELEFT), szTimeLeft); 
	
			} 
			else
			{
				ctx->dwLastTime = GetTickCount();
			}

		}
		break;


    case WM_COMMAND:
        {
			if (ctx->fnWaitDlg) 
			{
				int nResult;
				switch(LOWORD(wParam)) 
				{
					case IDCANCEL:
						nResult = ctx->fnWaitDlg(ctx, WDN_BTNCLICK, WDC_CANCEL);
						break;
					case IDPAUSE:
						ctx->bPause = !ctx->bPause;
						if (ctx->bPause)
						{
							Animate_Stop(GetDlgItem(hDlg, IDC_ANIMATE));
							RtkGuiWDSetBtnText(ctx, IDPAUSE, "继续");
							nResult = ctx->fnWaitDlg(ctx, WDN_BTNCLICK, WDC_PAUSE);
						}
						else
						{
							Animate_Play(GetDlgItem(hDlg, IDC_ANIMATE), 0, -1, -1,);
							RtkGuiWDSetBtnText(ctx, IDPAUSE, "暂停");
							nResult = ctx->fnWaitDlg(ctx, WDN_BTNCLICK, WDC_RESUME);
						}
						break;
				}
				// 从用户回调函数如果返回-1,则删除此对话框
				if (nResult == -1) {
					SendMessage(ctx->hWaitDlg, WM_DESTROY, 0, 0);
				}
                
            }
			else 
			{
				switch(wParam)
				{
					case IDCANCEL:
						ctx->uLastPushBtn |= WDC_CANCEL;
						break;
					case IDPAUSE:
						ctx->bPause = !ctx->bPause;
						
						if (ctx->bPause)
						{
							Animate_Stop(GetDlgItem(hDlg, IDC_ANIMATE));
							RtkGuiWDSetBtnText(ctx, IDPAUSE, "继续");
							ctx->uLastPushBtn |= WDC_PAUSE;
						}
						else
						{
							Animate_Play(GetDlgItem(hDlg, IDC_ANIMATE), 0, -1, -1,);
							RtkGuiWDSetBtnText(ctx, IDPAUSE, "暂停");
							ctx->uLastPushBtn |= WDC_RESUME;
						}
				
						break;
				}
            }
		}