Ejemplo n.º 1
0
// Set the selected filter to be displayed in the filter Combo Box
void SppTabFltr::SelFilter(int FilterId)
{
	// Get the index of the filter (By ID)
	int i=0, data;
	HWND hCombo = GetDlgItem(m_hDlg,  IDC_COMBO_FILTERS);
	HWND hFilterCB		= GetDlgItem(m_hDlg,  IDC_CH_FILTER);
	while ((data = (int)ComboBox_GetItemData(hCombo, i)) != CB_ERR)
	{
		if (data == FilterId)
		{
			// Select
			int res = ComboBox_SetCurSel(hCombo, i);

			// Checks the checkbox
			EnableWindow(hFilterCB, true);
			Button_SetCheck(hFilterCB, BST_CHECKED);
			ShowChannelArea( m_hDlg, true);
			
			// Inform Parent
			ComboBox_GetLBText (hCombo,i,m_FilterName);
			m_FilterActive = true;
			break;
		};
		i++;
	};

	SentFilterInfo2Parent();
}
Ejemplo n.º 2
0
PPH_STRING PhGetComboBoxString(
    _In_ HWND hwnd,
    _In_ INT Index
    )
{
    PPH_STRING string;
    ULONG length;

    if (Index == -1)
    {
        Index = ComboBox_GetCurSel(hwnd);

        if (Index == -1)
            return NULL;
    }

    length = ComboBox_GetLBTextLen(hwnd, Index);

    if (length == CB_ERR)
        return NULL;
    if (length == 0)
        return PhReferenceEmptyString();

    string = PhCreateStringEx(NULL, length * 2);

    if (ComboBox_GetLBText(hwnd, Index, string->Buffer) != CB_ERR)
    {
        return string;
    }
    else
    {
        PhDereferenceObject(string);
        return NULL;
    }
}
Ejemplo n.º 3
0
void FASTCALL CmdSignatureDlg_DisplaySig( HWND hwnd, int index )
{
   char sz[ _MAX_FNAME ];
   HWND hwndList;
   HWND hwndEdit;
   HNDFILE fh;

   hwndList = GetDlgItem( hwnd, IDD_LIST );
   hwndEdit = GetDlgItem( hwnd, IDD_EDIT );
   ComboBox_GetLBText( hwndList, index, sz );
   lstrcat( sz, ".sig" );
   if( ( fh = Ameol2_OpenFile( sz, DSD_SIG, AOF_READ ) ) != HNDFILE_ERROR )
      {
      WORD wSize;
      LPSTR lpText;

      INITIALISE_PTR(lpText);
      wSize = LOWORD( Amfile_GetFileSize( fh ) );
      if( fNewMemory( &lpText, wSize + 1 ) )
         {
         if( Amfile_Read( fh, lpText, wSize ) != wSize )
            DiskReadError( hwnd, sz, FALSE, FALSE );
         else
            {
            lpText[ wSize ] = '\0';
            Edit_SetText( hwndEdit, lpText );
            }
         FreeMemory( &lpText );
         }
      Amfile_Close( fh );
      }
   else
      Edit_SetText( hwndEdit, "" );
   SetWindowLong( hwnd, DWL_USER, (LPARAM)index );
}
Ejemplo n.º 4
0
tstring ComboBox::getValue( int index ) {
	// Uses CB_GETLBTEXTLEN and CB_GETLBTEXT
	int txtLength = ComboBox_GetLBTextLen( handle(), index );
	tstring retVal(txtLength, '\0');
	ComboBox_GetLBText( handle(), index, &retVal[0] );
	return retVal;
}
Ejemplo n.º 5
0
// Get selected filter fro GUI (if any) and send its filter index to parent window
void SppTabFltr::UpdateFilter(void)
{
	// Send the ID (in data) of the selected item to the parent window
	HWND hFilterList = GetDlgItem(m_hDlg,  IDC_COMBO_FILTERS);
	int FilterId; 
	int iCurSel = ComboBox_GetCurSel(hFilterList);
	if (iCurSel==CB_ERR)
	{
		SendMessage(m_TopDlgWnd, WMSPP_DLG_FILTER, (WPARAM)-1, 0);
		return;
	}

	FilterId = (int)ComboBox_GetItemData (hFilterList, iCurSel);
	SendMessage(m_TopDlgWnd, WMSPP_DLG_FILTER, (WPARAM)FilterId, 0);

	// Inform Parent
	ComboBox_GetLBText (hFilterList,iCurSel,m_FilterName);


	// Checks the checkbox
	HWND hFilterCB		= GetDlgItem(m_hDlg,  IDC_CH_FILTER);
	EnableWindow(hFilterCB, true);
	Button_SetCheck(hFilterCB, BST_CHECKED);
	ShowChannelArea( m_hDlg, true);
	m_FilterActive = true;
	SentFilterInfo2Parent();
}
Ejemplo n.º 6
0
int ConvertEmulateTypeSelStringToID(HWND hDlg, int id)
{
   WCHAR wtext[MAX_PATH];
   char text[MAX_PATH];

   if (!IsWindowEnabled(GetDlgItem(hDlg, id)))
      return EMUTYPE_NONE;

   ComboBox_GetLBText(GetDlgItem(hDlg, id),
                      ComboBox_GetCurSel(GetDlgItem(hDlg, id)),
                      wtext);
   WideCharToMultiByte(CP_ACP, 0, wtext, -1, text, MAX_PATH, NULL, NULL);

   if (strcmp(text, "Standard Pad") == 0)
      return EMUTYPE_STANDARDPAD;
   else if (strcmp(text, "Analog Pad") == 0)
      return EMUTYPE_ANALOGPAD;
   else if (strcmp(text, "Stunner") == 0)
      return EMUTYPE_STUNNER;
   else if (strcmp(text, "Mouse") == 0)
      return EMUTYPE_MOUSE;
   else if (strcmp(text, "Keyboard") == 0)
      return EMUTYPE_KEYBOARD;
   else
      return EMUTYPE_NONE;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
void on_button_connect_clicked (void)
{
    extern char      username[];
    extern char      password[];
    extern int       username_length, password_length;

    if (Edit_GetModify (hwndEditUser) || Edit_GetModify (hwndEditPass)) {
    
        username_length = GetWindowTextLength(hwndEditUser);
        password_length = GetWindowTextLength(hwndEditPass);
    
        GetWindowText(hwndEditUser, username, username_length + 1);
        GetWindowText(hwndEditPass, password, password_length + 1);
        
        reg_info_string (reg_key, REG_KEY_USER, TRUE, username, NULL, 0);
        reg_info_string (reg_key, REG_KEY_PASS, TRUE, password, NULL, 0);
    }
    
    /* 记录网卡设备列表序列 */
    reg_info_dword (reg_key, REG_KEY_IF_INDEX, TRUE, combo_index, NULL);

    /* 记录网卡设备列表名称 */    
    char combo_if_name[512] = {0};
    ComboBox_GetLBText (hwndComboList, combo_index, combo_if_name);
    reg_info_string (reg_key, REG_KEY_IF_NAME, TRUE, combo_if_name, NULL, 0);

    /* 禁用几个控件 */
    EnableWindow (hwndButtonConn, FALSE);
    EnableWindow (hwndEditUser, FALSE);
    EnableWindow (hwndEditPass, FALSE);
    EnableWindow (hwndComboList, FALSE);

    hEAP_THREAD = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)eap_thread, 0, 0, 0);
}
Ejemplo n.º 9
0
void AddDialogString(HWND hWndDlg, const PageHash key)
{
	TCHAR title[2048];
	GetWindowText(hWndDlg, title, _countof(title));
	if (mir_tstrlen(title) > 0)
		AddFilterString(key, title);

	TCHAR szClass[64];
	GetClassName(hWndDlg, szClass, _countof(szClass));

	if (mir_tstrcmpi(szClass, _T("SysTreeView32")) == 0) {
		HTREEITEM hItem = TreeView_GetRoot(hWndDlg);
		AddTreeViewNodes(hWndDlg, key, hItem);
		return;
	}

	if (mir_tstrcmpi(szClass, _T("listbox")) == 0) {
		if (GetWindowStyle(hWndDlg) & LBS_HASSTRINGS) {
			int count = ListBox_GetCount(hWndDlg);
			for (int i=0; i < count; i++) {
				title[0] = 0; //safety
				int res = ListBox_GetText(hWndDlg, i, title);
				if (res != LB_ERR) {
					title[_countof(title) - 1] = 0;
					if (mir_tstrlen(title) > 0)
						AddFilterString(key, title);
				}
			}
		}
		return;
	}

	if (mir_tstrcmpi(szClass, _T("SysListView32")) == 0) {
		int count = ListView_GetItemCount(hWndDlg);
		for (int i=0; i < count; i++) {
			title[0] = 0; //safety
			ListView_GetItemText(hWndDlg, i, 0, title, _countof(title));

			if (mir_tstrlen(title) > 0)
				AddFilterString(key, title);
		}
		return;
	}

	if (mir_tstrcmpi(szClass, _T("combobox")) == 0) {
		if (GetWindowStyle(hWndDlg) & CBS_HASSTRINGS) {
			int count = ComboBox_GetCount(hWndDlg);
			for (int i=0; i < count; i++) {
				title[0] = 0; //safety
				int res = ComboBox_GetLBText(hWndDlg, i, title);
				if (res != CB_ERR) {
					title[_countof(title) - 1] = 0;

					if (mir_tstrlen(title) > 0)
						AddFilterString(key, title);
				}
			}
		}
	}
}
Ejemplo n.º 10
0
BOOL plAnimComponentProc::DlgProc(TimeValue t, IParamMap2 *pMap, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HWND gWnd = GetDlgItem(hWnd, IDC_ANIM_GLOBAL_LIST);
    char buff[512];
    switch (msg)
    {
    case WM_INITDIALOG:
        {
            fPB = pMap->GetParamBlock();
            
            fNoteTrackDlg.Init(GetDlgItem(hWnd, IDC_ANIM_NAMES),
                GetDlgItem(hWnd, IDC_LOOP_NAMES),
                kAnimName,
                kAnimLoopName,
                fPB,
                fPB->GetOwner());
            fNoteTrackDlg.Load();
            
            EnableWindow(GetDlgItem(hWnd, IDC_LOOP_NAMES), fPB->GetInt(kAnimLoop));
            
            FillAgeGlobalComboBox(gWnd, fPB->GetStr(ParamID(kAnimGlobalName)));
            SetBoxToAgeGlobal(gWnd, fPB->GetStr(ParamID(kAnimGlobalName)));
            EnableGlobal(hWnd, fPB->GetInt(ParamID(kAnimUseGlobal)));
            Button_Enable(GetDlgItem(hWnd, IDC_COMP_ANIM_PHYSANIM), 
                HasPhysicalComponent((plComponentBase*)fPB->GetOwner()));
        }
        return TRUE;
    case WM_COMMAND:
        if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_ANIM_NAMES)
        {
            fNoteTrackDlg.AnimChanged();
            return TRUE;
        }
        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_LOOP_NAMES)
        {
            // Get the new loop name
            fNoteTrackDlg.LoopChanged();
            return TRUE;
        }
        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_ANIM_GLOBAL_LIST)
        {
            ComboBox_GetLBText(gWnd, ComboBox_GetCurSel(gWnd), buff);
            fPB->SetValue(ParamID(kAnimGlobalName), 0, _T(buff));
        }
        // Catch loop button updates
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_COMP_ANIM_LOOP_CKBX)
            EnableWindow(GetDlgItem(hWnd, IDC_LOOP_NAMES), fPB->GetInt(kAnimLoop));
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_COMP_ANIM_USE_GLOBAL)
        {
            EnableGlobal(hWnd, fPB->GetInt(ParamID(kAnimUseGlobal)));
        }
        break;
    }
    return false;   
}
Ejemplo n.º 11
0
/*------------------------------------------------
  Apply
--------------------------------------------------*/
void OnApply(HWND hDlg,BOOL preview)
{
	const wchar_t* section = (preview ? L"Preview" : L"Clock");
	wchar_t tmp[LF_FACESIZE];
	HWND fore_cb = GetDlgItem(hDlg, IDC_COLFORE);
	HWND back_cb = GetDlgItem(hDlg, IDC_COLBACK);
	HWND font_cb = GetDlgItem(hDlg, IDC_FONT);
	HWND size_cb = GetDlgItem(hDlg, IDC_FONTSIZE);
	int sel;
	
	api.SetInt(section, L"ForeColor", ColorBox_GetColorRaw(fore_cb));
	api.SetInt(section, L"BackColor", ColorBox_GetColorRaw(back_cb));
	
	ComboBox_GetLBText(font_cb, ComboBox_GetCurSel(font_cb), tmp);
	api.SetStr(section, L"Font", tmp);
	
	sel = ComboBox_GetCurSel(size_cb);
	if(sel == -1)
		ComboBox_GetText(size_cb, tmp, _countof(tmp));
	else
		ComboBox_GetLBText(size_cb, sel, tmp);
	api.SetInt(section, L"FontSize", _wtoi(tmp));
	
	api.SetInt(section, L"Bold",   IsDlgButtonChecked(hDlg, IDC_BOLD));
	api.SetInt(section, L"Italic", IsDlgButtonChecked(hDlg, IDC_ITALIC));
	
	api.SetInt(section, L"FontQuality", ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_FONTQUAL)));
	
	api.SetInt(section, L"ClockHeight", (int)SendDlgItemMessage(hDlg,IDC_SPINCHEIGHT,UDM_GETPOS32,0,0));
	api.SetInt(section, L"ClockWidth", (int)SendDlgItemMessage(hDlg,IDC_SPINCWIDTH,UDM_GETPOS32,0,0));
	api.SetInt(section, L"LineHeight", (int)SendDlgItemMessage(hDlg,IDC_SPINLHEIGHT,UDM_GETPOS32,0,0));
	api.SetInt(section, L"VertPos", (int)SendDlgItemMessage(hDlg,IDC_SPINVPOS,UDM_GETPOS32,0,0));
	api.SetInt(section, L"HorizPos", (int)SendDlgItemMessage(hDlg,IDC_SPINHPOS,UDM_GETPOS32,0,0));
	api.SetInt(section, L"Angle", (int)SendDlgItemMessage(hDlg,IDC_SPINANGLE,UDM_GETPOS32,0,0));
	
	if(!preview){
		api.SetInt(L"Taskbar", L"AlphaTaskbar", (int)SendDlgItemMessage(hDlg,IDC_SPINALPHA,UDM_GETPOS32,0,0));
		api.DelKey(L"Preview");
		m_transition = 0;
	}else
		m_transition = 1;
}
void plResponderProc::IDrawComboItem(DRAWITEMSTRUCT *dis)
{
    if (dis->itemID == -1)          // empty item
        return; 

    // The colors depend on whether the item is selected. 
    COLORREF clrForeground = SetTextColor(dis->hDC, 
        GetSysColor(dis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT)); 

    COLORREF clrBackground = SetBkColor(dis->hDC, 
        GetSysColor(dis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW)); 

    // Calculate the vertical and horizontal position.
    TEXTMETRIC tm;
    GetTextMetrics(dis->hDC, &tm);
    int y = (dis->rcItem.bottom + dis->rcItem.top - tm.tmHeight) / 2;
    int x = LOWORD(GetDialogBaseUnits()) / 4;

    // If this is a command, not a state, make it bold
    HFONT oldFont = nil;
    if (dis->itemData != kStateName)
    {
        LOGFONT lf;
        memset(&lf, 0, sizeof(lf));
        lf.lfHeight = tm.tmHeight;
        lf.lfWeight = FW_BOLD;
        GetTextFace(dis->hDC, LF_FACESIZE, lf.lfFaceName);
        HFONT boldFont = CreateFontIndirect(&lf);
        oldFont = SelectFont(dis->hDC, boldFont);
    }

    // Get and display the text for the list item.
    char buf[256];
    ComboBox_GetLBText(dis->hwndItem, dis->itemID, buf);
    if (fPB->GetInt(kResponderStateDef) == dis->itemID)
    {
        char buf2[256];
        sprintf(buf2, "* %s", buf);
        strcpy(buf, buf2);
    }

    ExtTextOut(dis->hDC, x, y, ETO_CLIPPED | ETO_OPAQUE, &dis->rcItem, buf, strlen(buf), NULL); 

    // Restore the previous colors. 
    SetTextColor(dis->hDC, clrForeground); 
    SetBkColor(dis->hDC, clrBackground); 

    if (oldFont)
        DeleteFont(SelectFont(dis->hDC, oldFont));

    // If the item has the focus, draw focus rectangle. 
    if (dis->itemState & ODS_FOCUS) 
        DrawFocusRect(dis->hDC, &dis->rcItem); 
}
Ejemplo n.º 13
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;
}
Ejemplo n.º 14
0
// Checks if the combo box contains the given text.
bool DeviceEnumeration::ComboBoxContainsText( HWND dialog, int id, char *text )
{
	char item[MAX_PATH];
	HWND control = GetDlgItem( dialog, id );
	for( int i = 0; i < ComboBoxCount( dialog, id ); i++ )
	{
		ComboBox_GetLBText( control, i, item );
		if( lstrcmp( item, text ) == 0 )
			return true;
	}
	return false;
}
Ejemplo n.º 15
0
int TftpDir_SelectEntry (HWND hCBWnd)
{
char szPath[_MAX_PATH];

    int n = ComboBox_GetCurSel (hCBWnd);
    if (     n!=CB_ERR  
        &&  ComboBox_GetLBTextLen (hCBWnd, n) < sizeof szPath  )
    {
        ComboBox_GetLBText (hCBWnd, n, sGuiSettings.szWorkingDirectory);
    }
return TRUE;
}  // TftpDir_SelectEntry
Ejemplo n.º 16
0
bool ComboBox_GetSelectedItemString(HWND hWnd, CString& value)
{
	int nSel = ComboBox_GetCurSel(hWnd);
	if (nSel == CB_ERR)
		return false;
	int len = ComboBox_GetLBTextLen(hWnd, nSel);
	TCHAR* pBuff = new TCHAR[len+1];
	if (ComboBox_GetLBText(hWnd, nSel, pBuff) == CB_ERR)
		assert(FALSE);
	value = pBuff;
	delete pBuff;
	return true;
}
Ejemplo n.º 17
0
//-----------------------------------------------------------------------------
// Name: ComboBoxContainsText
// Desc: Returns whether the combo box contains the given text.
//-----------------------------------------------------------------------------
bool CD3DSettingsDialog::ComboBoxContainsText( int id, TCHAR* pstrText )
{
    TCHAR strItem[200];
    HWND hwndCtrl = GetDlgItem( m_hDlg, id );
    UINT count = ComboBoxCount( id );
    for( UINT iItem = 0; iItem < count; iItem++ )
    {
        if( ComboBox_GetLBTextLen( hwndCtrl, iItem ) >= 200 )
            continue; // shouldn't happen, but don't overwrite buffer if it does
        ComboBox_GetLBText( hwndCtrl, iItem, strItem );
        if( lstrcmp( strItem, pstrText ) == 0 )
            return true;
    }
    return false;
}
Ejemplo n.º 18
0
BOOL FASTCALL CmdSignatureDlg_SaveSig( HWND hwnd, int index )
{
   char sz[ _MAX_FNAME ];
   HWND hwndList;
   register int c;
   HNDFILE fh;

   hwndList = GetDlgItem( hwnd, IDD_LIST );
   ComboBox_GetLBText( hwndList, index, sz );
   for( c = 0; sz[ c ]; ++c )
      if( !ValidFileNameChr( sz[ c ] ) )
         {
         wsprintf( lpTmpBuf, GS( IDS_STR136 ), sz[ c ] );
         fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION );
         return( FALSE );
         }
   lstrcat( sz, ".sig" );
   if( ( fh = Ameol2_CreateFile( sz, DSD_SIG, 0 ) ) == HNDFILE_ERROR )
      fMessageBox( hwnd, 0, GS( IDS_STR137 ), MB_OK|MB_ICONEXCLAMATION );
   else
      {
      WORD wSize;
      LPSTR lpText;
      HWND hwndEdit;

      INITIALISE_PTR(lpText);
      hwndEdit = GetDlgItem( hwnd, IDD_EDIT );
      wSize = Edit_GetTextLength( hwndEdit ) + 1;
      if( !fNewMemory( &lpText, wSize ) )
         OutOfMemoryError( hwnd, FALSE, FALSE );
      else
         {
         Edit_GetText( hwndEdit, lpText, wSize );
         if( Amfile_Write( fh, lpText, wSize ) == wSize )
            {
            FreeMemory( &lpText );
            Amfile_Close( fh );
            return( TRUE );
            }
         FreeMemory( &lpText );
         DiskWriteError( hwnd, sz, FALSE, FALSE );
         }
      Amfile_Close( fh );
      Amfile_Delete( sz );
      }
   return( FALSE );
}
Ejemplo n.º 19
0
void plAnimComponentProc::SetBoxToAgeGlobal(HWND box, const char *varName)
{
    char buff[512];
    if (!varName || !strcmp(varName, ""))
        varName = "(none)";

    ComboBox_SelectString(box, 0, varName);
    ComboBox_GetLBText(box, ComboBox_GetCurSel(box), buff);
    if (strcmp(varName, buff))
    {
        // Didn't find our variable in the age SDL file... 
        // Probably just missing the sdl file,
        // so we'll force it in there. It'll export fine.
        ComboBox_AddString(box, varName);
        ComboBox_SelectString(box, 0, varName);
    }
}   
Ejemplo n.º 20
0
/*------------------------------------------------
--------------------------------------------------*/
void SetComboFontSize(HWND hDlg, BOOL bInit)
{
	HDC hdc;
	wchar_t font[LF_FACESIZE];
	DWORD size;
	LOGFONT lf = {0};
	HWND size_cb = GetDlgItem(hDlg, IDC_FONTSIZE);
	HWND font_cb = GetDlgItem(hDlg, IDC_FONT);
	int pos;
	
	// remember old size
	if(bInit) { // on WM_INITDIALOG
		size = api.GetInt(L"Clock", L"FontSize", 9);
		if(!size || size>100) size = 9;
	} else { // when IDC_FONT has been changed
		ComboBox_GetText(size_cb, font, _countof(font));
		size = _wtoi(font);
	}
	
	ComboBox_ResetContent(size_cb);
	
	hdc = GetDC(NULL);
	m_logpixelsy = GetDeviceCaps(hdc, LOGPIXELSY);
	
	ComboBox_GetLBText(font_cb, ComboBox_GetCurSel(font_cb), font);
	
	wcscpy(lf.lfFaceName, font);
	lf.lfCharSet = DEFAULT_CHARSET;
	EnumFontFamiliesEx(hdc, &lf, EnumSizeProcEx,
					   (LPARAM)size_cb, 0);
					   
	ReleaseDC(NULL, hdc);
	
	wsprintf(font, FMT("%d"), size);
	pos = ComboBox_FindStringExact(size_cb, -1, font);
	if(pos != LB_ERR) {
		ComboBox_SetCurSel(size_cb, pos);
		return;
	}
	ComboBox_SetText(size_cb, font);
}
Ejemplo n.º 21
0
void init_info()
{
    extern uint32_t     ruijie_live_serial_num;
    extern uint8_t      client_ver_val[];
    extern char         username[];
    extern char         password[];
    extern int          username_length, password_length;
    extern int          dhcp_on;
    
    if ((reg_info_string 
            (reg_key, REG_KEY_USER, FALSE, NULL, username, 64) == ERROR_SUCCESS) &&
        (reg_info_string
            (reg_key, REG_KEY_PASS, FALSE, NULL, password, 64) == ERROR_SUCCESS)){
        username_length = strlen (username);
        password_length = strlen (password);
        Edit_SetText (hwndEditUser, TEXT(username));
        Edit_SetText (hwndEditPass, TEXT(password));
    }
    

    reg_info_dword (reg_key, REG_KEY_AUTO_CON, FALSE, BST_UNCHECKED, (DWORD*)&auto_con);
    reg_info_dword (reg_key, REG_KEY_AUTO_MIN, FALSE, BST_UNCHECKED, (DWORD*)&auto_min);
    CheckDlgButton(hwndDlg, IDC_CHK_AUTO_CON, auto_con);
    CheckDlgButton(hwndDlg, IDC_CHK_AUTO_MIN, auto_min);
    
    reg_info_dword (reg_key, REG_KEY_VER0,             FALSE, 3, (DWORD*)&client_ver_val[0]);
    reg_info_dword (reg_key, REG_KEY_VER1,             FALSE, 50, (DWORD*)&client_ver_val[1]);
    reg_info_dword (reg_key, REG_KEY_DHCP,                 FALSE,  1, (DWORD*)&dhcp_on);
    reg_info_dword (reg_key, REG_KEY_SER_NUM, FALSE, 0x0000102b, (DWORD*)&ruijie_live_serial_num);

    /* 判断注册表记录上次的网卡名称和列表里面选择的是否一样,
     * 不一样则临时禁用自动连接 */
    char    register_if_name[512] = {0};
    char    combo_if_name[512] = {0};

    reg_info_string (reg_key, REG_KEY_IF_NAME, FALSE, NULL, register_if_name, 512);
    ComboBox_GetLBText (hwndComboList, combo_index, combo_if_name);

    if (strcmp(register_if_name, combo_if_name) != 0) 
        auto_con = FALSE;
}
Ejemplo n.º 22
0
void GetCDRInfos(HWND hW,int * iA, int * iT,int * iL)
{
 HWND hWC=GetDlgItem(hW,IDC_DRIVE);
 char szB[256];int i;char * p;

 i=ComboBox_GetCurSel(hWC);
 if(i<=0)                                              // none selected
  {
   *iA=-1;*iT=-1;*iL=-1;
   MessageBox(hW,"Please select a cdrom drive!","Config error",MB_OK|MB_ICONINFORMATION);
   return;
  }

 ComboBox_GetLBText(hWC,i,szB);                        // get cd text
 p=szB+1;
 *iA=atoi(p);                                          // get AD,TA,LU
 p=strchr(szB,':')+1;
 *iT=atoi(p);
 p=strchr(p,':')+1;
 *iL=atoi(p);
}
Ejemplo n.º 23
0
static void onDrawItem(LPDRAWITEMSTRUCT lpdis, BOOL bDrive) 
{
  if((int)lpdis->itemID < 0)
    return;

  char szItem[_MAX_DIR];
  DWORD dwItemData;

  if(bDrive) 
  {
    dwItemData = ComboBox_GetItemData(lpdis->hwndItem, lpdis->itemID);
    ComboBox_GetLBText(lpdis->hwndItem, lpdis->itemID, szItem);
  } 
  else 
  {
    dwItemData = ListBox_GetItemData(lpdis->hwndItem, lpdis->itemID);
    ListBox_GetText(lpdis->hwndItem, lpdis->itemID, szItem);
  }

  if(lpdis->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) 
  {
    COLORREF colorText;
    COLORREF colorBack;
    if(lpdis->itemState & ODS_SELECTED) 
    {
      colorText = SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
      colorBack = SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
    }
    HICON hIcon;
    int indent = 0;
    if(bDrive) 
    {
      int iType=(int)HIWORD(dwItemData);
      switch (iType) 
      {
        case DRIVE_REMOVABLE:
          hIcon = hIconDrives[0];
          break; 
        case DRIVE_FIXED:
          hIcon = hIconDrives[1];
          break;
        case DRIVE_REMOTE:
          hIcon = hIconDrives[2];
          break; 
        case DRIVE_CDROM:
          hIcon = hIconDrives[3];
          break; 
        case DRIVE_RAMDISK:
          hIcon = hIconDrives[4];
          break; 
      }

    } 
    else 
    {
      int iconID = (int)HIWORD(lpdis->itemData);
      switch (iconID) 
      {
        case ID_ICON_FOLDERCLOSED:
          hIcon = hIconFolders[0];
          break;
        case ID_ICON_FOLDEROPEN:
          hIcon = hIconFolders[1];
          break;
        case ID_ICON_OPENSELECT:
          hIcon = hIconFolders[2];
          break;
      }
      indent = 4 * (1 + LOWORD(lpdis->itemData));
    }

    ExtTextOut(lpdis->hDC, 
               lpdis->rcItem.left + ITEM_LEFTMARGIN + ITEM_BITMAPWIDTH + ITEM_GAP + indent,
               lpdis->rcItem.top,
               ETO_OPAQUE | ETO_CLIPPED,
               &lpdis->rcItem,
               szItem,
               lstrlen(szItem),
               NULL);

    BOOL res = DrawIcon(lpdis->hDC, 
                        lpdis->rcItem.left + ITEM_LEFTMARGIN + indent,
                        lpdis->rcItem.top, 
                        hIcon);

    if(lpdis->itemState & ODS_SELECTED) 
    {
      SetTextColor(lpdis->hDC, colorText);
      SetBkColor(lpdis->hDC, colorBack);
    }
  }
  if((lpdis->itemAction & ODA_FOCUS) || (lpdis->itemState & ODS_FOCUS))
    DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
}
Ejemplo n.º 24
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;
    }
}
Ejemplo n.º 25
0
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: WndProc
--
-- DATE: February 9th, 2016
--
-- REVISIONS: February 9th, 2016: Created WndProc
--			  February 10th, 2016: Added WSAAsyncSelect socket calls and hooked up UI events
--			  February 15th, 2016: Commented
--
-- DESIGNER: Carson Roscoe
--
-- PROGRAMMER: Carson Roscoe
--
-- INTERFACE: LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
--
-- RETURN: long pointer result regarding exit code
--
-- NOTES:
-- Invoked whenever either a menu item has triggered an event, or whenever our socket has triggered a Accept or Read
-- event.
----------------------------------------------------------------------------------------------------------------------*/
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
    char ip[64];
    char portStr[64];
    char sizeStr[64];
    char timesStr[64];
    int port = DEFAULTPORT;
    int size = 2000;
    int times = 3;
    LPOPENFILENAME fileName;

    switch (Message) {
    //On destroy window, cleanup
    case WM_DESTROY:
        tcpConnection.Cleanup();
        udpConnection.Cleanup();
        break;
    //On create window
    case WM_CREATE:
        hdc = GetDC(hwnd);

        ReleaseDC(hwnd, hdc);
        break;
    //On UI command...
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        //On button pressed to send data
        case IDM_SEND:
            //determine if client.
            if (mode == Client) {
                GetWindowText(editTextIP, ip, sizeof(ip));
                GetWindowText(editTextPort, portStr, sizeof(portStr));
                ComboBox_GetLBText(comboBox1, ComboBox_GetCurSel(comboBox1), sizeStr);
                ComboBox_GetLBText(comboBox2, ComboBox_GetCurSel(comboBox2), timesStr);

                port = atoi(portStr);
                size = atoi(sizeStr);
                times = atoi(timesStr);

                switch (protocol) {
                case TCPmode:
                    tcpConnection.SendPacket(port, ip, size, times);
                    break;
                case UDPmode:
                    udpConnection.SendPacket(port, ip, size, times);
                    break;
                }
            } else { //Else we are teh server
                tcpConnection.Cleanup();
                udpConnection.Cleanup();
                GetWindowText(editTextPort, portStr, sizeof(portStr));
                switch (protocol) {
                case TCPmode:
                    tcpConnection.StartServer(atoi(portStr));
                    break;
                case UDPmode:
                    udpConnection.StartServer(atoi(portStr));
                    break;
                }
            }
            break;
        //If we are changing to either the client or the server
        case ID_MODE_CLIENT:
        case ID_MODE_SERVER:
            ChangeMode(wParam);
            break;
        //By default, update UDP/TCP modes
        default:
            switch (ComboBox_GetCurSel(comboBox3)) {
            case 0:
                protocol = TCPmode;
                break;
            case 1:
                protocol = UDPmode;
                break;
            }
        }
        break;
    //On receiving socket commands
    case WM_SOCKET:
        if (mode != Server)
            return 0;
        if (WSAGETSELECTERROR(lParam)) {
            int errorCode = WSAGETSELECTERROR(lParam);
            perror("Socket failed with error " + errorCode);
            //If it isnt an error
        } else {
            switch (WSAGETSELECTEVENT(lParam)) {
            //On accept call, we are TCP that means so call our Accept method
            case FD_ACCEPT:
                tcpConnection.Accept(wParam);
                break;
            //On read call determine which protocol and call appropriate read
            case FD_READ:
                GetWindowText(editTextPort, portStr, sizeof(portStr));
                switch (protocol) {
                case TCPmode:
                    tcpConnection.ReceivePacket(atoi(portStr), wParam);
                    break;
                case UDPmode:
                    udpConnection.ReceivePacket(atoi(portStr), wParam);
                    break;
                }
                return 0;
            }
        }
        return 0;
    default:
        return DefWindowProc(hwnd, Message, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 26
0
//
// CustomEntryDlgProc
//
// This function is the dialog procedure for the custom entry dialog and handles
// the basic events that happen within that dialog
//
INT_PTR CALLBACK CustomEntryDlgProc(
  HWND hwndDlg,  // handle to dialog box
  UINT uMsg,     // message
  WPARAM wParam, // first message parameter
  LPARAM lParam  // second message parameter
)
{  
    HWND hEditBox = NULL;                           // handle to an edit box
    HWND hComboBox = NULL;                          // handle to the combo box
    LPRASENTRYDLG lpInfo = NULL;                    // pointer to the RASENTRYDLG structure
    static LPRASENTRY lpRasEntry = NULL;            // pointer to the RASENTRY structure
    static PSAMPLE_CUSTOM_ENTRY_DATA pData = NULL;  // pointer to the SAMPLE_CUSTOM_ENTRY_DATA structure

    switch (uMsg)
    {
    case WM_INITDIALOG:    
        {
            // set up the dialog and the parameters
            pData = (PSAMPLE_CUSTOM_ENTRY_DATA) lParam;
            if (!pData) 
            {
                return FALSE;
            }

            lpInfo = &(pData->tEntryDlg);
            lpRasEntry = pData->ptEntry;                
          
            hComboBox = GetDlgItem(hwndDlg, IDC_LIST_MODEMS);

            hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_ENTRYNAME);
            if (hEditBox)
            {
                Edit_LimitText(hEditBox, RAS_MaxEntryName); // Count doesn't include NULL
                Edit_SetText(hEditBox, (LPTSTR)pData->szEntryName);
            }

            hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_PHONENO);
            if (hEditBox)
            {
                Edit_LimitText(hEditBox, CELEMS(lpRasEntry->szLocalPhoneNumber) - 1); // Count doesn't include NULL
                Edit_SetText(hEditBox, lpRasEntry->szLocalPhoneNumber);
            }
            
            //
            // enumerate to get the device name to use - we'll just do modems
            //
              
            // first get the size of the buffer required
            LPRASDEVINFO lpRasDevInfo = NULL;   // RASDEVINFO structure pointer
            DWORD dwNumEntries = 0;             // number of entries returned
            DWORD dwSize = sizeof(RASDEVINFO);  // size of buffer
            DWORD rc = 0;                       // return code


            // Allocate buffer with space for at least one structure
            lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
            if (NULL == lpRasDevInfo)
            {
                return FALSE;
            }

            lpRasDevInfo->dwSize = sizeof(RASDEVINFO);

            rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries);
            if (ERROR_BUFFER_TOO_SMALL == rc)
            {
                // If the buffer is too small, free the allocated memory and allocate a bigger buffer.
                if (HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo))
                {
                    lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
                    if (NULL == lpRasDevInfo)
                    {
                        OutputTraceString(L"--- Error allocating memory (HeapAlloc) for RASDEVINFO structures for RasEnumDevices(): %d\n", GetLastError());
                        return FALSE;
                    }

                    lpRasDevInfo->dwSize = sizeof(RASDEVINFO);

                    rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries);
                }
                else
                {
                    // Couldn't free the memory
                    return FALSE;
                }
            }

            // Check whether RasEnumDevices succeeded
            if (ERROR_SUCCESS == rc)
            {
                lpRasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
                if (NULL != lpRasDevInfo)
                {
                    lpRasDevInfo->dwSize = sizeof(RASDEVINFO);

                    rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries);
                    if (ERROR_SUCCESS == rc)
                    {
                        for (UINT i = 0; i < dwNumEntries; i++, lpRasDevInfo++)
                        {        
                            if (lstrcmpi(lpRasDevInfo->szDeviceType, RASDT_Modem) == 0)
                            {
                                if (hComboBox)
                                {
                                    // add to the list
                                    ComboBox_AddString(hComboBox, lpRasDevInfo->szDeviceName);         
                                }
                            }          
                        }
                    }

                    HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo);
                    lpRasDevInfo = NULL;
                }
                else
                {
                    OutputTraceString(L"--- Error allocating memory (HeapAlloc) for RASDEVINFO structures for RasEnumDevices(): %d\n", GetLastError());
                }
            }
        
            

            if (hComboBox)
            {
                // select the item we have in the entry
                ComboBox_SelectString(hComboBox, -1, lpRasEntry->szDeviceName);
            }

            // move dialog and position according to structure paramters
            // NOTE: we don't take into account multiple monitors or extreme
            // cases here as this is only a quick sample
            
            DWORD xPos = 0;         // x coordinate position for centering
            DWORD yPos = 0;         // y coordinate position for centering

            if (lpInfo->dwFlags & RASDDFLAG_PositionDlg)
            {
                xPos = lpInfo->xDlg;
                yPos = lpInfo->yDlg;
            }
            else
            {
                RECT rectTop;         // parent rectangle used for centering
                RECT rectDlg;         // dialog rectangle used for centering

                // center window within the owner or desktop
                GetWindowRect(lpInfo->hwndOwner != NULL ? lpInfo->hwndOwner : GetDesktopWindow(), &rectTop);
                GetWindowRect(hwndDlg, &rectDlg);
                         
                xPos = ((rectTop.left + rectTop.right) / 2) - ((rectDlg.right - rectDlg.left) / 2);
                yPos = ((rectTop.top + rectTop.bottom) / 2) - ((rectDlg.bottom - rectDlg.top) / 2);
            }

            SetWindowPos(hwndDlg, NULL, xPos, yPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

            return TRUE;
        }
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:          
            {
            TCHAR szEntryName[RAS_MaxEntryName + 1] = {0};  // Entry name
            TCHAR szPhoneBook[MAX_PATH + 1] = {0};          // Phonebook path
            TCHAR szPhoneNumber[RAS_MaxPhoneNumber + 1] = {0};

            // copy back the phonenumber, entry name, & device name
            hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_PHONENO);
            if (hEditBox)
            {
                Edit_GetText(hEditBox, lpRasEntry->szLocalPhoneNumber, CELEMS(lpRasEntry->szLocalPhoneNumber));
            }
          
            hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_ENTRYNAME);          
            if (hEditBox)
            {
                Edit_GetText(hEditBox, szEntryName, CELEMS(szEntryName));
            }
              
            hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_PHONENO);
            if (hEditBox)
            {
                Edit_GetText(hEditBox, szPhoneNumber, CELEMS(szPhoneNumber));
            }

            hComboBox = GetDlgItem(hwndDlg, IDC_LIST_MODEMS);          
            if (hComboBox)
            {
                ComboBox_GetLBText(hComboBox, ComboBox_GetCurSel(hComboBox), lpRasEntry->szDeviceName);
            }
            
            if (!pData) return FALSE;

            // Check entry name for validity
            StringCchCopy(szPhoneBook, CELEMS(szPhoneBook), (LPTSTR)pData->szPhoneBookPath);          
            if (RasValidateEntryName(szPhoneBook, szEntryName) == ERROR_INVALID_NAME)
            {
                MessageBox(hwndDlg, L"The Entry Name is Invalid.", L"Entry name error", MB_OK);
            }
            else          
            {
                StringCchCopy(pData->szEntryName, CELEMS(pData->szEntryName), szEntryName);
                StringCchCopy(lpRasEntry->szLocalPhoneNumber, CELEMS(lpRasEntry->szLocalPhoneNumber), szPhoneNumber);
                
                EndDialog(hwndDlg, TRUE);
            }
            
            return TRUE;
            }
        case IDCANCEL:
            EndDialog(hwndDlg, FALSE);
            return TRUE;
        }
        break;      
    }

    return FALSE;
}
Ejemplo n.º 27
0
void GetSettings(HWND hW) 
{
 HWND hWC;char cs[256];int i,j;char * p;

 hWC=GetDlgItem(hW,IDC_RESOLUTION);                    // get resolution
 i=ComboBox_GetCurSel(hWC);
 ComboBox_GetLBText(hWC,i,cs);
 iResX=atol(cs);
 p=strchr(cs,'x');
 iResY=atol(p+1);
 p=strchr(cs,',');									   // added by syo
 if(p) iRefreshRate=atol(p+1);						   // get refreshrate
 else  iRefreshRate=0;

 hWC=GetDlgItem(hW,IDC_COLDEPTH);                      // get color depth
 i=ComboBox_GetCurSel(hWC);
 ComboBox_GetLBText(hWC,i,cs);
 iColDepth=atol(cs);

 hWC=GetDlgItem(hW,IDC_SCANLINES);                     // scanlines
 iUseScanLines=ComboBox_GetCurSel(hWC);

 i=GetDlgItemInt(hW,IDC_WINX,NULL,FALSE);              // get win size
 if(i<50) i=50; if(i>20000) i=20000;
 j=GetDlgItemInt(hW,IDC_WINY,NULL,FALSE);
 if(j<50) j=50; if(j>20000) j=20000;
 iWinSize=MAKELONG(i,j);

 if(IsDlgButtonChecked(hW,IDC_DISPMODE2))              // win mode
  iWindowMode=1; else iWindowMode=0;

 if(IsDlgButtonChecked(hW,IDC_USELIMIT))               // fps limit
  UseFrameLimit=1; else UseFrameLimit=0;

 if(IsDlgButtonChecked(hW,IDC_USESKIPPING))            // fps skip
  UseFrameSkip=1; else UseFrameSkip=0;

 if(IsDlgButtonChecked(hW,IDC_GAMEFIX))                // game fix
  iUseFixes=1; else iUseFixes=0;

 if(IsDlgButtonChecked(hW,IDC_SYSMEMORY))              // use system memory
  iSysMemory=1; else iSysMemory=0;

 if(IsDlgButtonChecked(hW,IDC_STOPSAVER))              // stop screen saver
  iStopSaver=1; else iStopSaver=0;

 if(IsDlgButtonChecked(hW,IDC_VSYNC))                  // wait VSYNC
  bVsync=bVsync_Key=TRUE; else bVsync=bVsync_Key=FALSE;

 if(IsDlgButtonChecked(hW,IDC_TRANSPARENT))            // transparent menu
  bTransparent=TRUE; else bTransparent=FALSE;

 if(IsDlgButtonChecked(hW,IDC_SHOWFPS))                // show fps
  iShowFPS=1; else iShowFPS=0;

 if(IsDlgButtonChecked(hW,IDC_DEBUGMODE))              // debug mode
  iDebugMode=1; else iDebugMode=0;

 hWC=GetDlgItem(hW,IDC_NOSTRETCH);
 iUseNoStretchBlt=ComboBox_GetCurSel(hWC);

 hWC=GetDlgItem(hW,IDC_DITHER);
 iUseDither=ComboBox_GetCurSel(hWC);

 if(IsDlgButtonChecked(hW,IDC_FRAMEAUTO))              // frame rate
      iFrameLimit=2;
 else iFrameLimit=1;

 GetDlgItemText(hW,IDC_FRAMELIM,cs,255);
 fFrameRate=(float)atof(cs);
 if(fFrameRate<10.0f)  fFrameRate=10.0f;
 if(fFrameRate>200.0f) fFrameRate=200.0f;
}
Ejemplo n.º 28
0
BOOL CALLBACK DeviceDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
 switch(uMsg)
  {
   case WM_INITDIALOG:
    {
     HWND hWC;int i;
     DoDevEnum(hW);
     hWC=GetDlgItem(hW,IDC_DEVICE);
     i=ComboBox_FindStringExact(hWC,-1,szDevName);
     if(i==CB_ERR) i=0;
     ComboBox_SetCurSel(hWC,i);
     hWC=GetDlgItem(hW,IDC_GAMMA);
     ScrollBar_SetRange(hWC,0,1024,FALSE);
     if(iUseGammaVal==2048) ScrollBar_SetPos(hWC,512,FALSE);
     else
      {
       ScrollBar_SetPos(hWC,iUseGammaVal,FALSE);
       CheckDlgButton(hW,IDC_USEGAMMA,TRUE);
      }
    }

   case WM_HSCROLL:
    {
     HWND hWC=GetDlgItem(hW,IDC_GAMMA);
     int pos=ScrollBar_GetPos(hWC);
     switch(LOWORD(wParam))
      {
       case SB_THUMBPOSITION:    
        pos=HIWORD(wParam);break; 
       case SB_LEFT:
        pos=0;break;
       case SB_RIGHT:  
        pos=1024;break;
       case SB_LINELEFT:
        pos-=16;break;
       case SB_LINERIGHT:
        pos+=16;break;
       case SB_PAGELEFT:  
        pos-=128;break;
       case SB_PAGERIGHT: 
        pos+=128;break;

      }
     ScrollBar_SetPos(hWC,pos,TRUE);
     return TRUE;
    }

   case WM_COMMAND:
    {
     switch(LOWORD(wParam))
      {
       case IDCANCEL: FreeGui(hW);
                      EndDialog(hW,FALSE);return TRUE;
       case IDOK:     
        {
         HWND hWC=GetDlgItem(hW,IDC_DEVICE);
         int i=ComboBox_GetCurSel(hWC);
         if(i==CB_ERR) return TRUE;
         guiDev=*((GUID *)ComboBox_GetItemData(hWC,i));
         ComboBox_GetLBText(hWC,i,szDevName);
         FreeGui(hW);

         if(!IsDlgButtonChecked(hW,IDC_USEGAMMA))
          iUseGammaVal=2048;
         else
          iUseGammaVal=ScrollBar_GetPos(GetDlgItem(hW,IDC_GAMMA));

         EndDialog(hW,TRUE);
         return TRUE;
        }
      }
    }
  }
 return FALSE;
}                             
Ejemplo n.º 29
0
// list the entries (called ONCE at the end in order to save them)
int TftpDir_GetNextEntry (HWND hCBWnd)
{
static int n;
static char szPath [_MAX_PATH];
return (ComboBox_GetLBText (hCBWnd, n++, szPath) != CB_ERR);
} // TftpDir_GetNextEntry
Ejemplo n.º 30
0
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) 
{
  char szCurDir[_MAX_PATH];
  switch(id) 
  {
    case ID_LIST_DIR:
      if(codeNotify == LBN_DBLCLK) 
      {
        int index = ListBox_GetCurSel(hWndCtl);
        DWORD dwItemData = ListBox_GetItemData(hWndCtl, index);

        if(HIWORD(dwItemData) == ID_ICON_OPENSELECT) 
        {
          shutDialog(hWnd);
          char szString[_MAX_PATH];
          Edit_GetText(GetDlgItem(hWndDirPicker, ID_EDIT_DIR), szString, sizeof(szString));
          lstrcpy(lpszStringToReturn, szString);
          EndDialog(hWnd, IDOK);
          break;
        }

        ListBox_GetText(hWndCtl, index, szCurDir);

        char szDir[_MAX_DIR];
        LPSTR lpsz;
        if((HIWORD(dwItemData) == ID_ICON_FOLDEROPEN) && (index != 0)) 
        {
          GetWindowText(hWndCtl, szDir, sizeof(szDir));
          lpsz=_fstrstr(szDir, szCurDir);
          *(lpsz + lstrlen(szCurDir)) = '\0';
          lstrcpy(szCurDir, szDir);
        }
        if (_chdir(szCurDir) == 0) 
        {
          _getcwd(szCurDir, _MAX_PATH);
          fillListBox(hWndDirPicker, szCurDir);
        }
      }
      break;
    case ID_COMBO_DIR:
      if(codeNotify == CBN_SELCHANGE) 
      {
        char szDrive[80];
        int index = ComboBox_GetCurSel(hWndCtl);
        if(index == CB_ERR)
          break;
        ComboBox_GetLBText(hWndCtl, index, szDrive);

        int iCurDrive = _getdrive();
Retry:
        HCURSOR hCursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
        SetCapture(hWndDirPicker);
        if((0 == _chdrive((int)(szDrive[0] - 'a' + 1))) && (NULL != _getcwd(szCurDir, _MAX_PATH))) 
        {
          fillListBox(hWndDirPicker, szCurDir);
          ListBox_SetTopIndex(GetDlgItem(hWndDirPicker, ID_LIST_DIR), 0);
          SetCursor(hCursorOld);
          ReleaseCapture();
          break;
        }
        SetCursor(hCursorOld);
        ReleaseCapture();

        char szText[80];        
        sprintf(szText, "Cannot read drive %c:", szDrive[0]);
        if(IDRETRY == MessageBox(hWndDirPicker, szText, "Choose Directory", MB_ICONEXCLAMATION|MB_RETRYCANCEL))
          goto Retry;
        
        //Changing drives failed so restore drive and selection
        _chdrive(iCurDrive);

        sprintf(szDrive, "%c:", (char)(iCurDrive + 'a' - 1));
        index = ComboBox_SelectString(hWndCtl, -1, szDrive);
      }
      break;
    case IDOK:
      shutDialog(hWnd);
      char szString[_MAX_PATH];
      Edit_GetText(GetDlgItem(hWndDirPicker, ID_EDIT_DIR), szString, sizeof(szString));
      lstrcpy(lpszStringToReturn, szString);
      EndDialog(hWnd, IDOK);
      break;
    case IDCANCEL:
      shutDialog(hWnd);
      lpszStringToReturn[0] = '\0';
      EndDialog(hWnd, IDCANCEL);
      break;
    default:
      break;
  }
}