/******************************************************************************
 * Name         : main
 *
 * Description  : This function calls the Intialize procedure to prepare
 *                everything for the program's operation, enters the
 *                message loop, then call Finalize to shut everything down
 *                when the program is terminated.
 *
 * Concepts     : None.
 *
 * MMPM/2 API's : None.
 *
 * Parameters   : argc - Number of parameters passed into the program.
 *                argv - Command line parameters.
 *
 * Return       : None.
 *
 *************************************************************************/
void main(int argc, char *argv[])
{
InitializeDialog();

/* Handle the messages: */
while(WinGetMsg(hab,&qmsg,0,0,0))
        WinDispatchMsg(hab,&qmsg);

Finalize();

}
Esempio n. 2
0
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
{
    DISPLAY_DEVICEW DispDevice;
    HWND * hDlgs;
    HWND hwndDlg;
    WCHAR szDisplay[20];
    WCHAR szText[30];
    DWORD dwOffset = 0;

    while(TRUE)
    {
        ZeroMemory(&DispDevice, sizeof(DISPLAY_DEVICEW));
        DispDevice.cb = sizeof(DISPLAY_DEVICEW);
        if (!EnumDisplayDevicesW(NULL, pContext->NumDisplayAdapter + dwOffset, &DispDevice, 0))
            return;

        /* skip devices not attached to the desktop and mirror drivers */
        if (!(DispDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) || (DispDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
        {
            dwOffset++;
            continue;
        }
        if (pContext->NumDisplayAdapter)
            hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hDisplayWnd, (pContext->NumDisplayAdapter + 1) * sizeof(HWND));
        else
            hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumDisplayAdapter + 1) * sizeof(HWND));

        if (!hDlgs)
            break;

        pContext->hDisplayWnd = hDlgs;
        hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pContext);
        if (!hwndDlg)
           break;

        /* initialize the dialog */
        InitializeDialog(hwndDlg, &DispDevice);

        szDisplay[0] = L'\0';
        LoadStringW(hInst, IDS_DISPLAY_DIALOG, szDisplay, sizeof(szDisplay)/sizeof(WCHAR));
        szDisplay[(sizeof(szDisplay)/sizeof(WCHAR))-1] = L'\0';

        wsprintfW (szText, L"%s %u", szDisplay, pContext->NumDisplayAdapter + 1);
        InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL), pContext->NumDisplayAdapter + 1, szText);

        hDlgs[pContext->NumDisplayAdapter] = hwndDlg;
        pContext->NumDisplayAdapter++;
    }


}
Esempio n. 3
0
// handler for Settings dialog
LRESULT CALLBACK callback_settings(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  char tbuf[200];
  int idx = 1;
  //sprintf(tbuf,"event %d wp %d lp %d",message,wParam,lParam);
  switch (message) {
    case WM_INITDIALOG:
      
      InitializeDialog(hDlg);
      return TRUE;

    case WM_COMMAND:

      if (LOWORD(wParam) == IDC_ADVANCED) {
        // Reveal the advanced bit of the window
        RECT winsize;
        GetWindowRect (hDlg, &winsize);

        ShowWindow (GetDlgItem(hDlg, IDC_ADVANCED), SW_HIDE);
        ShowWindow (GetDlgItem(hDlg, IDC_STATICADV), SW_SHOW);
        ShowWindow (GetDlgItem(hDlg, IDC_STATICADV2), SW_SHOW);
        ShowWindow (GetDlgItem(hDlg, IDC_STATICADV3), SW_SHOW);
        ShowWindow (GetDlgItem(hDlg, IDC_COMBO4), SW_SHOW);

        MoveWindow (hDlg, winsize.left, winsize.top, wwidth, wheight, TRUE);
        //SetActiveWindow (GetDlgItem(hDlg, IDOK));
        SetFocus (GetDlgItem(hDlg, IDOK));
      }
      else if ((LOWORD(wParam) == IDC_LETTERBOX) || (LOWORD(wParam) == IDC_GFXFILTER)) {
        update_resolution_texts(hDlg);
      }

      if (LOWORD(wParam) == IDC_GFXDRIVER)
      {
        update_gfx_filter_box_enabled(hDlg);
      }
      else if (LOWORD(wParam) == IDC_GFXFILTER)
      {
        int curSel = SendDlgItemMessage(hDlg, IDC_GFXFILTER, CB_GETCURSEL, 0, 0);
        strcpy(curFilter, filterList[curSel]->GetFilterID());
      }

      if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDOKRUN) {
        if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDOKRUN)) {

          csendto = 0;

          if (defaultRes > 2) 
          {
            csendto = 1;
          }

          sprintf(tbuf,"%d",csendto);
          if (!WritePrivateProfileString("misc","screenres",tbuf,ac_config_file)) 
          {
            DWORD errCode = GetLastError();
            sprintf(tbuf, "Unable to write to the configuration file (error code 0x%08X). If you are using Windows Vista, you may need to right-click and Run as Administrator on the Setup application.", errCode);
            MessageBox(hDlg, tbuf, "Save error", MB_OK | MB_ICONEXCLAMATION);
            return TRUE;
          }
          sprintf(tbuf,"-1");
          WritePrivateProfileString("sound","digiid",tbuf,ac_config_file);
          WritePrivateProfileString("sound","midiid",tbuf,ac_config_file);
          sprintf(tbuf,"0");
          WritePrivateProfileString("sound","digiindx",tbuf,ac_config_file);
          WritePrivateProfileString("sound","midiindx",tbuf,ac_config_file);
          int idx=SendDlgItemMessage(hDlg,IDC_COMBO1,CB_GETCURSEL,0,0);
          sprintf(tbuf,"%d",idx);
          WritePrivateProfileString("sound","digiwinindx",tbuf,ac_config_file);
          if (idx == 0)
            idx = DIGI_DIRECTAMX(0);
          else if (idx == 1)
            idx = DIGI_WAVOUTID(0);
          else if (idx == 3) 
            idx = DIGI_DIRECTX(0);
          else idx = DIGI_NONE;
          sprintf(tbuf,"%d",idx);
          WritePrivateProfileString("sound","digiwin",tbuf,ac_config_file);

          idx=SendDlgItemMessage(hDlg,IDC_COMBO2,CB_GETCURSEL,0,0);
          sprintf(tbuf,"%d",idx);
          WritePrivateProfileString("sound","midiwinindx",tbuf,ac_config_file);
          if (idx == 0)
            idx = MIDI_AUTODETECT;
          else if (idx == 1)
            idx = MIDI_NONE;
          else idx = MIDI_WIN32MAPPER;
          sprintf(tbuf,"%d",idx);
          WritePrivateProfileString("sound","midiwin",tbuf,ac_config_file);

          idx = SendDlgItemMessage(hDlg,IDC_COMBO3,CB_GETCURSEL,0,0);
          if (idx > 0) {
            SendDlgItemMessage(hDlg,IDC_COMBO3,CB_GETLBTEXT,idx,(LPARAM)curtranslation);
            // cut the end off
            strstr (curtranslation, " translation")[0] = 0;
          }
          else
            curreplay[0] = 0;

          WritePrivateProfileString ("language", "translation",
              (idx == 0) ? NULL : curtranslation, ac_config_file);

          idx = SendDlgItemMessage(hDlg,IDC_REPLAYBOX,CB_GETCURSEL,0,0);
          if (idx > 0) {
            SendDlgItemMessage(hDlg,IDC_REPLAYBOX,CB_GETLBTEXT,idx,(LPARAM)curreplay);
            // cut the end bracket off
            curreplay[strlen(curreplay)-1] = 0;
            // get the filename
            char *fnptr = &strstr (curreplay, "File: ")[6];
            memmove (curreplay, fnptr, strlen (fnptr) + 1);
          }
          else
            curtranslation[0] = 0;
          WritePrivateProfileString ("misc", "replay",
              (idx == 0) ? NULL : curreplay, ac_config_file);

          idx = SendDlgItemMessage(hDlg,IDC_COMBO4,CB_GETCURSEL,0,0);
          SendDlgItemMessage(hDlg,IDC_COMBO4,CB_GETLBTEXT,idx,(LPARAM)tbuf);
          idx = atoi (tbuf);
          sprintf (tbuf, "%d", idx*1024);
          char *toWrite = &tbuf[0];
          // if it's the default, erase from config file
          if (idx == 20)
            toWrite = NULL;
          WritePrivateProfileString("misc","cachemax", toWrite,ac_config_file);

          if (SendDlgItemMessage(hDlg,IDC_SPEECHPACK,BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString ("sound", "usespeech", NULL, ac_config_file);
          else
            WritePrivateProfileString ("sound", "usespeech", "0", ac_config_file);

          if (SendDlgItemMessage(hDlg,IDC_WINDOWED,BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString("misc","windowed","1",ac_config_file);
          else
            WritePrivateProfileString("misc","windowed","0",ac_config_file);

          if (SendDlgItemMessage(hDlg,IDC_ANTIALIAS,BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString("misc","antialias","1",ac_config_file);
          else
            WritePrivateProfileString("misc","antialias",NULL,ac_config_file);

          if (SendDlgItemMessage(hDlg, IDC_SIDEBORDERS, BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString("misc","sideborders",NULL,ac_config_file);
          else
            WritePrivateProfileString("misc","sideborders","0",ac_config_file);

          if (SendDlgItemMessage(hDlg,IDC_REFRESH,BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString("misc","refresh","85",ac_config_file);
          else
            WritePrivateProfileString("misc","refresh","0",ac_config_file);

          if (mustBeLetterbox) ;
            // don't modify the Force Letterbox setting while it doesn't apply
          else if (SendDlgItemMessage(hDlg,IDC_LETTERBOX,BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString ("misc", "forceletterbox", "1", ac_config_file);
          else
            WritePrivateProfileString ("misc", "forceletterbox", NULL, ac_config_file);

          if (SendDlgItemMessage(hDlg, IDC_REDUCESPR, BM_GETCHECK,0,0) == BST_CHECKED)
            WritePrivateProfileString ("misc", "notruecolor", "1", ac_config_file);
          else
            WritePrivateProfileString ("misc", "notruecolor", NULL, ac_config_file);

          if (SendDlgItemMessage(hDlg, IDC_GFXDRIVER, CB_GETCURSEL,0,0) == 0)
            WritePrivateProfileString ("misc", "gfxdriver", "DX5", ac_config_file);
          else
            WritePrivateProfileString ("misc", "gfxdriver", "D3D9", ac_config_file);

          idx = SendDlgItemMessage(hDlg, IDC_GFXFILTER, CB_GETCURSEL, 0, 0);
          WritePrivateProfileString("misc", "gfxfilter", filterList[idx]->GetFilterID(), ac_config_file);
        }
	EndDialog(hDlg, LOWORD(wParam));
 	return TRUE;
      }
      return FALSE;
    default: return FALSE;
    }
  return TRUE;
  }
Esempio n. 4
0
INT_PTR CALLBACK TSIDE_ReferenceMessageProc (
                                             HWND   window,
                                             UINT   message,
                                             WPARAM wparam,
                                             LPARAM lparam
                                            )
{
    struct reference_data* data;
    NMHDR*                 notify_data;
    LRESULT                current_selection;
    int                    error;

    switch(message)
    {
    case WM_INITDIALOG:
        error = InitializeDialog(window);
        if(error != TSIDE_ERROR_NONE)
            goto initialize_dialog_failed;

        return TRUE;

    case WM_CLOSE:
        ShowWindow(tside_reference_window, SW_HIDE);

        return TRUE;

    case WM_DESTROY:
        data = (struct reference_data*)GetWindowLongPtr(window, GWLP_USERDATA);
        if(data == NULL)
            return FALSE;

        DestroyDialog(data);

        return TRUE;

    case WM_NOTIFY:
        data = (struct reference_data*)GetWindowLongPtr(window, GWLP_USERDATA);
        if(data == NULL)
            return FALSE;

        notify_data = (LPNMHDR)lparam;

        switch(notify_data->code)
        {
        case TCN_SELCHANGE:
            current_selection = SendMessage(data->tab_window, TCM_GETCURSEL, 0, 0);
            if(current_selection < 0)
                return TRUE;

            SetSelectedTab(current_selection, data);

            return TRUE;
        }
    }

    return FALSE;

initialize_dialog_failed:
    PostQuitMessage(TSIDE_ERROR_REFERENCE_ERROR);

    return FALSE;
}