void DSN_Set_Database(SQLHANDLE Connection)
{
  MADB_Stmt *Stmt= NULL;
  SQLRETURN ret= SQL_ERROR;
  char Database[65];
  MADB_Dsn *Dsn= (MADB_Dsn *)GetWindowLongPtr(GetParent(hwndTab[0]), DWLP_USER);
  

  if (DBFilled)
    return;

  GetDialogFields();
  
  if (SQLAllocHandle(SQL_HANDLE_STMT, Connection, (SQLHANDLE *)&Stmt) != SQL_SUCCESS)
    goto end;

  if (SQLExecDirect((SQLHSTMT)Stmt, (SQLCHAR *)"SHOW DATABASES", SQL_NTS) != SQL_SUCCESS)
    goto end;

  SQLBindCol(Stmt, 1, SQL_C_CHAR, Database, 65, 0);
  ComboBox_ResetContent(GetDlgItem(hwndTab[1], cbDatabase));
  while (SQLFetch(Stmt) == SQL_SUCCESS)
    ComboBox_InsertString(GetDlgItem(hwndTab[1], cbDatabase), -1, Database);
  if (Dsn->Catalog)
  {
    int Idx= ComboBox_FindString(GetDlgItem(hwndTab[2], cbDatabase), 0, Dsn->Catalog);
    ComboBox_SetCurSel(GetDlgItem(hwndTab[2], cbDatabase), Idx);
  }
  ComboBox_SetMinVisible(GetDlgItem(hwndTab[1], cbDatabase),5);
  DBFilled= TRUE;

end:
  if (Stmt)
	  SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE)Stmt);
}
Exemple #2
0
/*------------------------------------------------
--------------------------------------------------*/
int CALLBACK EnumSizeProcEx(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme, DWORD FontType, LPARAM lParam)
{
	HWND hwndSize = (HWND)lParam;
	const unsigned char nFontSizes[] = {4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,32,36,48,72};
	wchar_t str[8];
	int i, size, count;
	(void)lpelfe;
	
	// is modern font which supports any size?
	if((FontType&TRUETYPE_FONTTYPE) || !(FontType&RASTER_FONTTYPE)) {
		for(i=0; i<_countof(nFontSizes); ++i) {
			wsprintf(str, FMT("%hu"), nFontSizes[i]);
			ComboBox_AddString(hwndSize, str);
		}
		return 0;
	}
	
	// only add supported sizes for raster type fonts
	size = (lpntme->tmHeight - lpntme->tmInternalLeading) * 72 / m_logpixelsy;
	count = ComboBox_GetCount(hwndSize);
	for(i=0; i<count; ++i) { // dupes check + sorting
		ComboBox_GetLBText(hwndSize, i, str);
		if(size == _wtoi(str))
			return 1;
		else if(size < _wtoi(str)) {
			wsprintf(str, FMT("%d"), size);
			ComboBox_InsertString(hwndSize, i, str);
			return 1;
		}
	}
	wsprintf(str, FMT("%d"), size);
	ComboBox_AddString(hwndSize, str);
	return 1;
}
INT_PTR CWildcardSelectDialog::OnInitDialog()
{
	m_hDialogIcon = LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(IDI_MAIN_SMALL));
	SetClassLongPtr(m_hDlg,GCLP_HICONSM,reinterpret_cast<LONG_PTR>(m_hDialogIcon));

	HWND hComboBox = GetDlgItem(m_hDlg,IDC_SELECTGROUP_COMBOBOX);

	for each(auto strPattern in m_pwsdps->m_PatternList)
	{
		ComboBox_InsertString(hComboBox,-1,strPattern.c_str());
	}

	ComboBox_SetText(hComboBox,m_pwsdps->m_szPattern);

	if(!m_bSelect)
	{
		TCHAR szTemp[64];
		LoadString(GetInstance(),IDS_WILDCARDDESELECTION,
			szTemp,SIZEOF_ARRAY(szTemp));
		SetWindowText(m_hDlg,szTemp);
	}

	SetFocus(hComboBox);

	m_pwsdps->RestoreDialogPosition(m_hDlg,true);

	return 0;
}
Exemple #4
0
	void CComWnd::com_update_item_list()
	{
		list_callback_ud ud;
		ud.that = this;

		struct {
			list_callback_ud::e_type type;
			i_com_list* plist;
			HWND hwnd;
		} ups[] = {
			{list_callback_ud::e_type::cp, _comm.comports()->update_list() , _hCP},
			{list_callback_ud::e_type::br, _comm.baudrates()->update_list() , _hBR},
			{list_callback_ud::e_type::pa, _comm.parities()->update_list() , _hPA},
			{list_callback_ud::e_type::sb, _comm.stopbits()->update_list() , _hSB},
			{list_callback_ud::e_type::db, _comm.databits()->update_list() , _hDB},
		};

		for(int i=0; i<sizeof(ups)/sizeof(*ups); i++){
			ud.type = ups[i].type;
			ud.hwnd = ups[i].hwnd;
			ComboBox_ResetContent(ud.hwnd);
			ups[i].plist->callback(&CComWnd::com_udpate_list_callback, &ud);
			if (ComboBox_GetCount(ud.hwnd) > 0){
				ComboBox_SetCurSel(ud.hwnd, 0);
			}
		}

		int ii = ComboBox_InsertString(_hBR, -1, "<输入>");
		ComboBox_SetItemData(_hBR, ii, 1);	// 1 - 自定义
	}
Exemple #5
0
/*
 * TextInputKey:  User pressed a key on text input box.
 *   Return True iff key should NOT be passed on to Windows for default processing.
 */
Bool TextInputKey(HWND hwnd, UINT key, Bool fDown, int cRepeat, UINT flags)
{
   Bool held_down = (flags & 0x4000) ? True : False;  /* Is key being held down? */
   char string[MAXSAY + 1];
   int action;
   BOOL bValid;
   void *action_data;

   if (key == VK_RETURN && !held_down)
   {
      UserDidSomething();

      ComboBox_GetText(hwndInput, string, MAXSAY + 1);
      if (string[0] == 0)
	 return True;

      SetFocus(hMain);
      bValid = ParseGotText(string);

      // Add it to the history.
      if (*string && bValid)
      {
	 BOOL bAdd = TRUE;
	 int iCount;
	 char achHead[MAXSAY+1];
	 iCount = ComboBox_GetCount(hwndInput);
	 if (iCount > 0)
	 {
	    ComboBox_GetLBText(hwndInput, 0, achHead);
	    if (0 == strcmp(achHead, string))
	       bAdd = FALSE;
	 }
	 if (bAdd)
	 {
	    ComboBox_InsertString(hwndInput, 0, string);
	    if (iCount > EDITBOX_HISTORY)
	       ComboBox_DeleteString(hwndInput, iCount);
	 }
      }

      return True;
   }
   
   // Check for special keys
   action = TranslateKey(key, textin_key_table, &action_data);

   if (action == A_NOACTION)
      return False;

   PerformAction(action, action_data);

   return True;
}
	void UpdateItemList( const TreeItem& item ) {
		ClearOptionList();
		tjs_uint count = item.Select.size();
		for( tjs_uint i = 0; i < count; i++ ) {
			std::wstring itemstr = item.Select[i].second + std::wstring(L" / ") + item.Select[i].first;
			ComboBox_InsertString( OptionList, -1, itemstr.c_str() );
		}
		ComboBox_SetCurSel( OptionList, item.Value );
		count = count > 12 ? 12 : count;
		if( count <= 0 ) count = 1;
		int itemheight = ComboBox_GetItemHeight(OptionList);
		::SetWindowPos( OptionList, 0, 0, 0, OptionListWidth, itemheight * count + OptionListHeight + 2, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_HIDEWINDOW);
		::SetWindowPos( OptionList, 0, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
	}
int plResponderProc::AddState(IParamBlock2 *pb)
{
    int idx = fPB->Append(kResponderState, 1, (ReferenceTarget**)&pb);
    pb->SetValue(kStateCmdSwitch, 0, idx);

    char *name = "";
    fPB->Append(kResponderStateName, 1, &name);

    HWND hCombo = GetDlgItem(fhDlg, IDC_STATE_COMBO);
    char buf[128];
    sprintf(buf, "State %d", idx+1);
    ComboBox_InsertString(hCombo, idx, buf);
    ComboBox_SetCurSel(hCombo, idx);

    HWND hSwitch = GetDlgItem(fhDlg, IDC_SWITCH_COMBO);
    ComboBox_AddString(hSwitch, buf);

    return idx;
}
Exemple #8
0
/* This function fills the specified combo box with a list of all
 * signatures.
 */
void FASTCALL FillSignatureList( HWND hwnd, int id )
{
   register int n;
   FINDDATA ft;
   HWND hwndList;
   HFIND r;

   VERIFY( hwndList = GetDlgItem( hwnd, id ) );
   ComboBox_ResetContent( hwndList );
   for( n = r = AmFindFirst( "*.sig", DSD_SIG, _A_NORMAL, &ft ); n != -1; n = Amuser_FindNext( r, &ft ) )
      {
      register int i;

      for( i = 0; ft.name[ i ] && ft.name[ i ] != '.'; ++i );
      ft.name[ i ] = '\0';
      ComboBox_AddString( hwndList, ft.name );
      }
   Amuser_FindClose( r );
   ComboBox_InsertString( hwndList, 0, GS(IDS_STR946) );
}
void DSN_Set_CharacterSets(SQLHANDLE Connection)
{
  MADB_Stmt *Stmt= NULL;
  SQLRETURN ret= SQL_ERROR;
  char Charset[65];
  MADB_Dsn *Dsn= (MADB_Dsn *)GetWindowLongPtr(GetParent(hwndTab[0]), DWLP_USER);

  if (CSFilled)
    return;

  GetDialogFields();
  
  if (SQLAllocHandle(SQL_HANDLE_STMT, Connection, (SQLHANDLE *)&Stmt) != SQL_SUCCESS)
    goto end;

  if (SQLExecDirect((SQLHSTMT)Stmt, 
                    (SQLCHAR *)"select character_set_name from information_schema.collations "
                               "WHERE character_set_name NOT LIKE 'utf16%' AND "
                               "character_set_name NOT LIKE 'utf32%' AND "
                               "character_set_name NOT LIKE 'ucs2' "
                               "group by character_set_name order by character_set_name"
                               , SQL_NTS) != SQL_SUCCESS)
    goto end;

  SQLBindCol(Stmt, 1, SQL_C_CHAR, Charset, 65, 0);
  ComboBox_ResetContent(GetDlgItem(hwndTab[2], cbCharset));
  
  while (SQLFetch(Stmt) == SQL_SUCCESS)
    ComboBox_InsertString(GetDlgItem(hwndTab[2], cbCharset), -1, Charset);
  if (Dsn->CharacterSet)
  {
    int Idx= ComboBox_FindString(GetDlgItem(hwndTab[2], cbCharset), 0, Dsn->CharacterSet);
    ComboBox_SetCurSel(GetDlgItem(hwndTab[2], cbCharset), Idx);
  }
  ComboBox_SetMinVisible(GetDlgItem(hwndTab[2], cbCharset),5);
  CSFilled= TRUE;

end:
  if (Stmt)
	  SQLFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE)Stmt);
}
Exemple #10
0
// copy a ComboBox and select a given string
// Note : Since CB_IP has changed from text to a S_If structure
// this is not exactly a Copy function...
int CopyCBContent (HWND hFromCB, HWND hToCB, const char *lpszFind, int family)
{
int Rc=-1;
int Ark, n;
struct S_If 
{
	char  *descr;
	char  *addr;
} // Struct S_If 
*pif;
   // erase content
   ComboBox_ResetContent (hToCB);
   // get n of source items
   n = ComboBox_GetCount (hFromCB);
   // copy original combo
   for (Ark=0 ; Ark<n ; Ark++)
   {
	   pif = (struct S_If *) ComboBox_GetItemData (hFromCB, Ark);
	   // if AF_INET specified do not copy IPv6 address (the ones with : in the address)
	   if (! (family==AF_INET && strchr (pif->addr, ':')!=NULL)) ComboBox_AddString (hToCB, pif->addr);
   }
	  // locate string and select if found
   if (lpszFind!=NULL  && lpszFind[0]!=0)
   {
		Rc = ComboBox_FindStringExact (hToCB, 0, lpszFind);
		if (Rc==-1) 
		{
			// DHCP bound address is not present into the interface list
			// (because tftpd32.ini has been edited or interface address has changed...)
			char sz[128];
			sscanf (lpszFind, "%[0-9.:]", sz);
			lstrcat (sz, " [Bad Addr]");
			Rc = ComboBox_InsertString (hToCB, 0, sz);
		}
   }
   ComboBox_SetCurSel (hToCB, Rc==-1 ? 0 : Rc);
return Ark;
} // CopyCBContent
Exemple #11
0
static void PopulateForm(int32_t pgs)
{
    HWND hwnd;
    char buf[512];
    int32_t i,j;

    if (pgs & POPULATE_GAMEDIRS)
    {
        CACHE1D_FIND_REC *dirs = NULL;

        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCGAMEDIR);

        getfilenames("/");
        (void)ComboBox_ResetContent(hwnd);
        j = ComboBox_AddString(hwnd, "None");
        (void)ComboBox_SetItemData(hwnd, j, 0);
        (void)ComboBox_SetCurSel(hwnd, j);
        for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++)
        {
            (void)ComboBox_AddString(hwnd, dirs->name);
            (void)ComboBox_SetItemData(hwnd, i, i);
            if (Bstrcasecmp(dirs->name,settings.gamedir) == 0)
                (void)ComboBox_SetCurSel(hwnd, i);
        }
    }

    if (pgs & POPULATE_VIDEO)
    {
        int32_t mode;

        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);

        mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.flags&1, 1);
        if (mode < 0 || (settings.bpp < 15 && (settings.flags & 2)))
        {
            int32_t cd[] = { 32, 24, 16, 15, 8, 0 };
            for (i=0; cd[i];)
            {
                if (cd[i] >= settings.bpp) i++;
                else break;
            }
            for (; cd[i]; i++)
            {
                mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.flags&1, 1);
                if (mode < 0) continue;
                settings.bpp = cd[i];
                break;
            }
        }

        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), ((settings.flags&1) ? BST_CHECKED : BST_UNCHECKED));
        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCPOLYMER), ((settings.flags&2) ? BST_CHECKED : BST_UNCHECKED));

        (void)ComboBox_ResetContent(hwnd);

        for (i=0; i<validmodecnt; i++)
        {
            if (validmode[i].fs != (settings.flags & 1)) continue;
            if ((validmode[i].bpp < 15) && (settings.flags & 2)) continue;

            // all modes get added to the 3D mode list
            Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
            j = ComboBox_AddString(hwnd, buf);
            (void)ComboBox_SetItemData(hwnd, j, i);
            if (i == mode)(void)ComboBox_SetCurSel(hwnd, j);
        }
    }

    if (pgs & POPULATE_CONFIG)
    {
#if 0
        struct audioenumdev *d;
        char *n;

        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
        (void)ComboBox_ResetContent(hwnd);
        if (wavedevs)
        {
            d = wavedevs->devs;
            for (i=0; wavedevs->drvs[i]; i++)
            {
                strcpy(buf, wavedevs->drvs[i]);
                if (d->devs)
                {
                    strcat(buf, ":");
                    n = buf + strlen(buf);
                    for (j=0; d->devs[j]; j++)
                    {
                        strcpy(n, d->devs[j]);
                        (void)ComboBox_AddString(hwnd, buf);
                    }
                }
                else
                {
                    (void)ComboBox_AddString(hwnd, buf);
                }
                d = d->next;
            }
        }
#endif

        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
        Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCAUTOLOAD), (!(settings.flags & 4) ? BST_CHECKED : BST_UNCHECKED));

        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCINPUT);

        (void)ComboBox_ResetContent(hwnd);
        (void)ComboBox_SetCurSel(hwnd, 0);

        j = 4;

#ifdef RENDERTYPEWIN
        if (di_disabled) j = 2;
#endif

        for (i=0; i<j; i++)
        {
            (void)ComboBox_InsertString(hwnd, i, controlstrings[i]);
            (void)ComboBox_SetItemData(hwnd, i, i);

            switch (i)
            {
            case INPUT_MOUSE:
                if (settings.usemouse && !settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i);
                break;
            case INPUT_JOYSTICK:
                if (!settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i);
                break;
            case INPUT_ALL:
                if (settings.usemouse && settings.usejoy)(void)ComboBox_SetCurSel(hwnd, i);
                break;
            }
        }
    }

    if (pgs & POPULATE_GAME)
    {
        struct grpfile *fg;
        int32_t j;
        char buf[1024];

        hwnd = GetDlgItem(pages[TAB_CONFIG], IDCDATA);

        for (fg = foundgrps; fg; fg=fg->next)
        {
            struct grpfile *grp;
            for (grp = listgrps; grp; grp=grp->next)
                if (fg->crcval == grp->crcval) break;

            if (grp == NULL)
                continue;

            Bsprintf(buf, "%s\t%s", grp->name, fg->name);
            j = ListBox_AddString(hwnd, buf);
            (void)ListBox_SetItemData(hwnd, j, (LPARAM)fg);
            if (!Bstrcasecmp(fg->name, settings.selectedgrp))
            {
                (void)ListBox_SetCurSel(hwnd, j);
                settings.game = fg->game;
                settings.crcval = fg->crcval;
            }
        }
    }
}
BOOL plResponderProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static UINT dragListMsg = 0;

    if (dragListMsg != 0 && msg == dragListMsg)
        if (DragListProc(hWnd, (DRAGLISTINFO*)lParam))
            return TRUE;

    switch (msg)
    {
    case WM_INITDIALOG:
        {
            if (!fhMenu)
                ICreateMenu();

            fhDlg = hWnd;
            fhList = GetDlgItem(fhDlg, IDC_CMD_LIST);
            fCurState = 0;
            fCmdIdx = -1;
            
            fPB = pm->GetParamBlock();
            fComp = (plResponderComponent*)fPB->GetOwner();

            fComp->IFixOldPB();

            LoadState();
            
            // Make it so the user can drag commands to different positions
            dragListMsg = RegisterWindowMessage(DRAGLISTMSGSTRING);
            MakeDragList(GetDlgItem(hWnd, IDC_CMD_LIST));

            // Setup the State Name combo
            HWND hStateName = GetDlgItem(hWnd, IDC_STATE_COMBO);
            ComboBox_LimitText(hStateName, 256);

// I give up, Windows doesn't want to tell me the real font size
#if 0//def CUSTOM_DRAW
            // TEMP
            HDC hDC = GetDC(hStateName);
            HFONT sysFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            HFONT oldFont = SelectFont(hDC, sysFont);

            TEXTMETRIC tm;
            GetTextMetrics(hDC, &tm);
            ComboBox_SetItemHeight(hStateName, 0, tm.tmHeight+2);

            DeleteFont(SelectFont(hDC, oldFont));
            ReleaseDC(hStateName, hDC);
#endif

            // Add the commands
            int idx = ComboBox_AddString(hStateName, "Add State");
            ComboBox_SetItemData(hStateName, idx, kStateAdd);
            idx = ComboBox_AddString(hStateName, "Remove Current State");
            ComboBox_SetItemData(hStateName, idx, kStateRemove);
            idx = ComboBox_AddString(hStateName, "Set Current as Default");
            ComboBox_SetItemData(hStateName, idx, kStateDefault);
            idx = ComboBox_AddString(hStateName, "Copy Current State");
            ComboBox_SetItemData(hStateName, idx, kStateCopy);

            HWND hSwitchCombo = GetDlgItem(hWnd, IDC_SWITCH_COMBO);

            int numStates = fPB->Count(kResponderStateName);
            for (int i = 0; i < numStates; i++)
            {
                const char *stateName = fPB->GetStr(kResponderStateName, 0, i);
                char buf[128];
                if (!stateName || *stateName == '\0')
                {
                    sprintf(buf, "State %d", i+1);
                    stateName = buf;
                }
                ComboBox_InsertString(hStateName, i, stateName);
                ComboBox_AddString(hSwitchCombo, stateName);
            }

            ComboBox_SetCurSel(hStateName, fCurState);

            ComboBox_SetCurSel(hSwitchCombo, fStatePB->GetInt(kStateCmdSwitch));
        }
        return TRUE;

#ifdef CUSTOM_DRAW
    case WM_DRAWITEM:
        if (wParam == IDC_STATE_COMBO)
        {
            IDrawComboItem((DRAWITEMSTRUCT*)lParam);
            return TRUE;
        }
        break;
#endif

    case WM_SETCURSOR:
        {
            if (HIWORD(lParam) == WM_RBUTTONDOWN && HWND(wParam) == GetDlgItem(hWnd, IDC_CMD_LIST))
            {
                ICmdRightClick(HWND(wParam));
                return TRUE;
            }
        }
        break;
    
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_ADD_ACTIVATOR)
            {
                // Adding an activator.  Set it and refresh the UI to show it in our list.
                plPick::Activator(fPB, kResponderActivators, false);
                pm->Invalidate(kResponderActivators);
                return TRUE;
            }
            else if (LOWORD(wParam) == IDC_ADD_CMD)
            {
                AddCommand();
                return TRUE;
            }
            // Remove the currently selected condition
            else if (LOWORD(wParam) == IDC_REMOVE_CMD)
            {
                RemoveCurCommand();
                return TRUE;
            }
        }
        else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_CMD_LIST)
        {
            ICreateCmdRollups();
            return TRUE;
        }
        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SWITCH_COMBO)
        {
            int sel = ComboBox_GetCurSel((HWND)lParam);
            if (sel != CB_ERR)
                fStatePB->SetValue(kStateCmdSwitch, 0, sel);
        }
        else if (LOWORD(wParam) == IDC_STATE_COMBO)
        {
            HWND hCombo = (HWND)lParam;
            int code = HIWORD(wParam);

            // Disable accelerators when the combo has focus, so that new names can be typed in
            if (code == CBN_SETFOCUS)
            {
                plMaxAccelerators::Disable();
                return TRUE;
            }
            else if (code == CBN_KILLFOCUS)
            {
                plMaxAccelerators::Enable();
                return TRUE;
            }
            // State name changed, save it in the PB
            else if (code == CBN_EDITCHANGE)
            {
                char buf[256];
                ComboBox_GetText(hCombo, buf, sizeof(buf));
                const char *curName = fPB->GetStr(kResponderStateName, 0, fCurState);
                if (!curName || strcmp(buf, curName))
                {
                    HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO);
                    int sel = ComboBox_GetCurSel(hSwitch);
                    ComboBox_DeleteString(hSwitch, fCurState);
                    ComboBox_InsertString(hSwitch, fCurState, buf);
                    ComboBox_SetCurSel(hSwitch, sel);
                    
                    fPB->SetValue(kResponderStateName, 0, buf, fCurState);
                    ComboBox_DeleteString(hCombo, fCurState);
                    ComboBox_InsertString(hCombo, fCurState, buf);
//                  ComboBox_SetCurSel(hCombo, fCurState);
                }

                return TRUE;
            }
            else if (code == CBN_SELCHANGE)
            {
                int sel = ComboBox_GetCurSel(hCombo);
                int type = ComboBox_GetItemData(hCombo, sel);

                if (type == kStateAdd)
                {
                    IParamBlock2 *pb = CreateParameterBlock2(&gStateBlock, nil);
                    fCurState = AddState(pb);
                    fCmdIdx = -1;
                }
                else if (type == kStateRemove)
                {
                    int count = fPB->Count(kResponderState);
                    // Don't let the user remove the last state
                    if (count == 1)
                    {
                        hsMessageBox("You must have at least one state.", "Error", hsMessageBoxNormal);
                        ComboBox_SetCurSel(hCombo, fCurState);
                        return TRUE;
                    }
                    // Verify that the user really wants to delete the state
                    else
                    {
                        int ret = hsMessageBox("Are you sure you want to remove this state?", "Verify Remove", hsMessageBoxYesNo);
                        if (ret == hsMBoxNo)
                        {
                            ComboBox_SetCurSel(hCombo, fCurState);
                            return TRUE;
                        }
                    }

                    fPB->Delete(kResponderState, fCurState, 1);
                    fPB->Delete(kResponderStateName, fCurState, 1);

                    ComboBox_DeleteString(hCombo, fCurState);
                    ComboBox_SetCurSel(hCombo, 0);

                    HWND hSwitch = GetDlgItem(hWnd, IDC_SWITCH_COMBO);
                    ComboBox_DeleteString(hSwitch, fCurState);

                    // If the deleted state was the default, set the default to the first
                    int defState = fPB->GetInt(kResponderStateDef);
                    if (fCurState == defState)
                        fPB->SetValue(kResponderStateDef, 0, 0);
                    else if (fCurState < defState)
                        fPB->SetValue(kResponderStateDef, 0, defState-1);

                    // Patch up the switch commands
                    for (int i = fCurState; i < fPB->Count(kResponderState); i++)
                    {
                        IParamBlock2 *pb = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, i);

                        int switchState = pb->GetInt(kStateCmdSwitch);
                        // TODO: might want to warn about this
                        if (switchState == fCurState)
                            pb->SetValue(kStateCmdSwitch, 0, 0);
                        else if (switchState > fCurState)
                            pb->SetValue(kStateCmdSwitch, 0, switchState-1);
                    }

                    fCurState = 0;
                    fCmdIdx = -1;
                }
                else if (type == kStateDefault)
                {
                    // Set the current state as the default
                    fPB->SetValue(kResponderStateDef, 0, fCurState);
                    ComboBox_SetCurSel(hCombo, fCurState);
                }
                else if (type == kStateCopy)
                {
                    // Clone the state PB
                    IParamBlock2 *origPB = (IParamBlock2*)fPB->GetReferenceTarget(kResponderState, 0, fCurState);
                    IParamBlock2 *copyPB = (IParamBlock2*)origPB->Clone(gMyRemapDir);
                    fCurState = AddState(copyPB);
                    fCmdIdx = -1;
                }
                else
                {
                    fCurState = sel;
                    fCmdIdx = -1;
                }

                LoadState();

                return TRUE;
            }
        }
    }

    return FALSE;
}
Exemple #13
0
INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{

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

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

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

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

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	

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

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

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

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

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

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

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

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

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

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

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

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

						bRedrawList = true;
					}

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

						bRedrawList = true;
					}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

					if(bRedrawList)
						UpdateListView();

					SaveInternalUI();
					return true;
				}

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

			break;
	}

	return false;
}
static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
	int i, current_index, driver_index;
	const game_driver *gamedrv;
	UINT32 ram, current_ram;
	const char *this_ram_string;
	TCHAR* t_ramstring;
	const device_t *device;

	// identify the driver
	driver_index = PropertiesCurrentGame(dialog);
	gamedrv = &driver_list::driver(driver_index);

	// clear out the combo box
	(void)ComboBox_ResetContent(control);

	// allocate the machine config
	machine_config cfg(*gamedrv,*opts);

	// identify how many options that we have
	device = cfg.devicelist().first(RAM);

	EnableWindow(control, (device != NULL));
	i = 0;
	// we can only do something meaningful if there is more than one option
	if (device != NULL)
	{
		ram_config *config = (ram_config *)downcast<const legacy_device_base *>(device)->inline_config();

		// identify the current amount of RAM
		this_ram_string = opts->value(OPTION_RAMSIZE);
		current_ram = (this_ram_string != NULL) ? ram_parse_string(this_ram_string) : 0;
		if (current_ram == 0)
			current_ram = ram_parse_string(config->default_size);

		// by default, assume index 0
		current_index = 0;

		{
			ram = ram_parse_string(config->default_size);
			t_ramstring = tstring_from_utf8(config->default_size);
			if( !t_ramstring )
				return FALSE;

			(void)ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
			(void)ComboBox_SetItemData(control, i, ram);

			osd_free(t_ramstring);
		}
		if (config->extra_options != NULL)
		{
			int j;
			int size = strlen(config->extra_options);
			char * const s = mame_strdup(config->extra_options);
			char * const e = s + size;
			char *p = s;
			for (j=0;j<size;j++) {
				if (p[j]==',') p[j]=0;
			}

			/* try to parse each option */
			while(p <= e)
			{
				i++;
				// identify this option
				ram = ram_parse_string(p);

				this_ram_string = p;

				t_ramstring = tstring_from_utf8(this_ram_string);
				if( !t_ramstring )
					return FALSE;

				// add this option to the combo box
				(void)ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
				(void)ComboBox_SetItemData(control, i, ram);

				osd_free(t_ramstring);

				// is this the current option?  record the index if so
				if (ram == current_ram)
					current_index = i;

				p+= strlen(p);
				if (p == e)
					break;

				p += 1;
			}

			osd_free(s);
		}

		// set the combo box
		(void)ComboBox_SetCurSel(control, current_index);
	}
	return TRUE;
}
Exemple #15
0
INT_PTR CALLBACK PhpChoiceDlgProc(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
    )
{
    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            PCHOICE_DIALOG_CONTEXT context = (PCHOICE_DIALOG_CONTEXT)lParam;
            ULONG type;
            SIZE_T i;
            HWND comboBoxHandle;
            HWND checkBoxHandle;
            RECT checkBoxRect;
            RECT rect;
            ULONG diff;

            SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)context);
            PhCenterWindow(hwndDlg, GetParent(hwndDlg));

            SetWindowText(hwndDlg, context->Title);
            SetWindowText(GetDlgItem(hwndDlg, IDC_MESSAGE), context->Message);

            type = context->Flags & PH_CHOICE_DIALOG_TYPE_MASK;

            // Select the control to show, depending on the type. This is
            // because it is impossible to change the style of the combo box
            // after it is created.
            switch (type)
            {
            case PH_CHOICE_DIALOG_USER_CHOICE:
                comboBoxHandle = GetDlgItem(hwndDlg, IDC_CHOICEUSER);
                ShowWindow(GetDlgItem(hwndDlg, IDC_CHOICEUSER), SW_SHOW);
                break;
            case PH_CHOICE_DIALOG_PASSWORD:
                comboBoxHandle = GetDlgItem(hwndDlg, IDC_CHOICESIMPLE);
                ShowWindow(GetDlgItem(hwndDlg, IDC_CHOICESIMPLE), SW_SHOW);

                // Disable combo box features since it isn't a combo box.
                context->SavedChoicesSettingName = NULL;
                break;
            case PH_CHOICE_DIALOG_CHOICE:
            default:
                comboBoxHandle = GetDlgItem(hwndDlg, IDC_CHOICE);
                ShowWindow(GetDlgItem(hwndDlg, IDC_CHOICE), SW_SHOW);
                break;
            }

            context->ComboBoxHandle = comboBoxHandle;

            checkBoxHandle = GetDlgItem(hwndDlg, IDC_OPTION);

            if (type == PH_CHOICE_DIALOG_PASSWORD)
            {
                // Nothing
            }
            else if (type == PH_CHOICE_DIALOG_USER_CHOICE && context->SavedChoicesSettingName)
            {
                PPH_STRING savedChoices = PhGetStringSetting(context->SavedChoicesSettingName);
                ULONG_PTR indexOfDelim;
                PPH_STRING savedChoice;

                i = 0;

                // Split the saved choices using the delimiter.
                while (i < savedChoices->Length / 2)
                {
                    // BUG BUG BUG - what if the user saves "\s"?
                    indexOfDelim = PhFindStringInString(savedChoices, i, L"\\s");

                    if (indexOfDelim == -1)
                        indexOfDelim = savedChoices->Length / 2;

                    savedChoice = PhSubstring(savedChoices, i, indexOfDelim - i);

                    if (savedChoice->Length != 0)
                    {
                        PPH_STRING unescaped;

                        unescaped = PhUnescapeStringForDelimiter(savedChoice, '\\');
                        ComboBox_InsertString(comboBoxHandle, -1, unescaped->Buffer);
                        PhDereferenceObject(unescaped);
                    }

                    PhDereferenceObject(savedChoice);

                    i = indexOfDelim + 2;
                }

                PhDereferenceObject(savedChoices);
            }
            else
            {
                for (i = 0; i < context->NumberOfChoices; i++)
                {
                    ComboBox_AddString(comboBoxHandle, context->Choices[i]);
                }

                context->SavedChoicesSettingName = NULL; // make sure we don't try to save the choices
            }

            if (type == PH_CHOICE_DIALOG_PASSWORD)
            {
                if (*context->SelectedChoice)
                    SetWindowText(comboBoxHandle, (*context->SelectedChoice)->Buffer);

                Edit_SetSel(comboBoxHandle, 0, -1);
            }
            else if (type == PH_CHOICE_DIALOG_USER_CHOICE || type == PH_CHOICE_DIALOG_CHOICE)
            {
                // If we failed to choose a default choice based on what was specified,
                // select the first one if possible, or set the text directly.
                if (!(*context->SelectedChoice) || PhSelectComboBoxString(
                    comboBoxHandle, (*context->SelectedChoice)->Buffer, FALSE) == CB_ERR)
                {
                    if (type == PH_CHOICE_DIALOG_USER_CHOICE && *context->SelectedChoice)
                    {
                        SetWindowText(comboBoxHandle, (*context->SelectedChoice)->Buffer);
                    }
                    else if (type == PH_CHOICE_DIALOG_CHOICE && context->NumberOfChoices != 0)
                    {
                        ComboBox_SetCurSel(comboBoxHandle, 0);
                    }
                }

                if (type == PH_CHOICE_DIALOG_USER_CHOICE)
                    ComboBox_SetEditSel(comboBoxHandle, 0, -1);
            }

            if (context->Option)
            {
                SetWindowText(checkBoxHandle, context->Option);

                if (context->SelectedOption)
                    Button_SetCheck(checkBoxHandle, *context->SelectedOption ? BST_CHECKED : BST_UNCHECKED);
            }
            else
            {
                // Hide the check box and move the buttons up.

                ShowWindow(checkBoxHandle, SW_HIDE);
                GetWindowRect(checkBoxHandle, &checkBoxRect);
                MapWindowPoints(NULL, hwndDlg, (POINT *)&checkBoxRect, 2);
                GetWindowRect(GetDlgItem(hwndDlg, IDOK), &rect);
                MapWindowPoints(NULL, hwndDlg, (POINT *)&rect, 2);
                diff = rect.top - checkBoxRect.top;

                // OK
                rect.top -= diff;
                rect.bottom -= diff;
                SetWindowPos(GetDlgItem(hwndDlg, IDOK), NULL, rect.left, rect.top,
                    rect.right - rect.left, rect.bottom - rect.top,
                    SWP_NOACTIVATE | SWP_NOZORDER);

                // Cancel
                GetWindowRect(GetDlgItem(hwndDlg, IDCANCEL), &rect);
                MapWindowPoints(NULL, hwndDlg, (POINT *)&rect, 2);
                rect.top -= diff;
                rect.bottom -= diff;
                SetWindowPos(GetDlgItem(hwndDlg, IDCANCEL), NULL, rect.left, rect.top,
                    rect.right - rect.left, rect.bottom - rect.top,
                    SWP_NOACTIVATE | SWP_NOZORDER);

                // Window
                GetWindowRect(hwndDlg, &rect);
                rect.bottom -= diff;
                SetWindowPos(hwndDlg, NULL, rect.left, rect.top,
                    rect.right - rect.left, rect.bottom - rect.top,
                    SWP_NOACTIVATE | SWP_NOZORDER);
            }

            SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)comboBoxHandle, TRUE);
        }
        break;
    case WM_DESTROY:
        {
            RemoveProp(hwndDlg, PhMakeContextAtom());
        }
        break;
    case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
            case IDCANCEL:
                EndDialog(hwndDlg, IDCANCEL);
                break;
            case IDOK:
                {
                    PCHOICE_DIALOG_CONTEXT context = (PCHOICE_DIALOG_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom());
                    PPH_STRING selectedChoice;

                    if ((context->Flags & PH_CHOICE_DIALOG_TYPE_MASK) != PH_CHOICE_DIALOG_PASSWORD)
                    {
                        selectedChoice = PH_AUTO(PhGetWindowText(context->ComboBoxHandle));
                        *context->SelectedChoice = selectedChoice;
                    }
                    else
                    {
                        // Password values are never auto-dereferenced.
                        selectedChoice = PhGetWindowText(context->ComboBoxHandle);
                        *context->SelectedChoice = selectedChoice;
                    }

                    if (context->Option && context->SelectedOption)
                        *context->SelectedOption = Button_GetCheck(GetDlgItem(hwndDlg, IDC_OPTION)) == BST_CHECKED;

                    if (context->SavedChoicesSettingName)
                    {
                        PH_STRING_BUILDER savedChoices;
                        ULONG i;
                        ULONG choicesToSave = PH_CHOICE_DIALOG_SAVED_CHOICES;
                        PPH_STRING choice;
                        PPH_STRING escaped;

                        PhInitializeStringBuilder(&savedChoices, 100);

                        // Push the selected choice to the top, then save the others.

                        if (selectedChoice->Length != 0)
                        {
                            escaped = PhEscapeStringForDelimiter(selectedChoice, '\\');
                            PhAppendStringBuilder(&savedChoices, &escaped->sr);
                            PhDereferenceObject(escaped);
                            PhAppendStringBuilder2(&savedChoices, L"\\s");
                        }

                        for (i = 1; i < choicesToSave; i++)
                        {
                            choice = PhGetComboBoxString(context->ComboBoxHandle, i - 1);

                            if (!choice)
                                break;

                            // Don't save the choice if it's the same as the one
                            // entered by the user (since we already saved it above).
                            if (PhEqualString(choice, selectedChoice, FALSE))
                            {
                                PhDereferenceObject(choice);
                                choicesToSave++; // useless for now, but may be needed in the future
                                continue;
                            }

                            escaped = PhEscapeStringForDelimiter(choice, '\\');
                            PhAppendStringBuilder(&savedChoices, &escaped->sr);
                            PhDereferenceObject(escaped);
                            PhDereferenceObject(choice);

                            PhAppendStringBuilder2(&savedChoices, L"\\s");
                        }

                        if (PhEndsWithString2(savedChoices.String, L"\\s", FALSE))
                            PhRemoveEndStringBuilder(&savedChoices, 2);

                        PhSetStringSetting2(context->SavedChoicesSettingName, &savedChoices.String->sr);
                        PhDeleteStringBuilder(&savedChoices);
                    }

                    EndDialog(hwndDlg, IDOK);
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
LRESULT CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   static SQLHENV henv;
   static SQLHDBC hdbc;
   static SQLHSTMT hstmt;
   static int ifconnect=0;
   static SQLCHAR server[32];
   static char Content[10240] ;
   static RECT rect;
   static PAINTSTRUCT ps;
   static HBRUSH hbrush;	
   static HDC hDC ;
	static RedrawFlag = 0;
	LPDRAWITEMSTRUCT pdis;
	//~ char Content2[10240] ;
	SQLCHAR sqlstr[1024];	
	SQLRETURN retcode;
 
	//~ SQLHENV env;
	char dsn[256];
	char desc[256];
	SQLSMALLINT dsn_ret;
	SQLSMALLINT desc_ret;
	SQLUSMALLINT direction;
	SQLRETURN ret;
	HWND hEditTN = GetDlgItem(hwndDlg, IDC_EDIT1);
	HWND hEdit = GetDlgItem(hwndDlg, IDC_EDIT2);
	HWND hCBox = GetDlgItem(hwndDlg,IDC_COMBO1);
	HWND hBTN1 = GetDlgItem(hwndDlg,IDC_BUTTON1);
	int curSel;
	char szTable[256]; // receives name of item to delete. 
	LPDRAWITEMSTRUCT dItem;
	char text[20];
	int len;
	SIZE sz;

	GetWindowRect(hBTN1,&rect);
	
	switch (uMsg)
	{

	case WM_INITDIALOG:// WM_INITDIALOG message is sent before dialog is displayed
		{
		   // Allocate environment handle
		   retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
		   // Set the ODBC version environment attribute
		   if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
			  retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
		   }
		   else {
					MessageBoxPrintf("Prompt","fail to SQLAllocHandle SQL_HANDLE_ENV\n");
					return FALSE;
			}
			
		  direction = SQL_FETCH_FIRST;
		  while(SQL_SUCCEEDED(ret = SQLDataSources(henv, direction,
							   dsn, sizeof(dsn), &dsn_ret,
							   desc, sizeof(desc), &desc_ret))) 
		  {
			direction = SQL_FETCH_NEXT;
			//MessageBoxPrintf("DSN","%s\n",dsn);
			ComboBox_InsertString(hCBox,0,dsn);								   
			if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
		  }
			
			return TRUE;
		}
		break;
	case WM_COMMAND://
		{
			switch (LOWORD(wParam)) 
            { 
                // Process the accelerator and menu commands. 
 
                case ID_ACCELERATOR1: 
				//~ MessageBoxPrintf("hi","hello");
				//~ GetModuleHandle()
				SendMessage(hEdit, EM_SETSEL,(WPARAM)0,(LPARAM) sizeof(Content)/sizeof(char));
			return TRUE;
			}
			
			switch(wParam)
			{
				case IDC_BUTTON1:
				{
					//disconnect
					if (ifconnect) {
						retcode = SQLDisconnect(hdbc);	
					   if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
							SetWindowText(GetDlgItem(hwndDlg, IDC_BUTTON1), (LPCTSTR )"Connect");				   
							//~ MessageBoxPrintf("Prompt","Disconnected from %s!\n",server);
							ifconnect = 0;
						InvalidateRect(GetDlgItem(hwndDlg, IDC_BUTTON1),NULL, TRUE);  
						UpdateWindow(GetDlgItem(hwndDlg, IDC_BUTTON1));						   
							return 0;
					   }
					   //~ else
					   //~ {
							//~ MessageBoxPrintf("Prompt","Not Connect yet!\n");						
						//~ }
					}

					  // Allocate connection handle
						 retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
					  if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
							 // Set login timeout to 5 seconds					  
							SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)5, 0);	
					  }
					  else{
							SQLFreeHandle(SQL_HANDLE_DBC, hdbc);  
							SQLFreeHandle(SQL_HANDLE_ENV, henv);								
							return FALSE;					  
					  }

					// Connect to data source
						if(!ComboBox_GetTextLength(hCBox)){
							MessageBoxPrintf("ERROR","Please Select an Item!");
							return FALSE;
						}
						curSel=ComboBox_GetCurSel(hCBox);
						ComboBox_GetLBText(hCBox,curSel,server);
						retcode = SQLConnect(
						hdbc
						, (SQLCHAR*) server
						, SQL_NTS
						, (SQLCHAR*) NULL
						, 0
						, NULL
						, 0);
					  
					if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
						ifconnect=1;
						SetWindowText(GetDlgItem(hwndDlg, IDC_BUTTON1), (LPCTSTR )"Connected");
						RedrawFlag=1;
						//~ SendMessage(hBTN1, WM_CTLCOLORBTN, (WPARAM)GetWindowDC(hBTN1), (LPARAM)hBTN1);
						//~ SendDlgItemMessage(hwndDlg,IDC_BUTTON1
						//~ ,WM_CTLCOLORBTN,(WPARAM)GetWindowDC(hBTN1), (LPARAM)hBTN1);
						InvalidateRect(GetDlgItem(hwndDlg, IDC_BUTTON1),NULL, TRUE);  
						UpdateWindow(GetDlgItem(hwndDlg, IDC_BUTTON1));
						//~ InvalidateRect(hwndDlg,NULL,TRUE);
						//~ MessageBoxPrintf("Prompt","Connected to %s!\n" ,server);							
					}
					else {
						MessageBoxPrintf("Prompt","Fail to Connect to %s!\n",server);	
						ShowDBStmtError(hwndDlg,hdbc);								
					}
				}
				break;
				
				case IDC_BUTTON3:
				{
					//~ MessageBoxPrintf("INFO","length:%d\n",Edit_GetTextLength(hEdit));
					if(!Edit_GetTextLength(hEditTN)){
						MessageBoxPrintf("Error","[SKM.]TABNAME");
						return FALSE;
					}
					
					ZeroMemory(Content,sizeof(Content)/sizeof(char));
					SetDlgItemText(hwndDlg,IDC_EDIT2,Content);										
					if (!ifconnect) {
						MessageBoxPrintf("Prompt","Not Connect yet!\n");						
						return 0;
					}
					//初始化语句句柄
					retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
					//SQL_NTS telling the function the previous parameter is Null-Terminated String, 
					//please alculate the string length for me
                    if (!GetDlgItemText(hwndDlg, IDC_EDIT1, szTable, sizeof(szTable)/sizeof(SQLCHAR))) 
					{
						*szTable=0;
						MessageBoxPrintf("","%s\n",sqlstr);
					}
					
					// 判断表是否存在
					wsprintf(sqlstr,"select count(0) from syscat.columns where tabname = upper('%s')",szTable);
					retcode = SQLPrepare(hstmt,(SQLCHAR*)sqlstr,SQL_NTS);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					retcode =SQLExecute(hstmt);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					while ( SQLFetch(hstmt) != SQL_NO_DATA_FOUND ){
						SQLINTEGER id=0;
						SQLGetData(hstmt,1,SQL_C_ULONG,&id,sizeof(SQLINTEGER),(SQLINTEGER*)NULL);
						if(0==id){
						MessageBoxPrintf("ERROR","TABLE <%s> does not exists!",szTable);
							return FALSE;
						}
					}
					SQLFreeStmt(hstmt,SQL_CLOSE);

					// do the job
					wsprintf(sqlstr,"select COLNAME from syscat.columns where tabname = upper('%s') ORDER BY COLNO ASC",szTable);
					retcode = SQLPrepare(hstmt,(SQLCHAR*)sqlstr,SQL_NTS);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					retcode =SQLExecute(hstmt);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					while ( SQLFetch(hstmt) != SQL_NO_DATA_FOUND ){
						//~ SQLINTEGER id=0;
						char name[32];
						ZeroMemory(name,sizeof(name)/sizeof(char));
						//~ SQLGetData(hstmt,1,SQL_C_ULONG,&id,sizeof(SQLINTEGER),(SQLINTEGER*)NULL);
						SQLGetData(hstmt,1,SQL_C_CHAR,name,sizeof(name)/sizeof(SQLCHAR),(SQLINTEGER*)NULL);
						//~ MessageBoxPrintf("Result","%s",name);
						strncat(Content,name,32);
						strncat(Content,"\r\n,",32);
					}
					*(Content+strlen(Content)-1)=0;
					//~ strncpy(Content2,Content,strlen(Content)-2);
					SetDlgItemText(hwndDlg,IDC_EDIT2,Content);
					//~ SendMessage(hEdit, EM_LINESCROLL, 0, 80);//WS_VSCROLL
					SQLFreeStmt(hstmt,SQL_CLOSE);
				}				
				default:
					break;
			}
			return TRUE;
		}
		break;
		
	case WM_CTLCOLORBTN:
			//~ hDC = BeginPaint((HWND)wParam, &ps);
			//~ FillRect(hDC, &rect, hbrush);
			//~ EndPaint((HWND)wParam, &ps);		
			//~ if(RedrawFlag){
				//~ hbrush = CreateSolidBrush(RGB(0,255,0));			
				//~ SetTextColor((HDC)wParam,RGB(0,0,0));						
				//~ SetBkColor((HDC)wParam,RGB(0,255,0));
			//~ return (long)hbrush ;
			//~ }
			//~ else 
			//~ {
				//~ SetTextColor((HDC)wParam,RGB(255,0,0));	
				//~ SetBkColor((HDC)wParam,RGB(0,0,0));		
				//~ SetBkMode((HDC)wParam, TRANSPARENT);
				//~ return (long)hbrush ;
			//~ }
	break;
	
	case WM_CLOSE://Massage for terminate/exit (may close button clicked on title bar)
		{
			//Close dialog
			SQLFreeStmt(hstmt,SQL_CLOSE);	
			SQLDisconnect(hdbc);	
			SQLFreeHandle(SQL_HANDLE_DBC, hdbc);  
			SQLFreeHandle(SQL_HANDLE_ENV, henv);					
			//~ EndDialog(hwndDlg,0);
			DestroyWindow(hwndDlg);			
			break;
		}
	case WM_DESTROY:
		{
			PostQuitMessage(0); 
			return TRUE;
		}
	case WM_CTLCOLORDLG: //set its text and background colors using the specified display device context handle.
		{
			break;			
		}
	case WM_PAINT:
		{
			if (RedrawFlag == 1){
				hbrush = CreateSolidBrush(RGB(0,255,0));
				hDC = BeginPaint(hBTN1, &ps);
				FillRect(hDC, &rect, hbrush);
				EndPaint(hBTN1, &ps);
				return (LONG)hbrush;
			}
			break;	
		}
	case WM_DRAWITEM:
	{
				dItem = (DRAWITEMSTRUCT*)lParam;
				if (ifconnect){
				SetBkColor(dItem->hDC, RGB(0,255,0));				
					}
					else
					{
				SetBkColor(dItem->hDC, RGB(255,0,0));						
					}
                //~ SetTextColor(dItem->hDC, RGB(0,0,0xFF));
				memset(text, '\0', 20);

				GetWindowText(dItem->hwndItem, text, 20);
				len=lstrlen(text);

				GetTextExtentPoint32(dItem->hDC, text, len, &sz);

				ExtTextOut( dItem->hDC
							, ((dItem->rcItem.right - dItem->rcItem.left) / 2) + dItem->rcItem.left - (sz.cx / 2)
							, ((dItem->rcItem.bottom - dItem->rcItem.top) / 2) + dItem->rcItem.top - (sz.cy / 2)
							, ETO_OPAQUE | ETO_CLIPPED, &dItem->rcItem, text, len, NULL);

				DrawEdge( dItem->hDC, &dItem->rcItem
						, (dItem->itemState & ODS_SELECTED ? BDR_SUNKENOUTER : BDR_RAISEDOUTER), BF_RECT);
                return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
break;			
		
	}
	case WM_CTLCOLORSTATIC: //可以控制静态控件的颜色
		{
			break;			
		}
	default:
		break;			
	}
	return FALSE;
}
Exemple #17
0
/* This function handles the WM_INITDIALOG message.
 */
BOOL FASTCALL SortMailFrom_OnInitDialog( HWND hwnd, HWND hwndFocus, LPARAM lParam )
{
   LPWINDINFO lpWindInfo;
   MSGINFO msginfo;
   HWND hwndList;
   HWND hwndEdit;
   HWND hwndName;
   int index;
   PCAT pcat;
   PCL pcl;
   PTL ptl;

   /* Must have a message window open.
    */
   if( NULL == hwndTopic )
      {
      EndDialog( hwnd, 0 );
      return( FALSE );
      }

   /* Get details of the message we'll be using and set the
    * static text field in the dialog. If there is no author field (shouldn't
    * be possible now) we tell the user and quit the dialog.
    */
   lpWindInfo = GetBlock( hwndTopic );
   Amdb_GetMsgInfo( lpWindInfo->lpMessage, &msginfo );
   if( msginfo.szAuthor[ 0 ] == '\0' )
      {
      fMessageBox( hwnd, 0, GS(IDS_STR1220), MB_OK|MB_ICONINFORMATION );
      EndDialog( hwnd, 0 );
      return( FALSE );
      }

   SetDlgItemText( hwnd, IDD_PAD1, GS(IDS_STR1042) );

   /* Set the edit box to the author details
    */
   hwndName = GetDlgItem( hwnd, IDD_NAME );
   Edit_SetText( hwndName, msginfo.szAuthor );
   Edit_LimitText( hwndName, LEN_INTERNETNAME+1 );

   /* Fill the list of mail folders.
    */
   VERIFY( hwndList = GetDlgItem( hwnd, IDD_LIST ) );
   for( pcat = Amdb_GetFirstCategory(); pcat; pcat = Amdb_GetNextCategory( pcat ) )
      for( pcl = Amdb_GetFirstFolder( pcat ); pcl; pcl = Amdb_GetNextFolder( pcl ) )
         for( ptl = Amdb_GetFirstTopic( pcl ); ptl; ptl = Amdb_GetNextTopic( ptl ) )
            if( Amdb_GetTopicType( ptl ) == FTYPE_MAIL )
               {
               int index;

               index = ComboBox_InsertString( hwndList, -1, (LPSTR)Amdb_GetTopicName( ptl ) );
               ComboBox_SetItemData( hwndList, index, (LPARAM)ptl );
               }

   /* Select the first Mail topic.
    */
   if( ( index = RealComboBox_FindItemData( hwndList, -1, (LPARAM)lpWindInfo->lpTopic ) ) == CB_ERR )
      index = 0;
   ComboBox_SetCurSel( hwndList, index );

   /* Set the edit field limits.
    */
   VERIFY( hwndEdit = GetDlgItem( hwnd, IDD_EDIT ) );
   Edit_LimitText( hwndEdit, LEN_TOPICNAME );

   /* Choose to move to an existing folder.
    */
   CheckDlgButton( hwnd, IDD_EXISTING, TRUE );
   EnableControl( hwnd, IDD_PAD2, FALSE );
   EnableControl( hwnd, IDD_EDIT, FALSE );

   /* Move other messages.
    */
   CheckDlgButton( hwnd, IDD_FILEALL, TRUE );
   return( TRUE );
}
Exemple #18
0
static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
{
    RECT        rectClient;
    LVCOLUMN    LVCol;
    char*       token;
    char        buf[MAX_PATH * MAX_DIRS];
	int			i;

    pDirInfo = (struct tDirInfo*) malloc(sizeof(struct tDirInfo));
    if (pDirInfo == NULL) /* bummer */
    {
        EndDialog(hDlg, -1);
        return FALSE;
    }

	for (i = LASTDIR - 1; i >= 0; i--)
	{
		ComboBox_InsertString(GetDlgItem(hDlg, IDC_DIR_COMBO), 0, dir_names[i]);
	}

    ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO), 0);

    GetClientRect(GetDlgItem(hDlg, IDC_DIR_LIST), &rectClient);

    memset(&LVCol, 0, sizeof(LVCOLUMN));
    LVCol.mask    = LVCF_WIDTH;
    LVCol.cx      = rectClient.right - rectClient.left - GetSystemMetrics(SM_CXHSCROLL);
    
    ListView_InsertColumn(GetDlgItem(hDlg, IDC_DIR_LIST), 0, &LVCol);


    /* Keep a temporary copy of the directory strings in pDirInfo. */
    memset(pDirInfo, 0, sizeof(struct tDirInfo));

    strcpy(buf, GetRomDirs());

    pDirInfo->m_Paths[ROM].m_NumDirectories = 0;
    token = strtok(buf, ";");
    while ((DirInfo_NumDir(pDirInfo, ROM) < MAX_DIRS) && token)
    {
        strcpy(DirInfo_Path(pDirInfo, ROM, DirInfo_NumDir(pDirInfo, ROM)), token);
        DirInfo_NumDir(pDirInfo, ROM)++;
        token = strtok(NULL, ";");
    }
    pDirInfo->m_Paths[ROM].m_bModified = FALSE;

    strcpy(buf, GetSampleDirs());

    pDirInfo->m_Paths[SAMPLE].m_NumDirectories = 0;
    token = strtok(buf, ";");
    while ((DirInfo_NumDir(pDirInfo, SAMPLE) < MAX_DIRS) && token)
    {
        strcpy(DirInfo_Path(pDirInfo, SAMPLE, DirInfo_NumDir(pDirInfo, SAMPLE)), token);
        DirInfo_NumDir(pDirInfo, SAMPLE)++;
        token = strtok(NULL, ";");
    }
    pDirInfo->m_Paths[SAMPLE].m_bModified = FALSE;

    strcpy(DirInfo_Dir(pDirInfo, CFG),		GetCfgDir());
    strcpy(DirInfo_Dir(pDirInfo, HI),		GetHiDir());
    strcpy(DirInfo_Dir(pDirInfo, IMG),		GetImgDir());
    strcpy(DirInfo_Dir(pDirInfo, INP),		GetInpDir());
    strcpy(DirInfo_Dir(pDirInfo, STATE),	GetStateDir());
    strcpy(DirInfo_Dir(pDirInfo, ART),		GetArtDir());
	strcpy(DirInfo_Dir(pDirInfo, MEMCARD),	GetMemcardDir());
	strcpy(DirInfo_Dir(pDirInfo, FLYER),	GetFlyerDir());
	strcpy(DirInfo_Dir(pDirInfo, CABINET),	GetCabinetDir());
	strcpy(DirInfo_Dir(pDirInfo, NVRAM),	GetNvramDir());

    UpdateDirectoryList(hDlg);

    return TRUE;
}
Exemple #19
0
INT_PTR CALLBACK CDialogPackage::SelectFolderDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_INITDIALOG:
    {
        EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
        c_Dialog->SetDialogFont(hWnd);

        std::wstring* existingPath = (std::wstring*)lParam;
        SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);

        *existingPath += L'*';
        WIN32_FIND_DATA fd;
        HANDLE hFind = FindFirstFileEx(existingPath->c_str(), FindExInfoStandard, &fd, FindExSearchNameMatch, NULL, 0);
        existingPath->pop_back();

        if (hFind != INVALID_HANDLE_VALUE)
        {
            const WCHAR* folder = PathFindFileName(existingPath->c_str());

            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_RADIO);
            std::wstring text = L"Add folder from ";
            text.append(folder, wcslen(folder) - 1);
            text += L':';
            SetWindowText(item, text.c_str());
            Button_SetCheck(item, BST_CHECKED);

            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_COMBO);

            do
            {
                if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
                        !(fd.cFileName[0] == L'.' && (!fd.cFileName[1] || fd.cFileName[1] == L'.' && !fd.cFileName[2])) &&
                        wcscmp(fd.cFileName, L"Backup") != 0 &&
                        wcscmp(fd.cFileName, L"@Backup") != 0)
                {
                    ComboBox_InsertString(item, -1, fd.cFileName);
                }
            }
            while (FindNextFile(hFind, &fd));

            ComboBox_SetCurSel(item, 0);

            FindClose(hFind);
        }
    }
    break;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDC_PACKAGESELECTFOLDER_EXISTING_RADIO:
        {
            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_COMBO);
            EnableWindow(item, TRUE);
            int sel = ComboBox_GetCurSel(item);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
            EnableWindow(item, FALSE);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON);
            EnableWindow(item, FALSE);

            item = GetDlgItem(hWnd, IDOK);
            EnableWindow(item, sel != -1);
        }
        break;

        case IDC_PACKAGESELECTFOLDER_CUSTOM_RADIO:
        {
            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_COMBO);
            EnableWindow(item, FALSE);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
            EnableWindow(item, TRUE);
            item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON);
            EnableWindow(item, TRUE);

            SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT, EN_CHANGE), 0);
        }
        break;

        case IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT:
            if (HIWORD(wParam) == EN_CHANGE)
            {
                WCHAR buffer[MAX_PATH];
                int len = Edit_GetText((HWND)lParam, buffer, MAX_PATH);

                // Disable Add button if invalid directory
                DWORD attributes = GetFileAttributes(buffer);
                BOOL state = (attributes != INVALID_FILE_ATTRIBUTES &&
                              attributes & FILE_ATTRIBUTE_DIRECTORY);
                EnableWindow(GetDlgItem(hWnd, IDOK), state);
            }
            break;

        case IDC_PACKAGESELECTFOLDER_CUSTOMBROWSE_BUTTON:
        {
            WCHAR buffer[MAX_PATH];
            BROWSEINFO bi = {0};
            bi.hwndOwner = hWnd;
            bi.ulFlags = BIF_USENEWUI | BIF_NONEWFOLDERBUTTON | BIF_RETURNONLYFSDIRS;

            PIDLIST_ABSOLUTE pidl = SHBrowseForFolder(&bi);
            if (pidl && SHGetPathFromIDList(pidl, buffer))
            {
                HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
                SetWindowText(item, buffer);
                CoTaskMemFree(pidl);
            }
        }
        break;

        case IDOK:
        {
            WCHAR buffer[MAX_PATH];
            HWND item = GetDlgItem(hWnd, IDC_PACKAGESELECTFOLDER_EXISTING_RADIO);
            bool existing = Button_GetCheck(item) == BST_CHECKED;

            item = GetDlgItem(hWnd, existing ? IDC_PACKAGESELECTFOLDER_EXISTING_COMBO : IDC_PACKAGESELECTFOLDER_CUSTOM_EDIT);
            GetWindowText(item, buffer, _countof(buffer));

            std::wstring* result = (std::wstring*)GetWindowLongPtr(hWnd, GWLP_USERDATA);

            if (existing)
            {
                *result += buffer;
            }
            else
            {
                *result = buffer;
            }
            *result += L'\\';

            EndDialog(hWnd, 1);
        }
        }
        break;

    case WM_CLOSE:
        EndDialog(hWnd, 0);
        break;

    default:
        return FALSE;
    }

    return TRUE;
}
Exemple #20
0
static BOOL Directories_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
{
	RECT		rectClient;
	LVCOLUMN	LVCol;
	int 		i;
	int			nDirInfoCount;
	LPCSTR		s;
	TCHAR       *token;
	TCHAR       buf[MAX_PATH * MAX_DIRS];
	TCHAR*      t_s = NULL;
	HRESULT 	res;

	/* count how many dirinfos there are */
	nDirInfoCount = 0;
	while(g_directoryInfo[nDirInfoCount].lpName)
		nDirInfoCount++;

	g_pDirInfo = (tDirInfo *) malloc(sizeof(tDirInfo) * nDirInfoCount);
	if (!g_pDirInfo) /* bummer */
		goto error;
	memset(g_pDirInfo, 0, sizeof(tDirInfo) * nDirInfoCount);

	for (i = nDirInfoCount - 1; i >= 0; i--)
	{
		t_s = tstring_from_utf8(g_directoryInfo[i].lpName);
		if( !t_s )
			return FALSE;
		(void)ComboBox_InsertString(GetDlgItem(hDlg, IDC_DIR_COMBO), 0, win_tstring_strdup(t_s));
		osd_free(t_s);
		t_s = NULL;
	}

	(void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO), 0);

	GetClientRect(GetDlgItem(hDlg, IDC_DIR_LIST), &rectClient);

	memset(&LVCol, 0, sizeof(LVCOLUMN));
	LVCol.mask	  = LVCF_WIDTH;
	LVCol.cx	  = rectClient.right - rectClient.left - GetSystemMetrics(SM_CXHSCROLL);
	
	res = ListView_InsertColumn(GetDlgItem(hDlg, IDC_DIR_LIST), 0, &LVCol);

	/* Keep a temporary copy of the directory strings in g_pDirInfo. */
	for (i = 0; i < nDirInfoCount; i++)
	{
		s = g_directoryInfo[i].pfnGetTheseDirs();
		t_s = tstring_from_utf8(s);
		if( !t_s )
			return FALSE;
		if (g_directoryInfo[i].bMulti)
		{
			/* Copy the string to our own buffer so that we can mutilate it */
			_tcscpy(buf, t_s);

			g_pDirInfo[i].m_Path = (tPath*)malloc(sizeof(tPath));
			if (!g_pDirInfo[i].m_Path)
				goto error;

			g_pDirInfo[i].m_Path->m_NumDirectories = 0;
			token = _tcstok(buf, TEXT(";"));
			while ((DirInfo_NumDir(g_pDirInfo, i) < MAX_DIRS) && token)
			{
				_tcscpy(DirInfo_Path(g_pDirInfo, i, DirInfo_NumDir(g_pDirInfo, i)), token);
				DirInfo_NumDir(g_pDirInfo, i)++;
				token = _tcstok(NULL, TEXT(";"));
			}
			DirInfo_SetModified(g_pDirInfo, i, FALSE);
		}
		else
		{
			DirInfo_SetDir(g_pDirInfo, i, -1, t_s);
		}
		osd_free(t_s);
		t_s = NULL;
	}

	UpdateDirectoryList(hDlg);
	return TRUE;

error:
	if( t_s )
		osd_free(t_s);
	Directories_OnDestroy(hDlg);
	EndDialog(hDlg, -1);
	return FALSE;
}
Exemple #21
0
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	char str[20];

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		CheckDlgButton(hwndDlg, IDC_UPDATEONSTARTUP, UpdateOnStartup ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, OnlyOnceADay ? BST_CHECKED : BST_UNCHECKED);
		EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), UpdateOnStartup);
		CheckDlgButton(hwndDlg, IDC_UPDATEONPERIOD, UpdateOnPeriod ? BST_CHECKED : BST_UNCHECKED);
		EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), UpdateOnPeriod);
		EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), UpdateOnPeriod);
		EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), UpdateOnPeriod);

		SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1));
		SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETPOS, 0, (LPARAM)Period);

		Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2);
		mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PERIOD), MyEditProc);

		ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 0, TranslateT("hours"));
		ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
		ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), PeriodMeasure);

		CheckDlgButton(hwndDlg, IDC_REMINDER, Reminder ? BST_CHECKED : BST_UNCHECKED);
		if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
			ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE);
		}
		else {
			for (int i = 1; i < POPUPS; i++) {
				mir_snprintf(str, "Popups%dM", i);
				CheckDlgButton(hwndDlg, (i + 1029), (db_get_b(NULL, MODNAME, str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
			}
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_UPDATEONSTARTUP:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
			break;

		case IDC_ONLYONCEADAY:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_UPDATEONPERIOD:
		{
			BOOL value = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
			EnableWindow(GetDlgItem(hwndDlg, IDC_PERIOD), value);
			EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODSPIN), value);
			EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), value);
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		}
		break;

		case IDC_PERIODMEASURE:
			if (HIWORD(wParam) == CBN_SELCHANGE)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_REMINDER:
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_LINK_HOTKEY:
		{
			OPENOPTIONSDIALOG ood = { sizeof(ood) };
			ood.pszGroup = "Customize";
			ood.pszPage = "Hotkeys";
			Options_Open(&ood);
		}
		return true;

		case IDC_MSG_BOXES2:
		case IDC_ERRORS2:
		case IDC_INFO_MESSAGES2:
		case IDC_PROGR_DLG2:
			if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			break;
		}
		break;

	case WM_NOTIFY:
	{
		NMHDR *hdr = (NMHDR *)lParam;
		if (hdr && hdr->code == UDN_DELTAPOS)
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

		if (hdr && hdr->code == PSN_APPLY) {
			UpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
			OnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);

			UpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);

			char buffer[3] = { 0 };
			Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), (LPWSTR)&buffer, 2);
			Period = atoi(buffer);

			PeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));

			InitTimer();

			db_set_b(NULL, MODNAME, "UpdateOnStartup", UpdateOnStartup);
			db_set_b(NULL, MODNAME, "OnlyOnceADay", OnlyOnceADay);
			db_set_b(NULL, MODNAME, "UpdateOnPeriod", UpdateOnPeriod);
			db_set_dw(NULL, MODNAME, "Period", Period);
			db_set_b(NULL, MODNAME, "PeriodMeasure", PeriodMeasure);
			Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER);
			db_set_b(NULL, MODNAME, "Reminder", Reminder);
			if (!ServiceExists(MS_POPUP_ADDPOPUPT)) {
				for (int i = 1; i < POPUPS; i++) {
					mir_snprintf(str, "Popups%dM", i);
					db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i + 1029))));
				}
			}
		}
		break;
	}
	}
	return FALSE;
}
//
//  Processes messages for the dialog.
//
INT_PTR CALLBACK ChatDialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    BOOL handled = FALSE;
    switch (message)
    {
    case WM_INITDIALOG:
        {
            //
            //  Start by using the wave transport for "chat".
            //

            //
            //  Allocate the WAVE chat transport.  If we failed to startup, we're done.
            //
            g_CurrentChat = new (std::nothrow) CWaveChat(hWnd);
            if (g_CurrentChat == NULL)
            {
                MessageBox(hWnd, L"Unable to allocate WAVE chat transport", L"Startup Error", MB_OK);
                EndDialog(hWnd, TRUE);
            }
            if (!g_CurrentChat->Initialize(true))
            {
                EndDialog(hWnd, TRUE);
            }

            //
            //  Set up the combobox and initialize the chat options to reflect that we've set the Wave chat transport by default.
            //
            g_WaveComboBoxIndex = ComboBox_InsertString(GetDlgItem(hWnd, IDC_COMBO_CHAT_TRANSPORT), 0, L"WAVE API Transport");
            g_WasapiComboBoxIndex = ComboBox_InsertString(GetDlgItem(hWnd, IDC_COMBO_CHAT_TRANSPORT), 1, L"WASAPI API Transport");
            ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_COMBO_CHAT_TRANSPORT), g_WaveComboBoxIndex);

            //
            //  Simulate a "stop" event to get the UI in sync.
            //
            SyncUIState(hWnd, ChatStateNotPlaying);

            handled = TRUE;
            break;
        }

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

            // Parse the menu selections:
            switch (wmId)
            {
            case IDOK:
            case IDCANCEL:
                //
                //  Stop on Cancel/OK.
                //
                if (g_CurrentChat)
                {
                    g_CurrentChat->StopChat();
                }
                g_CurrentChat->Shutdown();
                delete g_CurrentChat;
                g_CurrentChat = NULL;

                EndDialog(hWnd, TRUE);
                handled = TRUE;
                break;

            case IDC_CHATSTART:
                //
                //  Start the chat engine.
                //
                if (g_CurrentChat->StartChat(IsDlgButtonChecked(hWnd, IDC_CHECK_HIDE_FROM_VOLUME_MIXER) == BST_CHECKED))
                {
                    SyncUIState(hWnd, ChatStatePlaying);
                }
                handled = TRUE;
                break;

            case IDC_CHATSTOP:
                //
                //  Stop the chat engine.
                //
                g_CurrentChat->StopChat();

                SyncUIState(hWnd, ChatStateNotPlaying);
                handled = TRUE;
                break;

                //
                //  The user's interacting with the chat transport combo box.
                //
            case IDC_COMBO_CHAT_TRANSPORT:
                {
                    switch (wmEvent)
                    {
                    case CBN_SELCHANGE:
                        {
                            int currentSel = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_CHAT_TRANSPORT));

                            //
                            //  The user modified the chat transport.  Delete the existing chat transport and create a new one.
                            //
                            g_CurrentChat->Shutdown();
                            delete g_CurrentChat;
                            g_CurrentChat = NULL;

                            if (currentSel == g_WasapiComboBoxIndex)
                            {
                                //
                                //  Instantiate the WASAPI transport.
                                //
                                g_CurrentChat = new (std::nothrow) CWasapiChat(hWnd);
                                if (g_CurrentChat == NULL)
                                {
                                    MessageBox(hWnd, L"Unable to create WASAPI chat transport", L"Error", MB_OK);
                                }
                            }
                            else if (currentSel == g_WaveComboBoxIndex)
                            {
                                //
                                //  Instantiate the wave transport.
                                //
                                g_CurrentChat = new (std::nothrow) CWaveChat(hWnd);
                                if (g_CurrentChat == NULL)
                                {
                                    MessageBox(hWnd, L"Unable to create WAVE chat transport", L"Error", MB_OK);
                                }
                            }

                            //
                            //  Sync the UI to the transport choice
                            //
                            SyncUIState(hWnd, ChatStateNotPlaying);

                            //
                            //  Initialize the chat object
                            //
                            bool useInputDevice = (IsDlgButtonChecked(hWnd, IDC_RADIO_CAPTURE) == BST_CHECKED);
                            if (g_CurrentChat->Initialize(useInputDevice))
                            {
                                //
                                //  Sync the UI to the state again - we're not playing but after initializing the state might change.
                                //
                                SyncUIState(hWnd, ChatStateNotPlaying);
                            }
                            else
                            {
                                MessageBox(hWnd, L"Unable to initialize chat", L"Error", MB_OK);
                            }
                            break;
                        }
                    default:
                        break;
                    }
                    handled = TRUE;
                    break;
                } // IDC_COMBO_CHAT_TRANSPORT
            case IDC_RADIO_CAPTURE:
            case IDC_RADIO_RENDER:
                {
                    int currentSel = ComboBox_GetCurSel(GetDlgItem(hWnd, IDC_COMBO_CHAT_TRANSPORT));
                    //
                    //  The radio button selection may change when the transport is changed to Wave because render is not
                    //  an option for Wave.  We detect that here and only rebuild the transport for Wasapi
                    //
                    if ((currentSel == g_WasapiComboBoxIndex) && (g_CurrentChat->TransportType() == CChatTransport::ChatTransportWasapi))
                    {
                        //
                        //  The user switched between render and capture.  Delete the existing chat transport and create a new one.
                        //
                        g_CurrentChat->Shutdown();
                        delete g_CurrentChat;

                        //
                        //  Reinstantiate the WASAPI transport.
                        //
                        //  Also update the state of the rendering options since the WASAPI transport supports them.
                        //
                        g_CurrentChat = new (std::nothrow) CWasapiChat(hWnd);
                        if (g_CurrentChat == NULL)
                        {
                            MessageBox(hWnd, L"Unable to create WASAPI chat transport", L"Error", MB_OK);
                        }
                        else if (g_CurrentChat->Initialize(IsDlgButtonChecked(hWnd, IDC_CHECK_HIDE_FROM_VOLUME_MIXER) == BST_CHECKED))
                        {
                        }
                        else
                        {
                            MessageBox(hWnd, L"Unable to initialize chat", L"Error", MB_OK);
                        }
                    }
                    SyncUIState(hWnd, ChatStateNotPlaying);
                    break;
                }
            default:
                break;
            }   // WM_COMMAND
        }
    default:
        //
        //  If the current chat transport is going to handle this message, pass the message to the transport.
        //
        //  Otherwise just let our caller know that they need to handle it.
        //
        if (g_CurrentChat && g_CurrentChat->HandlesMessage(hWnd, message))
        {
            handled = static_cast<BOOL>(g_CurrentChat->MessageHandler(hWnd, message, wParam, lParam));
        }
        break;
    }
    return handled;
}
Exemple #23
0
// ---------------------------------------------------------------------------
// CWinMenubar::LoadDialogProc()
// Dialog Window proc for the Load URL dialog
// ---------------------------------------------------------------------------
BOOL CALLBACK CWinMenubar::LoadDialogProc(HWND hDlg, UINT message, 
                                          WPARAM wParam, LPARAM lParam)
{
    switch (message) 
    {
    case WM_INITDIALOG:
        {
            SetWindowLong(hDlg, DWL_USER, lParam); // CEcmtMenubar*
            HWND hURL = GetDlgItem(hDlg, IDC_URL);
#ifdef HAVE_WLIB
            HKEY key = REG_OpenKey(HKCU, gRegPath, KEY_READ);
            if (key)
            {
                RegMsz* history = REG_QueryMultiSz(key, gRegLoadHistory);
                if (history)
                {
                    const char* entry = REGMSZ_First(history);
                    TRACE("ECMTMENUBAR: reading URL history...\n");
                    while (entry)
                    {
                        TRACE1("    %s\n",entry);
                        // Cannot use ComboBox_AddString because it may call
                        // SendMessageW, while we need SendMessageA
                        SendMessageA(hURL, CB_ADDSTRING, 0, (LPARAM)entry);
                        entry = REGMSZ_Next(history, entry);
                    }
                    int n = ComboBox_GetCount(hURL);
                    if (n > 0)
                    {
                        TRACE1("ECMTMENUBAR: loaded %d history entries\n",n);
                        ComboBox_SetCurSel(hURL, 0);
                    }
                }
                REG_CloseKey(key);
            }
#endif // HAVE_WLIB

            // Disable OK button if the URL field is empty
            HWND hOK = GetDlgItem(hDlg, IDOK);
            EnableWindow(hOK, GetWindowTextLength(hURL) > 0);
        }
        return TRUE;
        
    case WM_COMMAND:
        switch (wParam)
        {
        case MAKELONG(IDC_URL,CBN_SELCHANGE):
            // Will update the OK button after the edit field gets updated
            PostMessageA(hDlg, message, MAKELONG(IDC_URL,EN_CHANGE), lParam);
            return TRUE;

        case MAKELONG(IDC_URL,CBN_EDITCHANGE):
        case MAKELONG(IDC_URL,EN_CHANGE):
            {
                // Disable OK button if the URL is empty
                HWND hURL = GetDlgItem(hDlg, IDC_URL);
                HWND hOK = GetDlgItem(hDlg, IDOK);
                EnableWindow(hOK, GetWindowTextLength(hURL) > 0);
            }
            return TRUE;
        case IDC_BROWSE:
            {
                CWinMenubar* This = (CWinMenubar*)GetWindowLong(hDlg,DWL_USER);
                HWND hURL = GetDlgItem(hDlg, IDC_URL);
                TCHAR* fname = This->SelectFile(hURL);
                if (fname)
                {
					// Opening a local file. Add local file cheme to the beginning 
					// of url, so later on a decision can be made: whether open a 
					// web address using browser or local file using the SDK launcher.
                    TCHAR* url=NULL;					
					const char* cheme = LOCAL_FILE_SCHEME;
					
					int length = strlen(cheme) + wcslen(fname)+1;

					url = (TCHAR*)Alloc(length*sizeof(TCHAR));
					TCHAR* tempurl = url; 	
					if(url)
					{
						// Add cheme
						while(*cheme) {
							*tempurl = *cheme;
							cheme++;
							tempurl++;
						}
				
						// Add pathS
						wcscat(tempurl,fname);					
						tempurl=NULL;
                    
                        HWND hOK = GetDlgItem(hDlg, IDOK);
                        EnableWindow(hOK, TRUE);
                        SetWindowText(hURL, url);
                        SetFocus(hURL);
                        Free(url);
                    }
                    Free(fname);
                }
            }
            return TRUE;

        case IDOK:
            {
                CWinMenubar* This = (CWinMenubar*)GetWindowLong(hDlg,DWL_USER);
                HWND hURL = GetDlgItem(hDlg, IDC_URL);
                int len = GetWindowTextLength(hURL);
                if (This && len > 0)
                {
                    TCHAR* url = (TCHAR*)Alloc((len+1)*sizeof(TCHAR));
                    if (url)
                    {						
                        len = GetWindowText(hURL, url, len+1);

						// Check if url contains "local://" at the beginning.
						const char* cheme = LOCAL_FILE_SCHEME;
						// Boolean indicating does url contain local file cheme
						BOOL match = TRUE;

						for(int k=0;k<strlen(cheme);k++){
							TCHAR c_cheme=cheme[k];
							TCHAR c_url=url[k];

							if(c_url != c_cheme) {
								match = FALSE;
								break;
							}
						}
						
						// Launch file with the SDK launcher local cheme was found.
						// otherwice launch url in browser.
						if(match==TRUE)
						{							
							TCHAR* fname=url;
							fname += strlen(cheme);
							This->iEcmtMenubar->LoadFile(
								This->iDefaultBrowser, fname);
							fname=NULL;
						}
						else
						{//Else launch file in browser:
							This->iEcmtMenubar->LaunchBrowser(
							This->iDefaultBrowser, url);
#ifdef HAVE_WLIB
							// Update the URL history. First, remove duplicates.
							TRACE("ECMTMENUBAR: updating URL history...\n");
							int i, n = ComboBox_GetCount(hURL);
							int bufsize = 0;
							TCHAR* buf = NULL;
							for (i=n-1; i>=0; i--)
							{
								len = ComboBox_GetLBTextLen(hURL,i);
								if (len >= bufsize)
								{
									Free(buf);
									bufsize = len+1;
									buf = (TCHAR*)Alloc(bufsize*sizeof(TCHAR));
									if (!buf) break;
								}
								buf[0] = 0;
								ComboBox_GetLBText(hURL, i, buf);
								if (_tcscmp(buf, url) == 0)
								{
									TRACE1("ECMTMENUBAR: duplicate at %d\n",i);
									ComboBox_DeleteString(hURL, i);
								}
							}

							// Insert new item, recalculate number of items
							ComboBox_InsertString(hURL, 0, url);
							n = ComboBox_GetCount(hURL);
							Free(buf);

							// Delete extra items from the bottom
							int extra = n - KMaxLoadHistory;
							for (i=0; i<extra; i++)
							{
								ComboBox_DeleteString(hURL, n-i-1);
							}

							// Save the history
							RegMsz * msz = REGMSZ_Create();
							if (msz)
							{
								TRACE("ECMTMENUBAR: collecting history\n");
								char* buf2 = NULL;
								bufsize = 0;
								n = ComboBox_GetCount(hURL);
								for (i=0; i<n; i++)
								{
									len = ComboBox_GetLBTextLen(hURL,i);
									if (len >= bufsize)
									{
										Free(buf2);
										bufsize = len+1;
										buf2 = (char*)Alloc(bufsize);
										if (!buf2) break;
									}
									buf2[0] = 0;
									SendMessageA(hURL,CB_GETLBTEXT,i,(LPARAM)buf2);
									TRACE1("    %s\n",buf2);
									if (buf2[0]) REGMSZ_Add(msz, buf2);
								}

								HKEY key = REG_OpenCreateKey(HKCU, gRegPath);
								if (key)
								{
									TRACE("ECMTMENUBAR: saving history\n");
									REG_SetMsz(key, gRegLoadHistory, msz);
									REG_CloseKey(key);
								}
								REGMSZ_Delete(msz);
								Free(buf2);
							}

	#endif // HAVE_WLIB
						}
						// And finally free memory
						Free(url);
                    }
                }
            }
            // Fall through
        case IDCANCEL:
            EndDialog(hDlg, wParam);
            return TRUE;
        default:
            return FALSE;
        }

    default:
        return FALSE;
    }
}
Exemple #24
0
//初始化窗口函数
BOOL Mini_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
	//设置透明风格
	COLORREF color = RGB(0,0,0);
	SetWindowLong(hwnd,GWL_EXSTYLE,GetWindowLong(hwnd, GWL_EXSTYLE)|WS_EX_LAYERED);
	SetLayeredWindowAttributes(hwnd,color,255*75/100,LWA_ALPHA);//
	
	//获取主窗口句柄
	minphwnd = (HWND)lParam;//
	//向主窗口发送句柄
	PostMessage(minphwnd,MINI_OPEN,0,(LPARAM)hwnd);//

	//获取窗口坐标
	GetWindowRect(hwnd,&_size);//
	//设置窗口总在最前
	SetWindowPos(hwnd,HWND_TOPMOST,0,0,_ORIGIN_WIDTH,_ORIGIN_HEIGHT,SWP_NOMOVE);//
	//窗口状态为未隐藏
	_isHide = FALSE;//
	//窗口为未吸附边缘状态
	_shouldHide = FALSE;//

	//初始化组合框显示
	//播放顺序组合框初始化
	HWND CBSX = GetDlgItem(hwnd,IDC__COMBOSX);
	ComboBox_InsertString(CBSX,-1,TEXT("单曲循环"));
	ComboBox_InsertString(CBSX,-1,TEXT("列表循环"));
	ComboBox_InsertString(CBSX,-1,TEXT("随机播放"));
	//获取主窗口播放顺序组合框选中选项设置到迷你窗口中
	int i = ComboBox_GetCurSel(GetDlgItem(minphwnd,IDC_COMBOSX));
	ComboBox_SetCurSel(CBSX,i);//

	//静音复选框初始化
	CheckDlgButton(hwnd,IDC__SOF,IsDlgButtonChecked(minphwnd,IDC_SOF));//

	//音量滚动条初始化
	HWND VHK = GetDlgItem(hwnd,IDC__SOUND_SLIDER);
	//设置滚动条最小值为0
	SendMessage(VHK,TBM_SETRANGEMIN,(WPARAM)TRUE,0);//
	//设置滚动条最大值为640 /6.4
	SendMessage(VHK,TBM_SETRANGEMAX,(WPARAM)TRUE,640);//
	//设置按←键时,减小32 /6.4
	SendMessage(VHK,TBM_SETPAGESIZE,0, (LPARAM)32);//
	//设置按→键时,增大32 /6.4
	SendMessage(VHK,TBM_SETLINESIZE,0, (LPARAM)32);//
	//获取主窗口音量滚动条位置设置到迷你窗口音量滚动条上
	int Voice = (int)SendMessage(GetDlgItem(minphwnd,IDC_SOUND_SLIDER),TBM_GETPOS,0,0);
	SendMessage(GetDlgItem(hwnd,IDC__SOUND_SLIDER),TBM_SETPOS,(unsigned long)TRUE,Voice);//

	TCHAR TT[15],*p;
	//获取主窗口时间编辑框中内容
	GetDlgItemText(minphwnd,IDC_EDITTIME,TT,sizeof(TT));//
	p = TT;
	while (*p)
		p++;
	while (*p != '/')
		p--;
	p++;
	//获取总长分数
	int time = atoi(p);//
	p += 3;
	//获取总长秒数并与分数一起转化为毫秒
	time = time*60000 + (atoi(p)-1)*1000;//

	//播放进度滚动条初始化
	HWND MHK = GetDlgItem(hwnd,IDC__MUSIC_SLIDER);
	//设置滚动条最小值为0
	SendMessage(MHK,TBM_SETRANGEMIN,(WPARAM)TRUE,0);//
	//设置滚动条最大值为1000
	SendMessage(MHK,TBM_SETRANGEMAX,(WPARAM)TRUE,time);//
	//设置按←键时,减小25
	SendMessage(MHK,TBM_SETPAGESIZE,0, (LPARAM)(time/40));//
	//设置按→键时,增大25 
	SendMessage(MHK,TBM_SETLINESIZE,0, (LPARAM)(time/40));//
	//获取主窗口进度滚动条位置设置到迷你窗口进度滚动条上
	int Time = (int)SendMessage(GetDlgItem(minphwnd,IDC_MUSIC_SLIDER),TBM_GETPOS,0,0);
	SendMessage(GetDlgItem(hwnd,IDC__MUSIC_SLIDER),TBM_SETPOS,(unsigned long)TRUE,Time);//

	TCHAR Name[MAX_PATH];
	//获取主窗口正在播放编辑框中文件路径
	GetDlgItemText(minphwnd,IDC_EDITNOW,Name,sizeof(Name));//
	//将主窗口正在播放编辑框中文件路径设置到迷你窗口中
	SetDlgItemText(hwnd,IDC__EDITNOW,Name);//

	//设置检测吸附窗口及刷新进度滚动条位置定时器
	SetTimer(hwnd,TIMER_MTEST,TIMER_MTEST_TIME,(TIMERPROC)MINITimer);//

	return TRUE;
}//