Beispiel #1
1
void nt_settings_menu()
{
InstHandle=GetModuleHandle(NULL);
if(DialogBox(InstHandle,"DosBox",NULL,(FARPROC)DosDlgProc) == -1)
   DbgPrint("DialogBox() failed\n");
}
Beispiel #2
0
/*
 * Construct the proxy options to append to the cmd-line.
 */
void ConstructProxyCmdLine(char *proxy_string_ptr, unsigned int size)
{
  char proxy_string[100];

  CLEAR(proxy_string);

  if (o.proxy_source == PROXY_SOURCE_MANUAL)
    {
      if (o.proxy_type == PROXY_TYPE_HTTP)
        {
          if (o.proxy_http_auth == PROXY_HTTP_ASK_AUTH)
            {
              /* Ask for Proxy username/password */
              DialogBox(o.hInstance, (LPCTSTR)IDD_PROXY_AUTH, NULL, (DLGPROC)ProxyAuthDialogFunc);
              mysnprintf(proxy_string, "--http-proxy %s %s %s",
                         o.proxy_http_address,
                         o.proxy_http_port,
                         o.proxy_authfile);
            }
          else
            {
              mysnprintf(proxy_string, "--http-proxy %s %s",
                         o.proxy_http_address,
                         o.proxy_http_port);
            }
        }
      if (o.proxy_type == PROXY_TYPE_SOCKS)
        {
          mysnprintf(proxy_string, "--socks-proxy %s %s",
                     o.proxy_socks_address,
                     o.proxy_socks_port);
        }
    }

  if (o.proxy_source == PROXY_SOURCE_IE)
    {
      LPCTSTR ieproxy;
      char *pos;

      ieproxy = getIeHttpProxy();
      if (!ieproxy)
        {
          /* can't get ie proxy settings */
          ShowLocalizedMsg(GUI_NAME, ERR_GET_IE_PROXY_SETTINGS, getIeHttpProxyError);
        }
      else
        {
          /* Don't use a proxy if IE proxy string is empty */
          if (strlen(ieproxy) > 1)
            {
              /* Parse the port number from the IE proxy string */
              if ((pos = strchr(ieproxy, ':')))
                {
                  *pos = '\0';
                  if (o.proxy_http_auth == PROXY_HTTP_ASK_AUTH)
                    {
                      /* Ask for Proxy username/password */
                      DialogBox(o.hInstance, (LPCTSTR)IDD_PROXY_AUTH, NULL, (DLGPROC)ProxyAuthDialogFunc);
                      mysnprintf(proxy_string, "--http-proxy %s %s %s", 
                                 ieproxy, pos+1, o.proxy_authfile)
                    }
                  else
                    {
                      mysnprintf(proxy_string, "--http-proxy %s %s", ieproxy, pos+1)
                    }
                }
bool
WAO_InputDlg::launch( HWND hWPar, DLGPROC redirProc )
{
    DialogBox( GetModuleHandle( NULL ), MAKEINTRESOURCE( WAO_IDD_INPUT ), hWPar, redirProc );
    return m_result;
}
Beispiel #4
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int                    wmId, wmEvent;
    PAINTSTRUCT            ps;
    HDC                    hdc;
    RECT                rc;
    TCHAR                WndText[MAX_PATH];
    DWORD                Index;
    NONCLIENTMETRICS    ncm;
    HFONT                hFont;

    switch (message)
    {
    case WM_CREATE:

        hEditWnd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_AUTOHSCROLL|ES_LEFT|ES_MULTILINE, 0, 0, 0, 0, hWnd, NULL, hInst, NULL);
        hDisplayWnd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE, 0, 0, 0, 0, hWnd, NULL, hInst, NULL);

        memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
        ncm.cbSize = sizeof(NONCLIENTMETRICS);
        SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);

        hFont = CreateFontIndirect(&ncm.lfMessageFont);

        SendMessage(hEditWnd, WM_SETFONT, (WPARAM)hFont, TRUE);
        SendMessage(hDisplayWnd, WM_SETFONT, (WPARAM)hFont, TRUE);

        break;
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);

        if (lParam == (LPARAM)hEditWnd && wmEvent == EN_CHANGE)
        {
            GetWindowText(hEditWnd, WndText, MAX_PATH);

            if (_tcslen(WndText) > 0)
            {
                SetWindowText(hEditWnd, TEXT(""));

                if (!bConnected)
                {
                    MessageBox(hWnd, TEXT("You are not currently connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
                    break;
                }

                for (Index=0; Index<_tcslen(WndText); Index++)
                {
                    if (dwThreadId != 0)
                    {
                        PostThreadMessage(dwThreadId, WM_CHAR, (WPARAM)WndText[Index], (LPARAM)0);
                    }
                }
            }
        }

        // 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 IDM_FILE_CLEARDISPLAY:
            SetWindowText(hDisplayWnd, TEXT(""));
            break;
        case IDM_FILE_CONNECT:
            if (bConnected)
            {
                MessageBox(hWnd, TEXT("You are already connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
            }
            else
            {
                if (DialogBox(hInst, (LPCTSTR)IDD_CONNECTION, hWnd, (DLGPROC)ConnectionDialogProc) == IDOK)
                {
                    bConnected = TRUE;
                    EnableFileMenuItemByID(IDM_FILE_DISCONNECT, TRUE);
                    EnableFileMenuItemByID(IDM_FILE_CONNECT, FALSE);
                    _beginthread(Rs232Thread, 0, NULL);
                }
            }
            break;
        case IDM_FILE_DISCONNECT:
            if (bConnected)
            {
                bConnected = FALSE;
                EnableFileMenuItemByID(IDM_FILE_DISCONNECT, FALSE);
                EnableFileMenuItemByID(IDM_FILE_CONNECT, TRUE);
            }
            else
            {
                MessageBox(hWnd, TEXT("You are not currently connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
            }
            break;
        case IDM_FILE_STARTCAPTURE:
            if (DialogBox(hInst, (LPCTSTR)IDD_CAPTURE, hWnd, (DLGPROC)CaptureDialogProc) == IDOK)
            {
                bCapturing = TRUE;
                EnableFileMenuItemByID(IDM_FILE_STOPCAPTURE, TRUE);
                EnableFileMenuItemByID(IDM_FILE_STARTCAPTURE, FALSE);
                hCaptureFile = CreateFile(strCaptureFileName, FILE_APPEND_DATA, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
            }
            break;
        case IDM_FILE_STOPCAPTURE:
            if (bCapturing)
            {
                bCapturing = FALSE;
                EnableFileMenuItemByID(IDM_FILE_STOPCAPTURE, FALSE);
                EnableFileMenuItemByID(IDM_FILE_STARTCAPTURE, TRUE);
                CloseHandle(hCaptureFile);
                hCaptureFile = NULL;
            }
            break;
        case IDM_FILE_LOCALECHO:
            if (bLocalEcho)
            {
                bLocalEcho = FALSE;
                CheckLocalEchoMenuItem(bLocalEcho);
            }
            else
            {
                bLocalEcho = TRUE;
                CheckLocalEchoMenuItem(bLocalEcho);
            }
            break;
        default:
           return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        (void)hdc; // FIXME
        EndPaint(hWnd, &ps);
        break;
    case WM_SIZE:

        GetClientRect(hWnd, &rc);

        MoveWindow(hDisplayWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top - 20, TRUE);
        MoveWindow(hEditWnd, rc.left, rc.bottom - 20, rc.right - rc.left, 20, TRUE);

        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #5
0
static VOID
MainWndCommand(PMAIN_WND_INFO Info,
               WORD CmdId,
               HWND hControl)
{
    UNREFERENCED_PARAMETER(hControl);

    switch (CmdId)
    {
        case ID_PROP:
        {
            if (Info->SelectedItem != NO_ITEM_SELECTED)
            {
                Info->bDlgOpen = TRUE;
                OpenPropSheet(Info);
                Info->bDlgOpen = FALSE;
                SetMenuAndButtonStates(Info);
            }
        }
        break;

        case ID_REFRESH:
        {
            RefreshServiceList(Info);
            Info->SelectedItem = NO_ITEM_SELECTED;

            /* disable menus and buttons */
            SetMenuAndButtonStates(Info);

            /* clear the service in the status bar */
            SendMessage(Info->hStatus,
                        SB_SETTEXT,
                        1,
                        _T('\0'));
        }
        break;

        case ID_EXPORT:
        {
            ExportFile(Info);
            SetFocus(Info->hListView);
        }
        break;

        case ID_CREATE:
        {
            INT ret;

            ret = DialogBoxParam(hInstance,
                                 MAKEINTRESOURCE(IDD_DLG_CREATE),
                                 Info->hMainWnd,
                                 CreateDialogProc,
                                 (LPARAM)Info);
            if (ret == IDOK)
                RefreshServiceList(Info);

            SetFocus(Info->hListView);
        }
        break;

        case ID_DELETE:
        {
            if (Info->pCurrentService->ServiceStatusProcess.dwCurrentState != SERVICE_RUNNING)
            {
                DialogBoxParam(hInstance,
                               MAKEINTRESOURCE(IDD_DLG_DELETE),
                               Info->hMainWnd,
                               DeleteDialogProc,
                               (LPARAM)Info);
            }
            else
            {
                TCHAR Buf[60];
                LoadString(hInstance,
                           IDS_DELETE_STOP,
                           Buf,
                           sizeof(Buf) / sizeof(TCHAR));
                DisplayString(Buf);
            }

            SetFocus(Info->hListView);

        }
        break;

        case ID_START:
        {
            if (DoStart(Info, NULL))
            {
                UpdateServiceStatus(Info->pCurrentService);
                ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
                SetMenuAndButtonStates(Info);
                SetFocus(Info->hListView);
            }
        }
        break;

        case ID_STOP:
            if (DoStop(Info))
            {
                UpdateServiceStatus(Info->pCurrentService);
                ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
                SetMenuAndButtonStates(Info);
                SetFocus(Info->hListView);
            }
        break;

        case ID_PAUSE:
            DoPause(Info);
        break;

        case ID_RESUME:
            DoResume(Info);
        break;

        case ID_RESTART:
            if (DoStop(Info))
            {
                DoStart(Info, NULL);
                UpdateServiceStatus(Info->pCurrentService);
                ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
                SetMenuAndButtonStates(Info);
                SetFocus(Info->hListView);
            }
        break;

        case ID_HELP:
            MessageBox(NULL,
                       _T("Help is not yet implemented\n"),
                       _T("Note!"),
                       MB_OK | MB_ICONINFORMATION);
            SetFocus(Info->hListView);
        break;

        case ID_EXIT:
            PostMessage(Info->hMainWnd,
                        WM_CLOSE,
                        0,
                        0);
        break;

        case ID_VIEW_LARGE:
            SetListViewStyle(Info->hListView,
                             LVS_ICON);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_LARGE,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_SMALL:
            SetListViewStyle(Info->hListView,
                             LVS_SMALLICON);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_SMALL,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_LIST:
            SetListViewStyle(Info->hListView,
                             LVS_LIST);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_LIST,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_DETAILS:
            SetListViewStyle(Info->hListView,
                             LVS_REPORT);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_DETAILS,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_CUST:
        break;

        case ID_ABOUT:
            DialogBox(hInstance,
                      MAKEINTRESOURCE(IDD_ABOUTBOX),
                      Info->hMainWnd,
                      AboutDialogProc);
            SetFocus(Info->hListView);
        break;

    }
}
/*
 * DownloadFiles:  Bring up download dialog.
 */
void DownloadFiles(DownloadInfo *params)
{
   int retval, dialog, i;

   info = params;
   info->current_file = 0;
   MainSetState(STATE_DOWNLOAD);

   debug(("machine = %s\n", info->machine));
   debug(("path = %s\n", info->path));
   for (i = 0; i < info->num_files; i++)
      debug(("file = %s, time = %d, flags = %d\n", 
	     info->files[i].filename, info->files[i].time, info->files[i].flags));

   // If downloading only advertisements, show a different dialog to avoid the appearance
   // of a "real" download.
   dialog = IDD_DOWNLOADAD;
   for (i = 0; i < info->num_files; i++)
      if (DownloadLocation(info->files[i].flags) != DF_ADVERTISEMENT)
      {
         dialog = IDD_DOWNLOAD;
         break;
      }

   advert = (IDD_DOWNLOADAD == dialog);
   if (!advert  && !config.avoidDownloadAskDialog)
   {
      retval = DialogBox(hInst, MAKEINTRESOURCE(IDD_ASKDOWNLOAD), NULL, AskDownloadDialogProc);
      switch (retval) {
      case 3: // do the demo button
         WebLaunchBrowser(info->demoPath);
         SendMessage(hMain,WM_SYSCOMMAND,SC_CLOSE,0);
         return;
      case IDOK: // proceed with download
         retval = DialogBox(hInst, MAKEINTRESOURCE(dialog), NULL, DownloadDialogProc);
         advert = FALSE;
         if (retval == IDOK)
         {
            MainSetState(STATE_LOGIN);
            i = (((MAJOR_REV * 100) + MINOR_REV) * P_CATCH) + P_CATCH;
            RequestGame(config.download_time,i,config.comm.hostname);
            return;
         }
         break;
      case IDCANCEL: // cancel
      default:
         break;
      }
   }
   abort_download = True;
   config.quickstart = FALSE;
   //MainSetState(STATE_OFFLINE);
   Logoff();
   ShowWindow(hMain, SW_SHOW);
   UpdateWindow(hMain);

#if 0
   // If we were hung up, just leave
   if (state != STATE_DOWNLOAD)
      return;
   
   MainSetState(STATE_LOGIN);

   switch (retval)
   {
   case IDOK:
      RequestGame(config.download_time);
      break;

   case IDCANCEL:
      Logoff();
      break;
   }
#endif
}
Beispiel #7
0
FORCE_INLINE int NSISCALL ui_doinstall(void)
{
  header *header = g_header;
  static WNDCLASS wc; // richedit subclassing and bgbg creation

  // detect default language
  // more information at:
  //   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_0xrn.asp

  LANGID (WINAPI *GUDUIL)();

  GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage);
  if (GUDUIL)
  {
    // Windows ME/2000+
    myitoa(state_language, GUDUIL());
  }
  else
  {
    static const TCHAR reg_9x_locale[]     = _T("Control Panel\\Desktop\\ResourceLocale");
    static const TCHAR reg_nt_locale_key[] = _T(".DEFAULT\\Control Panel\\International");
    const TCHAR       *reg_nt_locale_val   = &reg_9x_locale[30]; // = _T("Locale") with opt

    *(DWORD*)state_language = CHAR4_TO_DWORD(_T('0'), _T('x'), 0, 0);

    {
      // Windows 9x
      myRegGetStr(HKEY_CURRENT_USER, reg_9x_locale, NULL, g_tmp, 0);
    }

    if (!g_tmp[0])
    {
      // Windows NT
      // This key exists on 9x as well, so it's only read if ResourceLocale wasn't found
      myRegGetStr(HKEY_USERS, reg_nt_locale_key, reg_nt_locale_val, g_tmp, 0);
    }

    mystrcat(state_language, g_tmp);
  }

  // set default language
  set_language();

  // initialize auto close flag
  g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE;

#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
  // initialize plugin api
  g_exec_flags.plugin_api_version=NSISPIAPIVER_CURR;
#endif

  // read install directory from registry
  if (!is_valid_instpath(state_install_directory))
  {
    if (header->install_reg_key_ptr)
    {
      myRegGetStr(
        (HKEY)header->install_reg_rootkey,
        GetNSISStringNP(header->install_reg_key_ptr),
        GetNSISStringNP(header->install_reg_value_ptr),
        ps_tmpbuf,
        0
      );
      if (ps_tmpbuf[0])
      {
        TCHAR *p=ps_tmpbuf;
        TCHAR *e;
        if (p[0]==_T('\"'))
        {
          TCHAR *p2;
          p++;
          p2 = findchar(p, _T('"'));
          *p2 = 0;
        }
        // p is the path now, check for .exe extension

        e=p+mystrlen(p)-4;
        if (e > p)
        {
          // if filename ends in .exe, and is not a directory, remove the filename
          if (!lstrcmpi(e, _T(".exe"))) // check extension
          {
            DWORD d;
            d=GetFileAttributes(p);
            if (d == INVALID_FILE_ATTRIBUTES || !(d&FILE_ATTRIBUTE_DIRECTORY))
            {
              // if there is no back-slash, the string will become empty, but that's ok because
              // it would make an invalid instdir anyway
              trimslashtoend(p);
            }
          }
        }

        mystrcpy(state_install_directory,addtrailingslash(p));
      }
    }
  }
  if (!is_valid_instpath(state_install_directory))
  {
    GetNSISString(state_install_directory,header->install_directory_ptr);
  }

#ifdef NSIS_CONFIG_LOG
  if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller)
  {
#if !defined(NSIS_CONFIG_LOG_ODS) && !defined(NSIS_CONFIG_LOG_STDOUT)
    build_g_logfile();
#endif
    log_dolog=1;
  }
#endif

#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
  g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED);
#ifdef NSIS_SUPPORT_BGBG
  if (header->bg_color1 != -1)
  {
    DWORD cn = CHAR4_TO_DWORD(_T('_'), _T('N'), _T('b'), 0);
    RECT vp;
    extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM);
    wc.lpfnWndProc = BG_WndProc;
    wc.hInstance = g_hInstance;
    wc.hIcon = g_hIcon;
    //wc.hCursor = LoadCursor(NULL,IDC_ARROW);
    wc.lpszClassName = (LPCTSTR)&cn;

    if (!RegisterClass(&wc)) return 0;

    SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);

    m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,(LPCTSTR)&cn,0,WS_POPUP,
      vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL);
  }

#endif//NSIS_SUPPORT_BGBG

#endif//NSIS_CONFIG_VISIBLE_SUPPORT

#ifdef NSIS_SUPPORT_CODECALLBACKS
  // Select language
  if (ExecuteCallbackFunction(CB_ONINIT)) return 2;
  set_language();
#endif

#ifdef NSIS_CONFIG_VISIBLE_SUPPORT

#ifdef NSIS_CONFIG_SILENT_SUPPORT
  if (!g_exec_flags.silent)
#endif//NSIS_CONFIG_SILENT_SUPPORT
  {
#ifdef NSIS_SUPPORT_BGBG
    ShowWindow(m_bgwnd, SW_SHOW);
#endif//NSIS_SUPPORT_BGBG

#ifdef NSIS_CONFIG_LICENSEPAGE
    { // load richedit DLL
      static const TCHAR riched20[]=_T("RichEd20");
      static const TCHAR riched32[]=_T("RichEd32");
      static const TCHAR richedit20a[]=_T("RichEdit20A");
      static const TCHAR richedit[]=_T("RichEdit");
      if (!LoadLibrary(riched20))
      {
        LoadLibrary(riched32);
      }

      // make richedit20a point to RICHEDIT
      if (!GetClassInfo(NULL,richedit20a,&wc))
      {
        GetClassInfo(NULL,richedit,&wc);
        wc.lpszClassName = richedit20a;
        RegisterClass(&wc);
      }
    }
#endif

    {
      int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc);
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
      ExecuteCallbackFunction(CB_ONGUIEND);
#endif
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
      Plugins_SendMsgToAllPlugins(NSPIM_GUIUNLOAD);
#endif
      return ret;
    }
  }
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
#ifdef NSIS_CONFIG_SILENT_SUPPORT
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
  else
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
  {
    if (install_thread(NULL))
    {
#ifdef NSIS_SUPPORT_CODECALLBACKS
      if (!g_quit_flag) ExecuteCallbackFunction(CB_ONINSTFAILED);
#endif//NSIS_SUPPORT_CODECALLBACKS
      return 2;
    }
#ifdef NSIS_SUPPORT_CODECALLBACKS
    ExecuteCallbackFunction(CB_ONINSTSUCCESS);
#endif//NSIS_SUPPORT_CODECALLBACKS

    return 0;
  }
#endif//NSIS_CONFIG_SILENT_SUPPORT
}
int	WINAPI WKInitRecording(HWND hParent)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if(!pInter){
		AfxMessageBox("Container not found!!!");
		return 0;
	}
	if(hMacroRecControlWindow!=0){
		AfxMessageBox(_pl("To record new macro, You have to stop\nrecording previous macro"));
		return 0;
	}
	static long lMacroCounter=1;
	plgOptions.sLastMacroName="";
	COleDateTime dt=COleDateTime::GetCurrentTime();
	plgOptions.sLastMacroName.Format("%s (%02lu.%02lu.%04lu)",GetRandomName(),dt.GetDay(),dt.GetMonth(),dt.GetYear());
	lMacroCounter++;
	char szPrefFolder[MAX_PATH]="";
	pInter->GetPreferencesFolder(szPrefFolder,sizeof(szPrefFolder));
	CString sTargetFile=szPrefFolder;
	sTargetFile+="RecorderMacro\\";
	if(int(GetFileAttributes(sTargetFile))==-1){
		::CreateDirectory(sTargetFile,NULL);
	}
	plgOptions.sLastMacroContent="";
	DWORD dwStart=GetTickCount();
	ATOM at=GlobalAddAtom("WK_RECORDING");
	DWORD dwRes=DialogBox(WKGetPluginContainer()->GetPluginDllInstance(),MAKEINTRESOURCE(IDD_OPTIONS),hParent,OptionsDialogProc);
	if(!WKUtils::isWKUpAndRunning()){
		return 0;
	}
	GlobalDeleteAtom(at);
	if(dwRes!=0){
		// Пользователь отказался...
		return 0;
	}
	if(pInter){
		pInter->PushMyOptions(0);
	}
	if(plgOptions.sLastMacroContent==""){
		return 0;
	}
	CString sMacroFileNm=plgOptions.sLastMacroName;
	MakeSafeFileName(sMacroFileNm);
	sTargetFile+=sMacroFileNm;
	sTargetFile+=".wkm";
	// Добавлять иконку на время записи макроса
	// Префикс макроса...
	CString sMacroTemplate=	"// Language: %s\r\n"\
							"// Title: %s\r\n"\
							"// Description: Recorded macro\r\n"\
							"// ParamType: String\r\n"\
							"// Hint: wait_for_key_release;\r\n\r\n"\
							"%s"\
							"%s"\
							"\r\n"\
							"// <wkMain>: Action\r\n"\
							"function wkMain()\r\n"\
							"{// wkMain description: Replay keystrokes\r\n"\
							"%s"\
							"};\r\n"\
							"// </wkMain>: End of Action\r\n"\
							"\r\n";
	CString sDopFunc=		(plgOptions.lMFormat==0 || plgOptions.lMFormat==1 || plgOptions.lMFormat==3)?"":"// System object that will be used to replay recorded keystrokes\r\nvar WshShell = new ActiveXObject('WScript.Shell');\r\n";
	sDopFunc+=				"// Playback Speed ratio ('1' means as recorded)\r\n";
	sDopFunc+=				"var iMacroSpeed = 1.0;";
	sDopFunc+=				"\r\n";
	CString sWaitFunc=		(plgOptions.lMFormat==0 || plgOptions.lMFormat==1 || plgOptions.lMFormat==3)?"":"function Wait(time)\r\n"\
							"{\r\n"\
							"	var d = new Date();\r\n"\
							"	var timeCounter = 0;\r\n"\
							"	while((new Date()).getSeconds()-d.getSeconds()<(time*iMacroSpeed)){\r\n"\
							"		timeCounter++;\r\n"\
							"	};\r\n"\
							"}\r\n";
	plgOptions.sLastMacroContent=Format(sMacroTemplate,(plgOptions.lMFormat==0 || plgOptions.lMFormat==1 || plgOptions.lMFormat==3)?"JScript":"JScript",plgOptions.sLastMacroName,sDopFunc,(plgOptions.bRecPauses?sWaitFunc:""),plgOptions.sLastMacroContent);
	DWORD dwStop=GetTickCount();
	CString sTime;
	sTime.Format("%.2f",double(dwStop-dwStart)/1000);
	int iRes=::MessageBox(NULL,_pl("Macro recorded")+"!\n"+_pl("Duration")+": "+sTime+_pl("sec")+". "+_pl("Continue")+"?",_pl("Macro successfully recorded")+"!",IDOK);
	if(iRes==IDOK){
		SaveFile(sTargetFile,plgOptions.sLastMacroContent);
		if(plgOptions.bAP_Add2WK && pInter){
			pInter->AddQrunFromFile(sTargetFile);
		}
		if(plgOptions.bAP_OpenInEd && pInter){
			int iRes=(int)::ShellExecute(NULL,"open","notepad.exe",CString("\"")+sTargetFile+CString("\""),NULL,SW_SHOWNORMAL);
		}
	}
	return 1;
}
Beispiel #9
0
INT dlgAbout_Show(HWND hWndParent)
{
    DialogBox( (HINSTANCE)GetWindowLong( hWndParent, GWL_HINSTANCE ),
               MAKEINTRESOURCE(IDD_DLG_ABOUT), hWndParent, (DLGPROC)dlgAboutProc );
    return 0;
}
Beispiel #10
0
void OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD(wParam))
	{
		case IDM_STARTSERVICE:
		{
			//开始服务器
			DWORD	dwIP = 0;
			int		nPort = 0;

			g_fTerminated = FALSE;
		
			//初始化等待ip
			ENGINE_COMPONENT_INFO info = g_SeverConfig.getLoginGateInfo();
			
			nPort = info.extport?info.extport:7000;

			
			//初始化完成端口
			InitServerSocket(g_ssock, &g_saddr, _IDM_SERVERSOCK_MSG, nPort, FD_ACCEPT);

			//初始化等待ip
			ENGINE_COMPONENT_INFO loginsrvinfo = g_SeverConfig.getLoginSrvInfo();

			nPort = loginsrvinfo.intport?loginsrvinfo.intport:5500;

			//连接loginsrv
			ConnectToServer(g_csock, &g_caddr, _IDM_CLIENTSOCK_MSG, loginsrvinfo.intip.c_str(), dwIP, nPort, FD_CONNECT|FD_READ|FD_CLOSE);

			HMENU hMainMenu = GetMenu(g_hMainWnd);
			HMENU hMenu = GetSubMenu(hMainMenu, 0);

			EnableMenuItem(hMenu, IDM_STARTSERVICE, MF_GRAYED|MF_BYCOMMAND);
			EnableMenuItem(hMenu, IDM_STOPSERVICE, MF_ENABLED|MF_BYCOMMAND);

			SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDM_STARTSERVICE, (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
			SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDM_STOPSERVICE, (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));

			InsertLogMsg(IDS_STARTSERVICE);

			SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(0, 0), (LPARAM)_TEXT("Ready"));

			return;
		}
		case IDM_STOPSERVICE:
		{
			g_fTerminated = TRUE;

/*			if (g_hAcceptThread != INVALID_HANDLE_VALUE)
			{
				TerminateThread(g_hAcceptThread, 0);
				WaitForSingleObject(g_hAcceptThread, INFINITE);
				CloseHandle(g_hAcceptThread);
				g_hAcceptThread = INVALID_HANDLE_VALUE;
			}

			if (g_hMsgThread != INVALID_HANDLE_VALUE)
			{
				TerminateThread(g_hMsgThread, 0);
				WaitForSingleObject(g_hMsgThread, INFINITE);
				CloseHandle(g_hMsgThread);
				g_hMsgThread = INVALID_HANDLE_VALUE;
			}
*/
			ClearSocket(g_ssock);
			ClearSocket(g_csock);

			CloseHandle(g_hIOCP);

			HMENU hMainMenu = GetMenu(g_hMainWnd);
			HMENU hMenu = GetSubMenu(hMainMenu, 0);

			EnableMenuItem(hMenu, IDM_STARTSERVICE, MF_ENABLED|MF_BYCOMMAND);
			EnableMenuItem(hMenu, IDM_STOPSERVICE, MF_GRAYED|MF_BYCOMMAND);

			SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDM_STARTSERVICE, (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
			SendMessage(g_hToolBar, TB_SETSTATE, (WPARAM)IDM_STOPSERVICE, (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));

			InsertLogMsg(IDS_STOPSERVICE);

			SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(0, 0), (LPARAM)_TEXT("Not Ready"));

			return;
		}
		// ORZ:
		case IDM_FONTCOLOR:
			SetFontColor();
			return;
		case IDM_BACKCOLOR:
			SetBackColor();
			return;
		case IDM_CONFIG:
		{
			DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CONFIGDLG), g_hMainWnd, (DLGPROC)ConfigDlgFunc);

			return;
		}
	}
}
int	WINAPI RecordMacro(BOOL bJScript, HWND hParent, const char* szFileOut)
{
	__FLOWLOG
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	COleDateTime dt=COleDateTime::GetCurrentTime();
	if(dt.GetMonth()!=4){
		AfxMessageBox("This is demo version of macro recorder.\nContact WiredPlane.com for full version");
		return 0;
	}
	if(hMacroRecControlWindow!=0){
		AfxMessageBox("To record new macro, You have to stop\nrecording previous macro");
		return 0;
	}
	hwndDlgBeforeActive=GetForegroundWindow();
	static long lMacroCounter=1;
	plgOptions.sLastMacroContent="";
	DWORD dwStart=GetTickCount();
	plgOptions.lMFormat=bJScript?2:0;
	plgOptions.bRecPauses=1;
	plgOptions.bAppSwitchesRTyp=0;
	plgOptions.lPauseLevel=1;
	plgOptions.bAppSwitchesRTyp=0;
	bSkipPreparations=1;
	ATOM at=GlobalAddAtom("WK_RECORDING");
	{
		__FLOWLOG
		DWORD dwRes=DialogBox(WKGetPluginContainer()->GetPluginDllInstance(),MAKEINTRESOURCE(IDD_OPTIONS),hParent,OptionsDialogProc);
	}
	if(!WKUtils::isWKUpAndRunning()){
		return 0;
	}
	GlobalDeleteAtom(at);
	if(plgOptions.sLastMacroContent==""){
		return 0;
	}
	CString sMacroTemplate=	"// Language: %s\r\n"\
							"// Title: %s\r\n"\
							"// Description: Recorded macro\r\n"\
							"// ParamType: String\r\n\r\n"\
							"%s"\
							"%s"\
							"\r\n"\
							"// <wkMain>: Action\r\n"\
							"function wkMain()\r\n"\
							"{// wkMain description: Replay keystrokes\r\n"\
							"%s"\
							"};\r\n"\
							"// </wkMain>: End of Action\r\n"\
							"\r\n";
	CString sDopFunc=		(plgOptions.lMFormat==0 || plgOptions.lMFormat==1 || plgOptions.lMFormat==3)?"":"// System object that will be used to replay recorded keystrokes\r\nvar WshShell = new ActiveXObject('WScript.Shell');\r\n";
	sDopFunc+=				"// Playback Speed ratio ('1' means as recorded)\r\n";
	sDopFunc+=				"var iMacroSpeed = 1.0;";
	sDopFunc+=				"\r\n";
	CString sWaitFunc=		(plgOptions.lMFormat==0 || plgOptions.lMFormat==1 || plgOptions.lMFormat==3)?"":"function Wait(time)\r\n"\
							"{\r\n"\
							"	var d = new Date();\r\n"\
							"	var timeCounter = 0;\r\n"\
							"	while((new Date()).getSeconds()-d.getSeconds()<(time*iMacroSpeed)){\r\n"\
							"		timeCounter++;\r\n"\
							"	};\r\n"\
							"}\r\n";
	plgOptions.sLastMacroContent=Format(sMacroTemplate,(plgOptions.lMFormat==0 || plgOptions.lMFormat==1 || plgOptions.lMFormat==3)?"JScript":"JScript",plgOptions.sLastMacroName,sDopFunc,(plgOptions.bRecPauses?sWaitFunc:""),plgOptions.sLastMacroContent);
	DWORD dwStop=GetTickCount();
	SaveFile(szFileOut,plgOptions.sLastMacroContent);
	return 1;
}
Beispiel #12
0
__forceinline int NSISCALL ui_doinstall(void)
{
  header *header = g_header;
  static WNDCLASS wc; // richedit subclassing and bgbg creation
  g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE;

  set_language();

  if (!is_valid_instpath(state_install_directory))
  {
    if (header->install_reg_key_ptr)
    {
      myRegGetStr(
        (HKEY)header->install_reg_rootkey,
        GetNSISStringNP(header->install_reg_key_ptr),
        GetNSISStringNP(header->install_reg_value_ptr),
        ps_tmpbuf
      );
      if (ps_tmpbuf[0])
      {
        char *p=ps_tmpbuf;
        char *e;
        if (p[0]=='\"')
        {
          char *p2=CharNext(p);
          p=p2;
          while (*p2 && *p2 != '\"') p2=CharNext(p2);
          *p2=0;
        }
        // p is the path now, check for .exe extension

        e=p+mystrlen(p)-4;
        if (e > p)
        {
          // if filename ends in .exe, and is not a directory, remove the filename
          if (!lstrcmpi(e, ".exe")) // check extension
          {
            DWORD d;
            d=GetFileAttributes(p);
            if (d == (DWORD)-1 || !(d&FILE_ATTRIBUTE_DIRECTORY))
            {
              // if there is no back-slash, the string will become empty, but that's ok because
              // it would make an invalid instdir anyway
              trimslashtoend(p);
            }
          }
        }

        mystrcpy(state_install_directory,p);
      }
    }
  }
  if (!is_valid_instpath(state_install_directory))
  {
    GetNSISString(state_install_directory,header->install_directory_ptr);
  }

#ifdef NSIS_CONFIG_LOG
  if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller)
  {
#ifndef NSIS_CONFIG_LOG_ODS
    build_g_logfile();
#endif
    log_dolog=1;
  }
#endif

#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
  g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED);
#ifdef NSIS_SUPPORT_BGBG
  if (header->bg_color1 != -1)
  {
    RECT vp;
    extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM);
    wc.lpfnWndProc = BG_WndProc;
    wc.hInstance = g_hInstance;
    wc.hIcon = g_hIcon;
    //wc.hCursor = LoadCursor(NULL,IDC_ARROW);
    wc.lpszClassName = "_Nb";

    if (!RegisterClass(&wc)) return 0;

    SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);

    m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,"_Nb",0,WS_POPUP,
      vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL);
  }

#ifdef NSIS_SUPPORT_CODECALLBACKS
  g_hwnd=m_bgwnd;
#endif//NSIS_SUPPORT_CODECALLBACKS

#endif//NSIS_SUPPORT_BGBG

#endif//NSIS_CONFIG_VISIBLE_SUPPORT

#ifdef NSIS_SUPPORT_CODECALLBACKS
  // Select language
  if (ExecuteCodeSegment(header->code_onInit,NULL)) return 1;
  set_language();
#endif

#ifdef NSIS_CONFIG_VISIBLE_SUPPORT

#ifdef NSIS_SUPPORT_CODECALLBACKS
#ifdef NSIS_SUPPORT_BGBG
  g_hwnd=NULL;
#endif//NSIS_SUPPORT_BGBG
#endif//NSIS_SUPPORT_CODECALLBACKS

#ifdef NSIS_CONFIG_SILENT_SUPPORT
  if (!g_exec_flags.silent)
#endif//NSIS_CONFIG_SILENT_SUPPORT
  {
#ifdef NSIS_SUPPORT_BGBG
    ShowWindow(m_bgwnd, SW_SHOW);
#endif//NSIS_SUPPORT_BGBG

#ifdef NSIS_CONFIG_LICENSEPAGE
    { // load richedit DLL
      static char str1[]="RichEd20.dll";
      static char str2[]="RichEdit20A";
      if (!LoadLibrary(str1))
      {
        *(WORD*)(str1+6) = CHAR2_TO_WORD('3','2');
        LoadLibrary(str1);
      }

      // make richedit20a point to RICHEDIT
      if (!GetClassInfo(NULL,str2,&wc))
      {
        str2[8]=0;
        GetClassInfo(NULL,str2,&wc);
        wc.lpszClassName = str2;
        str2[8]='2';
        RegisterClass(&wc);
      }
    }
#endif

    {
      int ret=DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc);
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
      ExecuteCodeSegment(header->code_onGUIEnd,NULL);
#endif
      return ret;
    }
  }
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
#ifdef NSIS_CONFIG_SILENT_SUPPORT
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
  else
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
  {
    if (install_thread(NULL))
    {
#ifdef NSIS_SUPPORT_CODECALLBACKS
      if (!g_quit_flag) ExecuteCodeSegment(header->code_onInstFailed,NULL);
#endif//NSIS_SUPPORT_CODECALLBACKS
      return 1;
    }
#ifdef NSIS_SUPPORT_CODECALLBACKS
    ExecuteCodeSegment(header->code_onInstSuccess,NULL);
#endif//NSIS_SUPPORT_CODECALLBACKS

    return 0;
  }
#endif//NSIS_CONFIG_SILENT_SUPPORT
}
Beispiel #13
0
//  A simple wrapper for running as specified dialog as modal, 
//  and returning the result.
INT_PTR RunDialog( int dlgId, DLGPROC proc )
{
  return DialogBox( appInstance_, MAKEINTRESOURCE(dlgId), 0, proc );
}
Beispiel #14
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)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			s_sai.cbSize = sizeof(SHACTIVATEINFO);
			hwndCB = CreateRpCommandBar(hWnd);
			break;
		case WM_PAINT:
		{
			hdc = BeginPaint(hWnd, &ps);

			HPEN hpen1, hpen2;
			HBRUSH hbr1, hbr2;

			hpen1 = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
			hpen2 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
			hbr1 = CreateSolidBrush(RGB(0, 255, 0));
			hbr2 = CreateSolidBrush(RGB(0, 255, 255));

			SelectObject(hdc, hpen1);
			POINT pt[2];
			pt[0].x = 10;
			pt[0].y = 10;
			pt[1].x = 110;
			pt[1].y = 10;
			Polyline(hdc, pt, 2);

			SelectObject(hdc, hbr1);
			Rectangle(hdc, 40, 40, 80, 80);

			SelectObject(hdc, hpen2);
			pt[0].x = 20;
			pt[0].y = 20;
			pt[1].x = 20;
			pt[1].y = 120;
			Polyline(hdc, pt, 2);

			SelectObject(hdc, hbr2);
			Rectangle(hdc, 100, 100, 150, 150);

			// Clean Up all objects created.
			SelectObject(hdc, GetStockObject(BLACK_PEN));
			SelectObject(hdc, GetStockObject(WHITE_BRUSH));
			DeleteObject(hpen1);
			DeleteObject(hpen2);
			DeleteObject(hbr1);
			DeleteObject(hbr2);
			EndPaint(hWnd, &ps);
		}
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #15
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int				wmId, wmEvent;
	PAINTSTRUCT		ps;
	HDC				hdc;

	switch (message)
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam);
			wmEvent = HIWORD(wParam);
			
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_ABOUT:
					DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
					break;

				case IDM_EXIT:
					DestroyWindow(hWnd);
					break;

				case OPENFRAME1:
				case OPENFRAME2:
					open_frame();
					break;

				case PREVFRAME:
					prev_frame();
					break;

				case NEXTFRAME:
					next_frame();
					break;

				case RESET:
					cur_frame = -1;
					cur_working_path[0] = '\0';
					InvalidateRect(g_hWnd, NULL, true);
					break;

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

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

			EndPaint(hWnd, &ps);
			break;

		case WM_DESTROY:
			DestroyWindow();
			PostQuitMessage(0);
			break;

		case WM_SYSCOMMAND:
			if (wParam == sys_menu_item_open)
			{
				open_frame();
				return false;
			}
			return DefWindowProc(hWnd, message, wParam, lParam);
			break;

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

	return 0;
}
Beispiel #16
0
// Window procedure for our main window.
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  static HINSTANCE hInstance;

  switch (msg)
  {  
    case WM_COMMAND:
    {
      switch (LOWORD(wParam))
      {
        case ID_HELP_ABOUT:
        {
          DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc);
          return 0;
        }

        case ID_FILE_EXIT:
        {
          DestroyWindow(hWnd);
          return 0;
        }
      }
      break;
    }

    case WM_GETMINMAXINFO:
    {
      MINMAXINFO *minMax = (MINMAXINFO*) lParam;
      minMax->ptMinTrackSize.x = 220;
      minMax->ptMinTrackSize.y = 110;

      return 0;
    }

    case WM_SYSCOMMAND:
    {
      switch (LOWORD(wParam))
      {
        case ID_HELP_ABOUT:
        {
          DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hWnd, &AboutDialogProc);
          return 0;
        }
      }
      break;
    }
    
    case WM_CREATE:
    {
      hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
      return 0;
    }

    case WM_DESTROY:
    {
      PostQuitMessage(0);
      return 0;
    }
  }

  return DefWindowProc(hWnd, msg, wParam, lParam);
}
Beispiel #17
0
BOOL SessionManagerProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
BOOL retval = FALSE;
int selItem;
char tmpName[SESSION_NAME_SIZE];
VuGameEntity* myGame;
static int theTimer;

   switch (message)
   {
      case WM_INITDIALOG:
         SetDlgItemText(hDlg, IDC_SESSION_NAME, F4SessionMemberName);
         SetDlgItemText(hDlg, IDC_SESSION_GROUP, F4SessionGameName);
         CheckDlgButton (hDlg, IDC_SESSION_ENABLE, F4SessionManagerOn ? BST_CHECKED : BST_UNCHECKED);
	      F4SessionManagerOn = TRUE;
			theTimer = SetTimer(hDlg,1,500,NULL);
     	break;

		case WM_TIMER:
         F4SessionUpdateGameList(hDlg);
         F4SessionUpdateMemberList(hDlg);
      break;

      case WM_COMMAND:                		/* message: received a command */
         switch (LOWORD(wParam))
         {
            case IDOK:
            case IDCANCEL:
               EndDialog(hDlg, TRUE);        /* Exits the dialog box        */
               retval = TRUE;
               KillTimer (hDlg, theTimer);
            break;

            case IDC_SESSION_ENABLE:
               if (IsDlgButtonChecked(hDlg, IDC_SESSION_ENABLE) == BST_CHECKED)
   					{
                  InitSessionStuff(hDlg);
                  F4SessionUpdateGameList(hDlg);
                  F4SessionUpdateMemberList(hDlg);
			         SetDlgItemText(hDlg, IDC_SESSION_NAME, F4SessionMemberName);
         			SetDlgItemText(hDlg, IDC_SESSION_GROUP, F4SessionGameName);
						}
               else
                  EndSessionStuff();
               retval = TRUE;
            break;

            case IDC_SESSION_CREATE_GROUP:
               retval = CreateNewGame(hDlg);
            break;

            case IDC_SESSION_CHANGE_NAME:
               NewBoxType = NEW_BOX_NAME;
               DialogBox(hInst,MAKEINTRESOURCE(IDD_SESSION_NEW),hDlg,(DLGPROC)SessionNewProc);
               if (dialogReturnString[0])
               {
                  vuLocalSessionEntity->SetPlayerCallsign(dialogReturnString);
                  InitSessionStuff(hDlg);
               }
               SetDlgItemText(hDlg, IDC_SESSION_NAME, F4SessionMemberName);
               F4SessionUpdateMemberList(hDlg);
               retval = TRUE;
            break;

            case IDC_SESSION_GROUP_LIST:
               switch (HIWORD(wParam))
               {
                  case LBN_SELCHANGE:
                  case LBN_DBLCLK:
                     selItem = SendDlgItemMessage (hDlg, IDC_SESSION_GROUP_LIST, LB_GETCURSEL, 0, 0);
                     SendDlgItemMessage (hDlg, IDC_SESSION_GROUP_LIST, LB_GETTEXT,
                        selItem, (LPARAM)tmpName);
                     myGame = (VuGameEntity*)vuDatabase->Find (
                     *((VU_ID*)SendDlgItemMessage (hDlg, IDC_SESSION_GROUP_LIST, LB_GETITEMDATA,
                        selItem, 0)));

                     if ((HIWORD(wParam) == LBN_DBLCLK) && myGame)
                     {
                        gMainThread->LeaveGame();
                        gMainThread->JoinGame(myGame);
                        InitSessionStuff(hDlg);
                     }
                     F4SessionUpdateMemberList(hDlg);
                  break;
               }
               retval = TRUE;
            break;

            case IDC_SESSION_EXIT:
               if (vuLocalSessionEntity->Game() != vuPlayerPoolGroup)
                  gMainThread->LeaveGame();
               InitSessionStuff(hDlg);
               F4SessionUpdateGameList(hDlg);
               F4SessionUpdateMemberList(hDlg);
            break;
         }
      break;
   }

   lParam = wParam;
   return (retval);
}
Beispiel #18
0
/*
 * AliasDialogProc:  Dialog procedure for alias dialog.
 */
BOOL CALLBACK AliasDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
   int i;
   HWND hEdit;
   WORD command;

   switch (message)
   {
   case WM_INITDIALOG:
      // Show current aliases
      for (i=0; i < NUM_ALIASES; i++)
      {
	 hEdit = GetDlgItem(hDlg, IDC_ALIASF1 + i);
	 SetWindowText(hEdit, aliases[i].text);
	 Edit_LimitText(hEdit, MAX_ALIASLEN - 1);
	 SetWindowFont(hEdit, GetFont(FONT_LIST), FALSE);

	 CheckDlgButton(hDlg, IDC_CHECK_F1 + i, aliases[i].cr);
      }

      hAliasDialog = hDlg;
      hAliasDialog1 = hDlg;
      if (hAliasDialog2)
	 DestroyWindow(GetDlgItem(hDlg, IDC_TUNNEL));

      CenterWindow(hDlg, GetParent(hDlg));
      return TRUE;

   case WM_COMMAND:
      switch(GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDOK:
	 // Read aliases
	 for (i=0; i < NUM_ALIASES; i++)
	 {
	    GetDlgItemText(hDlg, IDC_ALIASF1 + i, aliases[i].text, MAX_ALIASLEN - 1);
	    aliases[i].cr = IsDlgButtonChecked(hDlg, IDC_CHECK_F1 + i);
	    if (aliases[i].cr)
	       command = A_TEXTCOMMAND;
	    else command = A_TEXTINSERT;
	    AliasSetKey(interface_key_table, aliases[i].key, KEY_NONE, command, aliases[i].text);
	    AliasSetKey(inventory_key_table, aliases[i].key, KEY_NONE, command, aliases[i].text);
	 }

	 EndDialog(hDlg, IDOK);
	 return TRUE;

      case IDCANCEL:
	 EndDialog(hDlg, IDCANCEL);
	 return TRUE;

      case IDC_TUNNEL:
	 if (!hAliasDialog2 &&
	     IDOK == DialogBox(hInst, MAKEINTRESOURCE(IDD_CMDALIAS), hDlg, VerbAliasDialogProc))
	 {
	    AliasSave();
	    SetFocus(GetDlgItem(hDlg, IDOK));
	 }
      }
      break;

   case WM_DESTROY:
      hAliasDialog = NULL;
      hAliasDialog1 = NULL;
      return TRUE;
   }
   
   return FALSE;
}
Beispiel #19
0
void kof_Set_Level_Environment(LEVEL_ENVIRONMENT * p_LevEnv, HINSTANCE hInst,
                               HWND hWnd)
{
    p_LevelEnvironment = p_LevEnv;
    DialogBox(hInst, MAKEINTRESOURCE(IDD_LEVEL_ENVIRONMENT), hWnd, MainDlgProc);
}
Beispiel #20
0
/*
 * VerbAliasDialogProc:  Dialog procedure for command verb alias dialog.
 */
BOOL CALLBACK VerbAliasDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
   switch (message)
   {
   case WM_INITDIALOG:

      SendDlgItemMessage(hDlg, IDC_VERB, EM_LIMITTEXT, MAX_VERBLEN, 0L);
      SendDlgItemMessage(hDlg, IDC_EXPANSION, EM_LIMITTEXT, MAX_ALIASLEN, 0L);

      // Prepare list of aliases currently defined.
      {
	 LV_COLUMN lvcol;
	 HWND hList;
	 int i;

	 // Prepare list of aliases.
	 hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);
	 SetWindowFont(hList, GetFont(FONT_LIST), FALSE);
	 SetWindowLong(hList, GWL_STYLE, GetWindowLong(hList, GWL_STYLE) | LVS_SHOWSELALWAYS);

	 // Add column headings
	 lvcol.mask = LVCF_TEXT | LVCF_WIDTH;
	 lvcol.pszText = GetString(hInst, IDS_AHEADER0);
	 lvcol.cx = 60;
	 ListView_InsertColumn(hList, 0, &lvcol);
	 lvcol.pszText = GetString(hInst, IDS_AHEADER1);
	 lvcol.cx = 220;
	 ListView_InsertColumn(hList, 1, &lvcol);

	 // Add aliases
	 for (i = 0; i < _nVerbAliases; i++)
	 {
	    if (_apVerbAliases[i].verb[0])
	    {
	       LV_ITEM lvitem;

	       // Add item for verb.
	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = ListView_GetItemCount(hList);
	       lvitem.iSubItem = 0;
	       lvitem.pszText = _apVerbAliases[i].verb;
	       lvitem.iItem = ListView_InsertItem(hList, &lvitem);

	       // Add subitem for command.
	       lvitem.mask = LVIF_TEXT;
	       lvitem.iSubItem = 1;
	       lvitem.pszText = _apVerbAliases[i].text;
	       ListView_SetItem(hList, &lvitem);
	    }
	 }
      }

      // Dialog is up.
      hAliasDialog = hDlg;
      hAliasDialog2 = hDlg;
      if (hAliasDialog1)
	 DestroyWindow(GetDlgItem(hDlg, IDC_TUNNEL));

      CenterWindow(hDlg, GetParent(hDlg));
      return TRUE;

   case WM_NOTIFY:
      if (wParam != IDC_COMMAND_LIST)
      {
	 return TRUE;
      }
      else
      {
	 NM_LISTVIEW* pnm = (NM_LISTVIEW*)lParam;
	 LV_HITTESTINFO lvhit;
	 LV_KEYDOWN* plvkey;
	 HWND hList;
	 int i;

	 if (!pnm)
	    break;

	 // Prepare list of aliases.
	 hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	 switch (pnm->hdr.code)
	 {
	 case NM_CLICK:
	    {
	       VerbAlias alias;
	       LV_ITEM lvitem;
	       HWND hList;

	       hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	       // If you click anywhere on an item.
	       GetCursorPos(&lvhit.pt);
	       ScreenToClient(hList, &lvhit.pt);
	       lvhit.pt.x = 3;
	       i = ListView_HitTest(hList, &lvhit);
	       if (i < 0)
		  break;

	       // Get our current definition.
	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = i;
	       lvitem.iSubItem = 0;
	       lvitem.pszText = alias.verb;
	       lvitem.cchTextMax = sizeof(alias.verb);
	       ListView_GetItem(hList, &lvitem);
	       lvitem.iSubItem = 1;
	       lvitem.pszText = alias.text;
	       lvitem.cchTextMax = sizeof(alias.text);
	       ListView_GetItem(hList, &lvitem);

	       // Put it up for editing.
	       SetDlgItemText(hDlg, IDC_VERB, alias.verb);
	       SetDlgItemText(hDlg, IDC_EXPANSION, alias.text);

	       // Select and focus the item in the list.
	       ListView_SetItemState(hList, i, 
				     LVIS_SELECTED | LVIS_FOCUSED,
				     LVIS_SELECTED | LVIS_FOCUSED);
	    }
	    break;

	 case LVN_KEYDOWN:
	    plvkey = (LV_KEYDOWN*)pnm;
	    if (plvkey->wVKey == VK_DELETE)
	    {
//	       for (i = 0; i < nItems; i++)
//		  if (is selected i)
//		     ListView_DeleteItem(hList, i);
	    }
	    break;
	 }
      }
      return TRUE;

   case WM_COMMAND:
      switch(GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDOK:
	 // Erase current set and redefine words in the dialog.
	 {
	    int i, nItems;
	    HWND hList;
	    hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	    // Simulate a last click of 'Define' in case they forgot.
	    // Does no harm if they left the boxes empty after their
	    // last 'Define'.
	    //
	    ListView_ClearSelection(hList);
	    SendMessage(hDlg, WM_COMMAND,
	       (WPARAM)MAKELONG(IDC_DEFINE, BN_CLICKED),
	       (LPARAM)GetDlgItem(hDlg, IDC_DEFINE));

	    // Clear our real aliases and rebuild them from our listbox.
	    //
	    FreeVerbAliases();
	    nItems = ListView_GetItemCount(hList);
	    for (i = 0; i < nItems; i++)
	    {
	       VerbAlias alias;
	       LV_ITEM lvitem;

	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = i;
	       lvitem.iSubItem = 0;
	       lvitem.pszText = alias.verb;
	       lvitem.cchTextMax = sizeof(alias.verb);
	       ListView_GetItem(hList, &lvitem);
	       lvitem.iSubItem = 1;
	       lvitem.pszText = alias.text;
	       lvitem.cchTextMax = sizeof(alias.text);
	       ListView_GetItem(hList, &lvitem);

	       AddVerbAlias(alias.verb, alias.text);
	    }
	 }
	 EndDialog(hDlg, IDOK);
	 return TRUE;

      case IDCANCEL:
	 EndDialog(hDlg, IDCANCEL);
	 return TRUE;

      case IDC_DEFINE:
	 {
	    VerbAlias alias;
	    LV_ITEM lvitem;
	    HWND hList;

	    hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	    // Get our new definition.
	    GetDlgItemText(hDlg, IDC_VERB, alias.verb, sizeof(alias.verb));
	    GetDlgItemText(hDlg, IDC_EXPANSION, alias.text, sizeof(alias.text));
	    if (!alias.verb[0])
	    {
	       SetFocus(GetDlgItem(hDlg, IDC_VERB));
	       return TRUE;
	    }
	    if (!alias.text[0])
	    {
	       SetFocus(GetDlgItem(hDlg, IDC_EXPANSION));
	       return TRUE;
	    }

	    // Simulate a remove so we don't have to hunt and modify existing entry.
	    ListView_ClearSelection(hList);
	    SendMessage(hDlg, WM_COMMAND,
	       (WPARAM)MAKELONG(IDC_REMOVE, BN_CLICKED),
	       (LPARAM)GetDlgItem(hDlg, IDC_REMOVE));

	    // Add item for verb.
	    lvitem.mask = LVIF_TEXT;
	    lvitem.iItem = ListView_GetItemCount(hList);
	    lvitem.iSubItem = 0;
	    lvitem.pszText = alias.verb;
	    lvitem.iItem = ListView_InsertItem(hList, &lvitem);

	    // Add subitem for command.
	    lvitem.mask = LVIF_TEXT;
	    lvitem.iSubItem = 1;
	    lvitem.pszText = alias.text;
	    ListView_SetItem(hList, &lvitem);

	    // Clear the fields to try another.
	    SetDlgItemText(hDlg, IDC_VERB, "");
	    SetDlgItemText(hDlg, IDC_EXPANSION, "");
	    SetFocus(GetDlgItem(hDlg, IDC_VERB));
	 }
	 return TRUE;

      case IDC_REMOVE:
	 {
	    char verb[MAX_VERBLEN+1];
	    LV_FINDINFO lvfind;
	    HWND hList;
	    int i;

	    hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	    // Get our new definition.
	    GetDlgItemText(hDlg, IDC_VERB, verb, sizeof(verb));
	    if (!verb[0])
	    {
	       LV_ITEM lvitem;

	       i = ListView_GetSelection(hList);
	       if (i < 0)
	       {
		  SetFocus(GetDlgItem(hDlg, IDC_VERB));
		  return TRUE;
	       }

	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = i;
	       lvitem.iSubItem = 0;
	       lvitem.pszText = verb;
	       lvitem.cchTextMax = sizeof(verb);
	       ListView_GetItem(hList, &lvitem);
	       if (!verb[0])
	       {
		  SetFocus(GetDlgItem(hDlg, IDC_VERB));
		  return TRUE;
	       }
	    }

	    // Find item for verb.
	    lvfind.flags = LVFI_STRING | LVFI_WRAP; // not LVFI_PARTIAL
	    lvfind.psz = verb;
	    lvfind.lParam = 0;
	    i = ListView_FindItem(hList, -1, &lvfind);
	    if (i < 0)
	    {
	       SetFocus(GetDlgItem(hDlg, IDC_VERB));
	       Edit_SetSel(GetDlgItem(hDlg, IDC_VERB), 0, -1);
	       return TRUE;
	    }

	    // Remove item.
	    ListView_DeleteItem(hList, i);

	    // Clear the fields to try another.
	    SetDlgItemText(hDlg, IDC_VERB, "");
	    SetDlgItemText(hDlg, IDC_EXPANSION, "");
	    SetFocus(GetDlgItem(hDlg, IDC_VERB));
	 }
	 return TRUE;

      case IDC_TUNNEL:
	 if (!hAliasDialog1 &&
	     IDOK == DialogBox(hInst, MAKEINTRESOURCE(IDD_ALIAS), hDlg, AliasDialogProc))
	 {
	    AliasSave();
	    SetFocus(GetDlgItem(hDlg, IDOK));
	 }
	 return TRUE;
      }
      break;

   case WM_DESTROY:
      hAliasDialog = NULL;
      hAliasDialog2 = NULL;
      return TRUE;
   }
   
   return FALSE;
}
Beispiel #21
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)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		::TextOut(hdc, 10, 10, L"Arrow keys to turn.", 19);
		::SetTextColor(hdc, RGB(200,0,0));
		::TextOut(hdc, 10, 25, L"Red = Original;", 15);
		::SetTextColor(hdc, RGB(0,0,255));
		::TextOut(hdc, 120, 25, L"Blue = Extrapolated", 19);
		::SetTextColor(hdc, RGB(0,0,0));
		{
		  wchar_t buf[100];
		  _snwprintf(buf, 100, L"Latency %d ms Jitter %d ms Droprate %d%%", (int)(LATENCY*1000), (int)(JITTER*1000),
		      (int)(DROPRATE*100));
		  buf[99] = 0;
		  ::TextOut(hdc, 10, 40, buf, (INT)wcslen(buf));
		}
		::TextOut(hdc, 10, 55, L"F2: change draw mode", 20);
		::TextOut(hdc, 10, 70, L"F3: pause/go", 12);
		::TextOut(hdc, 10, 85, L"F4: single step", 15);
		if (gPaused) {
		  ::SetTextColor(hdc, RGB(255,0,0));
		  ::TextOut(hdc, 300, 10, L"PAUSED", 6);
		  ::SetTextColor(hdc, RGB(0,0,0));
		}
		if (gPointDisplay) {
		  ::TextOut(hdc, 300, 25, L"POINTS", 6);
		}
		else {
		  ::TextOut(hdc, 300, 25, L"LINES", 5);
		}
    DrawWindow(hWnd, hdc);
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		gRunning = false;
		break;

  case WM_SYSKEYDOWN:
  case WM_KEYDOWN:
    keyDown[wParam&0xff] = true;
    break;
  case WM_SYSKEYUP:
  case WM_KEYUP:
    keyDown[wParam&0xff] = false;
    break;
  case WM_ACTIVATEAPP:
    gActive = (wParam != 0);
    memset(keyDown, 0, sizeof(keyDown));
    break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Beispiel #22
0
void SERVERCONSOLE_SETTINGS_Display( HWND hDlg )
{
	DialogBox( g_hInst, MAKEINTRESOURCE( IDD_SERVERSETTINGS_DIALOG ), hDlg, settings_Dialog_Callback );
}
LRESULT CALLBACK MainWndProc ( HWND hWnd, UINT message,
                               WPARAM wParam, LPARAM lParam )
{
   HDC            hDC;
   PAINTSTRUCT    ps;
   DLGPROC        dlgProcAbout;
   int            i;
   int            j;
   short          y;


   switch ( message )
   {
      case WM_CREATE:
         hDC = GetDC ( hWnd );

         GetTextMetrics ( hDC, &tm );
         cxChar = tm.tmAveCharWidth;
         cyChar = tm.tmHeight + tm.tmExternalLeading;

         ReleaseDC ( hWnd, hDC );

         lpDdeProc = MakeProcInstance ( (FARPROC) DDECallback, hInst );
         if ( DdeInitialize ( (LPDWORD)&idInst, (PFNCALLBACK)lpDdeProc,
                              APPCMD_CLIENTONLY, 0L ) )
         {
            HandleOutput ( "Client DDE initialization failure." );
            return ( FALSE );
         }

         hszService = DdeCreateStringHandle ( idInst, "Borland", CP_WINANSI );
         hszTopic = DdeCreateStringHandle ( idInst, "DDEExample", CP_WINANSI );
         hszItem = DdeCreateStringHandle ( idInst, "DDEData", CP_WINANSI );

         cCurrentLine = 0;
         cTotalLines = 0;

         strcpy ( szDDEString, "Client application message number:  " );
         break;

      case WM_COMMAND:
         switch ( wParam )
         {
            case IDM_EXIT:
               DestroyWindow ( hWnd );
               break;

            case IDM_CONNECT_SERVER:
               if ( hConv == NULL )
               {
                  hConv = DdeConnect ( idInst, hszService, hszTopic,
                                       (PCONVCONTEXT) NULL );
                  if ( hConv == NULL )
                  {
                     HandleError ( DdeGetLastError ( idInst ) );
                     HandleOutput ( "Unsuccessful connection." );
                  }
                  else
                     HandleOutput ( "Successful connection." );
               }
               else
                  HandleOutput ( "Already connected to DDE Server." );

               break;

            case IDM_DISCONNECT_SERVER:
               if ( hConv != NULL )
               {
                  DdeDisconnect ( hConv );
                  hConv = NULL;
                  HandleOutput ( "Disconnected from server." );
               }
               else
                  HandleOutput ( "Must be connected before disconnecting." );

               break;

            case IDM_MSG_TO_SERVER:
               if ( hConv != NULL )
               {
                  iClientCount ++;
                  sprintf ( tbuf, "%3d.", iClientCount );
                  strncpy ( &szDDEString[36], tbuf, 5 );

                  hData = DdeCreateDataHandle ( idInst, &szDDEString,
                           sizeof ( szDDEString ), 0L, hszItem, wFmt, 0 );

                  if ( hData != NULL )
            		  hData = DdeClientTransaction ( (LPBYTE)hData, -1, hConv,
                               hszItem, wFmt, XTYP_POKE, 1000, &dwResult );
                  else
                     HandleOutput ( "Could not create data handle." );
               }
               else
                  HandleOutput ( "A connection to a DDE Server has not been established." );

               break;

            case IDM_MSG_FROM_SERVER:
               if ( hConv != NULL )
               {
                  hData = DdeClientTransaction ( NULL, 0, hConv,
                               hszItem, wFmt, XTYP_REQUEST, 1000, &dwResult );

                  if ( dwResult == DDE_FNOTPROCESSED )
                     HandleOutput ( "Data not available from server." );
                  else
                  {
                     DdeGetData ( hData, (LPBYTE) szDDEData, 80L, 0L );

                     if ( szDDEData != NULL )
                        HandleOutput ( szDDEData );
                     else
                        HandleOutput ( "Message from server is null." );
                  }
               }
               else
                  HandleOutput ( "A connection to a DDE Server has not been established." );

               break;

            case IDM_ABOUT:
               dlgProcAbout = (DLGPROC) MakeProcInstance ( (FARPROC)About, hInst );
               DialogBox ( hInst, "AboutBox", hWnd, dlgProcAbout );
               FreeProcInstance ( (FARPROC) dlgProcAbout );
               break;

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

      case WM_PAINT:
         hDC = BeginPaint ( hWnd, &ps );

         y = 0;

         for ( i = 0; i < cTotalLines; i ++ )
         {
            if ( cTotalLines == 8 )
               j = ( (cCurrentLine + 1 + i) % 9 );
            else
               j = i;         // can't do this if we clear window and start in middle of array

            TextOut ( hDC, 0, y, (LPSTR)(szScreenText[j]),
                                 lstrlen ( szScreenText[j] ) );
            y = y + cyChar;
         }

         EndPaint ( hWnd, &ps );
         break;

      case WM_DESTROY:
         if ( hConv != NULL )
         {
            DdeDisconnect ( hConv );
            hConv = NULL;
         }

         DdeFreeStringHandle ( idInst, hszService );
         DdeFreeStringHandle ( idInst, hszTopic );
         DdeFreeStringHandle ( idInst, hszItem );

         FreeProcInstance ( lpDdeProc );

         PostQuitMessage ( 0 );
         break;

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

   return ( FALSE );
}
Beispiel #24
0
BOOL CALLBACK settings_ServerTab_Callback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	switch ( Message )
	{
	case WM_INITDIALOG:

		g_hDlg_ServerTab = hDlg;

		// Enable tab gradients on XP and later.
		if ( pEnableThemeDialogTexture != NULL )
			pEnableThemeDialogTexture ( hDlg, ETDT_ENABLETAB );

		// Limit the input length for the text boxes.
		SendDlgItemMessage( hDlg, IDC_SERVERNAME, EM_SETLIMITTEXT, 96, 0 );
		SendDlgItemMessage( hDlg, IDC_WADURL, EM_SETLIMITTEXT, 96, 0 );
		SendDlgItemMessage( hDlg, IDC_EMAIL, EM_SETLIMITTEXT, 96, 0 );
		
		// Initialize all the fields.		
		SetDlgItemText( hDlg, IDC_SERVERNAME, sv_hostname.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_EMAIL, sv_hostemail.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_WADURL, sv_website.GetGenericRep( CVAR_String ).String );
		SendDlgItemMessage( hDlg, IDC_UPDATEMASTER, BM_SETCHECK, ( sv_updatemaster ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_BROADCAST, BM_SETCHECK, ( sv_broadcast ? BST_CHECKED : BST_UNCHECKED ), 0 );
		g_fsMOTD = sv_motd.GetGenericRep( CVAR_String ).String;

		// PWADs.		
		SendMessage( GetDlgItem( hDlg, IDC_PWADS ), WM_SETFONT, (WPARAM) CreateFont( 12, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1 );
		{
			char		szString[256];
			
			int iNumChars = 0;
			sprintf( szString, "PWADs:" );
			for( std::list<FString>::iterator i = NETWORK_GetPWADList( )->begin( ); i != NETWORK_GetPWADList( )->end(); ++i )
			{
				iNumChars += i->Len( );
				if ( iNumChars > 50 - 3 ) // Determined by width of label
				{
					sprintf( szString + strlen ( szString ), "...", *i->GetChars( ));
					break;
				}
				else
					sprintf( szString + strlen ( szString ), " %s", *i );
			}

			g_ulNumPWADs = NETWORK_GetPWADList( )->size( );
			if ( g_ulNumPWADs == 0 )
			{
				ShowWindow( GetDlgItem( hDlg, IDC_WADURL ), SW_HIDE );
				ShowWindow( GetDlgItem( hDlg, IDC_WADURLLABEL ), SW_HIDE );
				ShowWindow( GetDlgItem( hDlg, IDC_PWADS ), SW_HIDE );
				ShowWindow( GetDlgItem( hDlg, IDC_PWADGROUP ), SW_HIDE );
			}
			else
				SetDlgItemText( hDlg, IDC_PWADS, szString );
		}
		break;
	case WM_COMMAND:

		if ( LOWORD( wParam ) == IDC_STARTUPMESSAGE )
			DialogBox( g_hInst, MAKEINTRESOURCE( IDD_EDITMOTD ), hDlg, settings_ServerTab_MOTDCallback );
		break;
	}

	return FALSE;
}
NOEXPORT LRESULT CALLBACK window_proc(HWND main_window_handle,
        UINT message, WPARAM wParam, LPARAM lParam) {
    NOTIFYICONDATA nid;
    POINT pt;
    RECT rect;
    SERVICE_OPTIONS *section;
    unsigned int section_number;

#if 0
    if(message!=WM_CTLCOLORSTATIC && message!=WM_TIMER)
        s_log(LOG_DEBUG, "Window message: %d", message);
#endif
    switch(message) {
    case WM_CREATE:
#ifdef _WIN32_WCE
        /* create command bar */
        command_bar_handle=CommandBar_Create(ghInst, main_window_handle, 1);
        if(!command_bar_handle)
            error_box("CommandBar_Create");
        if(!CommandBar_InsertMenubar(command_bar_handle, ghInst, IDM_MAINMENU, 0))
            error_box("CommandBar_InsertMenubar");
        if(!CommandBar_AddAdornments(command_bar_handle, 0, 0))
            error_box("CommandBar_AddAdornments");
#endif

        /* create child edit window */
        edit_handle=CreateWindow(TEXT("EDIT"), NULL,
            WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY,
            0, 0, 0, 0, main_window_handle, (HMENU)IDE_EDIT, ghInst, NULL);
#ifndef _WIN32_WCE
        SendMessage(edit_handle, WM_SETFONT,
            (WPARAM)CreateFont(-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
                DEFAULT_CHARSET, OUT_RASTER_PRECIS, CLIP_DEFAULT_PRECIS,
                PROOF_QUALITY, DEFAULT_PITCH, TEXT("Courier")),
            MAKELPARAM(FALSE, 0)); /* no need to redraw right, now */
#endif
        /* NOTE: there's no return statement here -> proceeding with resize */

    case WM_SIZE:
        GetClientRect(main_window_handle, &rect);
#ifdef _WIN32_WCE
        MoveWindow(edit_handle, 0, CommandBar_Height(command_bar_handle),
            rect.right, rect.bottom-CommandBar_Height(command_bar_handle), TRUE);
#else
        MoveWindow(edit_handle, 0, 0, rect.right, rect.bottom, TRUE);
#endif
        UpdateWindow(edit_handle);
        /* CommandBar_Show(command_bar_handle, TRUE); */
        return TRUE;

    case WM_SETFOCUS:
        SetFocus(edit_handle);
        return TRUE;

    case WM_TIMER:
        if(visible)
            update_logs();
        return TRUE;

    case WM_CLOSE:
        ShowWindow(main_window_handle, SW_HIDE);
        return TRUE;

    case WM_SHOWWINDOW:
        visible=wParam; /* setup global variable */
        if(tray_menu_handle)
            CheckMenuItem(tray_menu_handle, IDM_SHOW_LOG,
                visible ? MF_CHECKED : MF_UNCHECKED);
        if(visible)
            update_logs();
        return TRUE;

    case WM_DESTROY:
#ifdef _WIN32_WCE
        CommandBar_Destroy(command_bar_handle);
#else
        if(main_menu_handle)
            DestroyMenu(main_menu_handle);
#endif
        if(tray_menu_handle)
            DestroyMenu(tray_menu_handle);
        ZeroMemory(&nid, sizeof nid);
        nid.cbSize=sizeof nid;
        nid.hWnd=main_window_handle;
        nid.uID=1;
        nid.uFlags=NIF_TIP; /* not really sure what to put here, but it works */
        Shell_NotifyIcon(NIM_DELETE, &nid); /* this removes the icon */
        PostQuitMessage(0);
        KillTimer(main_window_handle, 0x29a);
        return TRUE;

    case WM_COMMAND:
        if(wParam>=IDM_PEER_MENU && wParam<IDM_PEER_MENU+number_of_sections) {
            for(section=service_options.next, section_number=0;
                    section && wParam!=IDM_PEER_MENU+section_number;
                    section=section->next, ++section_number)
                ;
            if(!section)
                return TRUE;
            if(save_text_file(section->file, section->chain))
                return TRUE;
#ifndef _WIN32_WCE
            if(main_menu_handle)
                CheckMenuItem(main_menu_handle, wParam, MF_CHECKED);
#endif
            if(tray_menu_handle)
                CheckMenuItem(tray_menu_handle, wParam, MF_CHECKED);
            message_box(section->help, MB_ICONINFORMATION);
            return TRUE;
        }
        switch(wParam) {
        case IDM_ABOUT:
            DialogBox(ghInst, TEXT("AboutBox"), main_window_handle,
                (DLGPROC)about_proc);
            break;
        case IDM_SHOW_LOG:
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
        case IDM_CLOSE:
            ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            break;
        case IDM_EXIT:
            if(!error_mode) /* signal_pipe is active */
                signal_post(SIGNAL_TERMINATE);
            DestroyWindow(main_window_handle);
            break;
        case IDM_SAVE_LOG:
            if(!cmdline.service) /* security */
                save_log();
            break;
        case IDM_EDIT_CONFIG:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                edit_config(main_window_handle);
#endif
            break;
        case IDM_RELOAD_CONFIG:
            if(error_mode) /* unlock daemon_thread */
                SetEvent(config_ready);
            else /* signal_pipe is active */
                signal_post(SIGNAL_RELOAD_CONFIG);
            break;
        case IDM_REOPEN_LOG:
            signal_post(SIGNAL_REOPEN_LOG);
            break;
        case IDM_MANPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("stunnel.html"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        case IDM_HOMEPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("http://www.stunnel.org/"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        }
        return TRUE;

    case WM_SYSTRAY: /* a taskbar event */
        switch(lParam) {
#ifdef _WIN32_WCE
        case WM_LBUTTONDOWN: /* no right mouse button on Windows CE */
            GetWindowRect(GetDesktopWindow(), &rect); /* no cursor position */
            pt.x=rect.right;
            pt.y=rect.bottom-25;
#else
        case WM_RBUTTONDOWN:
            GetCursorPos(&pt);
#endif
            SetForegroundWindow(main_window_handle);
            TrackPopupMenuEx(GetSubMenu(tray_menu_handle, 0), TPM_BOTTOMALIGN,
                pt.x, pt.y, main_window_handle, NULL);
            PostMessage(main_window_handle, WM_NULL, 0, 0);
            break;
#ifndef _WIN32_WCE
        case WM_LBUTTONDBLCLK: /* switch log window visibility */
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
#endif
        }
        return TRUE;

    case WM_VALID_CONFIG:
        valid_config();
        return TRUE;

    case WM_INVALID_CONFIG:
        invalid_config();
        return TRUE;

    case WM_LOG:
        win_log((LPSTR)wParam);
        return TRUE;

    case WM_NEW_CHAIN:
#ifndef _WIN32_WCE
        if(main_menu_handle)
            EnableMenuItem(main_menu_handle, IDM_PEER_MENU+wParam, MF_ENABLED);
#endif
        if(tray_menu_handle)
            EnableMenuItem(tray_menu_handle, IDM_PEER_MENU+wParam, MF_ENABLED);
        return TRUE;

    case WM_CLIENTS:
        update_tray_icon((int)wParam);
        return TRUE;
    }

    return DefWindowProc(main_window_handle, message, wParam, lParam);
}
Beispiel #26
0
BOOL CALLBACK settings_GameplayTab_Callback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	switch ( Message )
	{
	case WM_INITDIALOG:

		g_hDlg_GameplayTab = hDlg;

		// Enable tab gradients on XP and later.
		if ( pEnableThemeDialogTexture != NULL )
			pEnableThemeDialogTexture ( hDlg, ETDT_ENABLETAB );

		// Limit the input length for the spin boxes.
		SendDlgItemMessage( hDlg, IDC_FRAGLIMIT, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_TIMELIMIT, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_POINTLIMIT, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_DUELLIMIT, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_WINLIMIT, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_MAXLIVES, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_TIMELIMITSPIN, UDM_SETRANGE, 0, MAKELONG( 9999,0 ));
		SendDlgItemMessage( hDlg, IDC_FRAGLIMITSPIN, UDM_SETRANGE, 0, MAKELONG( 9999,0 ));
		SendDlgItemMessage( hDlg, IDC_POINTLIMITSPIN, UDM_SETRANGE, 0, MAKELONG( 9999,0 ));
		SendDlgItemMessage( hDlg, IDC_DUELLIMITSPIN, UDM_SETRANGE, 0, MAKELONG( 9999,0 ));
		SendDlgItemMessage( hDlg, IDC_WINLIMITSPIN, UDM_SETRANGE, 0, MAKELONG( 9999,0 ));
		SendDlgItemMessage( hDlg, IDC_MAXLIVESSPIN, UDM_SETRANGE, 0, MAKELONG( 9999,0 ));

		// Initialize all the fields.		
		SetDlgItemText( hDlg, IDC_FRAGLIMIT, fraglimit.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_TIMELIMIT, timelimit.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_POINTLIMIT, pointlimit.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_DUELLIMIT, duellimit.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_WINLIMIT, winlimit.GetGenericRep( CVAR_String ).String );
		SetDlgItemText( hDlg, IDC_MAXLIVES, sv_maxlives.GetGenericRep( CVAR_String ).String );

		// Fill the list with game modes, and select the current one.
		for ( int i = 0; i < NUM_GAMEMODES; i++ )
			SendDlgItemMessage( hDlg, IDC_GAMEPLAYMODE, CB_INSERTSTRING, -1, (WPARAM)(LPSTR) GameModeVals[i].name );
		SendDlgItemMessage( hDlg, IDC_GAMEPLAYMODE, CB_SETCURSEL, (LONG) GAMEMODE_GetCurrentMode( ), 0 );

		// Fill and select modifiers.
		for ( int i = 0; i < NUM_MODIFIERS; i++ )
			SendDlgItemMessage( hDlg, IDC_MODIFIER, CB_INSERTSTRING, -1, (WPARAM)(LPSTR) ModifierVals[i].name );
		SendDlgItemMessage( hDlg, IDC_MODIFIER, CB_SETCURSEL, (LONG) GAMEMODE_GetModifier( ), 0 );

		// Fill and select skills.
		for ( int i = 0; i < NUM_SKILLS; i++ )
			SendDlgItemMessage( hDlg, IDC_SKILL, CB_INSERTSTRING, -1, (WPARAM)(LPSTR) GameskillVals[i].name );
		SendDlgItemMessage( hDlg, IDC_SKILL, CB_SETCURSEL, gameskill.GetGenericRep( CVAR_Int ).Int, 0 );

		// Fill and select botskills.
		for ( int i = 0; i < NUM_BOTSKILLS; i++ )
			SendDlgItemMessage( hDlg, IDC_BOTSKILL, CB_INSERTSTRING, -1, (WPARAM)(LPSTR) BotskillVals[i].name );
		SendDlgItemMessage( hDlg, IDC_BOTSKILL, CB_SETCURSEL, botskill.GetGenericRep( CVAR_Int ).Int, 0 );

		settings_GameplayTab_ShowOrHideItems( hDlg );
		break;
	case WM_COMMAND:

		if ( LOWORD( wParam ) == IDC_GAMEPLAYMODE )
			settings_GameplayTab_ShowOrHideItems( hDlg );
		if ( LOWORD( wParam ) == IDC_MAPLIST )
			DialogBox( g_hInst, MAKEINTRESOURCE( IDD_MAPROTATION ), hDlg, SERVERCONSOLE_MapRotationCallback );
		if ( LOWORD( wParam ) == IDC_SHOWFLAGS )
			DialogBox( g_hInst, MAKEINTRESOURCE( IDD_DMFLAGS ), hDlg, SERVERCONSOLE_DMFlagsCallback );
		break;
	}

	return FALSE;
}
Beispiel #27
0
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int iCmdShow)
{
    HWND        hwnd;
    MSG            msg;
    WNDCLASS    wndclass;
    INITCOMMONCONTROLSEX ice;
    HACCEL        hAccelTable;

    hInstance = hInst;

    /* Load application title */
    LoadString(hInst, IDS_SPI_NAME, szAppName, sizeof(szAppName) / sizeof(szAppName[0]));
    /* Load MsgBox() texts here to avoid loading them many times later */
    LoadString(hInst, IDS_SPI_ABOUT, MsgAbout, sizeof(MsgAbout) / sizeof(MsgAbout[0]));
    LoadString(hInst, IDS_SPI_QUIT, MsgQuit, sizeof(MsgQuit) / sizeof(MsgQuit[0]));
    LoadString(hInst, IDS_SPI_WIN, MsgWin, sizeof(MsgWin) / sizeof(MsgWin[0]));
    LoadString(hInst, IDS_SPI_DEAL, MsgDeal, sizeof(MsgDeal) / sizeof(MsgDeal[0]));

    /* Window class for the main application parent window */
    wndclass.style             = 0;
    wndclass.lpfnWndProc       = WndProc;
    wndclass.cbClsExtra        = 0;
    wndclass.cbWndExtra        = 0;
    wndclass.hInstance         = hInst;
    wndclass.hIcon             = LoadIcon (hInst, MAKEINTRESOURCE(IDI_SPIDER));
    wndclass.hCursor           = LoadCursor (NULL, IDC_ARROW);
    wndclass.hbrBackground     = (HBRUSH)NULL;
    wndclass.lpszMenuName      = MAKEINTRESOURCE(IDR_MENU1);
    wndclass.lpszClassName     = szAppName;

    RegisterClass(&wndclass);

    ice.dwSize = sizeof(ice);
    ice.dwICC = ICC_BAR_CLASSES;
    InitCommonControlsEx(&ice);

    srand((unsigned)GetTickCount());

    /* InitCardLib(); */

    /* Construct the path to our help file */
    MakePath(szHelpPath, MAX_PATH, _T(".hlp"));

    hwnd = CreateWindow(szAppName,
                szAppName,
                WS_OVERLAPPEDWINDOW,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                0,  /*The real size will be computed in WndProc through WM_GETMINMAXINFO */
                0,  /* The real size will be computed in WndProc through WM_GETMINMAXINFO */
                NULL,
                NULL,
                hInst,
                NULL);

    hwndMain = hwnd;

    ShowWindow(hwnd, iCmdShow);
    UpdateWindow(hwnd);

    hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));

    DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIFFICULTY), hwnd, DifficultyDlgProc);

    while(GetMessage(&msg, NULL,0,0))
    {
        if(!TranslateAccelerator(hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    return msg.wParam;
}
Beispiel #28
0
BOOL CALLBACK settings_AccessTab_Callback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam )
{
	switch ( Message )
	{
	case WM_INITDIALOG:

		// Enable tab gradients on XP and later.
		if ( pEnableThemeDialogTexture != NULL )
			pEnableThemeDialogTexture ( hDlg, ETDT_ENABLETAB );

		g_hDlg_AccessTab = hDlg;

		SendDlgItemMessage( hDlg, IDC_PASSWORD, EM_SETLIMITTEXT, 32, 0 );
		SendDlgItemMessage( hDlg, IDC_JOINPASSWORD, EM_SETLIMITTEXT, 32, 0 );
		SendDlgItemMessage( hDlg, IDC_RCONPASSWORD, EM_SETLIMITTEXT, 32, 0 );
		SendDlgItemMessage( hDlg, IDC_MAXCLIENTS, EM_SETLIMITTEXT, 4, 0 );
		SendDlgItemMessage( hDlg, IDC_MAXPLAYERS, EM_SETLIMITTEXT, 4, 0 );		
		SendDlgItemMessage( hDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG( MAXPLAYERS,0 ));
		SendDlgItemMessage( hDlg, IDC_SPIN6, UDM_SETRANGE, 0, MAKELONG( MAXPLAYERS,0 ));

		SetDlgItemText( hDlg, IDC_PASSWORD, sv_password.GetGenericRep( CVAR_String ).String );
		SendDlgItemMessage( hDlg, IDC_REQUIREPW, BM_SETCHECK, sv_forcepassword ? BST_CHECKED : BST_UNCHECKED, 0 );

		SetDlgItemText( hDlg, IDC_JOINPASSWORD, sv_joinpassword.GetGenericRep( CVAR_String ).String );
		SendDlgItemMessage( hDlg, IDC_REQUIREJOINPW, BM_SETCHECK, sv_forcejoinpassword ? BST_CHECKED : BST_UNCHECKED, 0 );

		SetDlgItemText( hDlg, IDC_RCONPASSWORD, sv_rconpassword.GetGenericRep( CVAR_String ).String );
		SendDlgItemMessage( hDlg, IDC_ALLOWRCON, BM_SETCHECK, strlen( sv_rconpassword ) ? BST_CHECKED : BST_UNCHECKED, 0 );

		SetDlgItemText( hDlg, IDC_MAXPLAYERS, sv_maxplayers.GetGenericRep( CVAR_String ).String );		
		SetDlgItemText( hDlg, IDC_MAXCLIENTS, sv_maxclients.GetGenericRep( CVAR_String ).String );

		// Update voting checkboxes.
		SendDlgItemMessage( hDlg, IDC_ALLOW_CALLVOTE, BM_SETCHECK, ( sv_nocallvote != 1 ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_DUELLIMIT, BM_SETCHECK, ( !sv_noduellimitvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_FRAGLIMIT, BM_SETCHECK, ( !sv_nofraglimitvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_KICKLIMIT, BM_SETCHECK, ( !sv_nokickvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_POINTLIMIT, BM_SETCHECK, ( !sv_nopointlimitvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_TIMELIMIT, BM_SETCHECK, ( !sv_notimelimitvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_WINLIMIT, BM_SETCHECK, ( !sv_nowinlimitvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_MAP, BM_SETCHECK, ( !sv_nomapvote ? BST_CHECKED : BST_UNCHECKED ), 0 );
		SendDlgItemMessage( hDlg, IDC_ALLOWVOTE_SPECTATOR, BM_SETCHECK, ( sv_nocallvote != 2 ? BST_CHECKED : BST_UNCHECKED ), 0 );

		settings_AccessTab_ShowOrHideItems( hDlg );
		break;
	case WM_COMMAND:

		switch ( LOWORD( wParam ) )
		{
		case IDC_ALLOW_CALLVOTE:
		case IDC_REQUIREPW:
		case IDC_REQUIREJOINPW:	
		
			// Enable / disable the password fields.
			settings_AccessTab_ShowOrHideItems( hDlg );
			break;
		case IDC_BANLIST:

			DialogBox( g_hInst, MAKEINTRESOURCE( IDD_BANLIST ), hDlg, SERVERCONSOLE_BanListCallback );
			/*
			SERVERCONSOLE_IPLIST_Display( hDlg, IPLIST_BAN );			
			break;
		case IDC_WHITELIST:

			SERVERCONSOLE_IPLIST_Display( hDlg, IPLIST_WHITE );		
			break;
		case IDC_ADMINLIST:

			SERVERCONSOLE_IPLIST_Display( hDlg, IPLIST_ADMIN );
			break;
*/
		break;
		}
	}

	return FALSE;
}
//
//  函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的: 处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	static HWND hwndNextViewer; 
	HGLOBAL hGlobal;
	PTSTR pGlobal;
	RECT rect;

	switch (message)
	{
	case WM_CREATE:
		hwndNextViewer = SetClipboardViewer(hWnd);
		break;
	case WM_CHANGECBCHAIN:
		if((HWND)wParam == hwndNextViewer)
			hwndNextViewer = (HWND)lParam;
		else if(hwndNextViewer)
			SendMessage(hwndNextViewer, message, wParam, lParam);
		//return 0;
		break;
	case WM_DRAWCLIPBOARD:
		if(hwndNextViewer)
			SendMessage(hwndNextViewer, message, wParam, lParam);
		InvalidateRect(hWnd, NULL, TRUE);
		//return 0;
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 在此添加任意绘图代码...
		// OpenClipboard, GetClipboardData, CloseClipboard
		GetClientRect(hWnd, &rect);
		OpenClipboard(hWnd);
#ifdef UNICODE
		hGlobal = GetClipboardData(CF_UNICODETEXT);
#else 
		hGlobal = GetClipboardData(CF_TEXT);
#endif
		if(hGlobal != NULL)
		{
			pGlobal = (PTSTR)GlobalLock(hGlobal);
			DrawText(hdc, pGlobal, -1, &rect, DT_EXPANDTABS);
			GlobalUnlock(hGlobal);
		}
		CloseClipboard();

		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		ChangeClipboardChain(hWnd, hwndNextViewer);
		PostQuitMessage(0);
		//return 0;
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Beispiel #30
0
void ShowProxySettingsDialog()
{

  DialogBox(o.hInstance, (LPCTSTR)IDD_PROXY, NULL, (DLGPROC)ProxySettingsDialogFunc);
}