Exemple #1
0
static void InitialiseEditControls (HWND hwnd)
{
	INFOOFFSET infoIdx = GetSelectedStructure(hwnd);
	char szNumber[20];
	HLOCAL hmem = GetProp(hwnd, SZINFODEF);
	LPSTRUCTINFO lpinfo = LocalLock(hmem);

	bUserChangeEdit = FALSE;
	bInitEdit = TRUE;
	my_dwtoa(infoMin[infoIdx].dwRows, szNumber, 10);
	Edit_Enable(GetDlgItem(hwnd, IDC_ROWS), FALSE);
	Edit_SetText (GetDlgItem(hwnd, IDC_ROWS), szNumber);
	Edit_Enable(GetDlgItem(hwnd, IDC_ROWS), TRUE);

	my_itoa(infoMin[infoIdx].nRowWidth, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_ROWWIDTH), szNumber);

	my_dwtoa(infoMin[infoIdx].dwUniqueKeys, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_UNIQUEKEYS), szNumber);

	my_itoa(infoMin[infoIdx].nKeyWidth, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_KEYWIDTH), szNumber);

	if (lpinfo[infoIdx].fillFactors.nData != -1)
		my_itoa(lpinfo[infoIdx].fillFactors.nData, szNumber, 10);
	else
		my_itoa(infoMin[infoIdx].fillFactors.nData, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_DATA), szNumber);

	if (lpinfo[infoIdx].fillFactors.nIndex != -1)
		my_itoa(lpinfo[infoIdx].fillFactors.nIndex, szNumber, 10);
	else
		my_itoa(infoMin[infoIdx].fillFactors.nIndex, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_INDEX), szNumber);

	if (lpinfo[infoIdx].fillFactors.nLeaf != -1)
		my_itoa(lpinfo[infoIdx].fillFactors.nLeaf, szNumber, 10);
	else
		my_itoa(infoMin[infoIdx].fillFactors.nLeaf, szNumber, 10);
	Edit_SetText (GetDlgItem(hwnd, IDC_LEAF), szNumber);

	if (lpinfo[infoIdx].fillFactors.nData != -1)
		SaveFillFactors.FillFactors.nData = lpinfo[infoIdx].fillFactors.nData;
	if (lpinfo[infoIdx].fillFactors.nIndex != -1)
		SaveFillFactors.FillFactors.nIndex = lpinfo[infoIdx].fillFactors.nIndex;
	if (lpinfo[infoIdx].fillFactors.nLeaf != -1)
		SaveFillFactors.FillFactors.nLeaf = lpinfo[infoIdx].fillFactors.nLeaf;

	bInitEdit = FALSE;

	LimitNumericEditControls(hwnd);

	LocalUnlock(hmem);
}
Exemple #2
0
void CPathEditWnd::Init( CPathEditUI* pOwner )
{
	m_pOwner = pOwner;
	RECT rcPos = CalPos();
	UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
	if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
	Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
	HFONT hFont=NULL;
	int iFontIndex=m_pOwner->GetFont();
	if (iFontIndex!=-1)
		hFont=m_pOwner->GetManager()->GetFont(iFontIndex);
	if (hFont==NULL)
		hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont;

	SetWindowFont(m_hWnd, hFont, TRUE);
	Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
	if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
	Edit_SetText(m_hWnd, m_pOwner->GetText());
	Edit_SetModify(m_hWnd, FALSE);
	SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
	Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
	Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
	//Styls
	LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
	styleValue |= pOwner->GetWindowStyls();
	::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
	::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
	::SetFocus(m_hWnd);
	m_bInit = true;    
}
Exemple #3
0
void CEditWnd::Init(CEditUI* pOwner)
{
    m_pOwner = pOwner;
    RECT rcPos = CalPos();
    UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;

    if (m_pOwner->IsPasswordMode()) uStyle |= ES_PASSWORD;
    
	Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
    SetWindowFont(m_hWnd, m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->hFont, TRUE);
    Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
    
	if (m_pOwner->IsPasswordMode()) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
    
	Edit_SetText(m_hWnd, m_pOwner->GetText());
    Edit_SetModify(m_hWnd, FALSE);
    
	SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
    Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
    Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
    
	::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
    ::SetFocus(m_hWnd);
    m_bInit = true;
}
void ProjectConfigDialog::onScreenSizeChanged(void)
{
    HWND list = GetDlgItem(m_hwndDialog, IDC_COMBO_SCREEN_SIZE);
    int index = ComboBox_GetCurSel(list);
    SimulatorConfig *defaults = SimulatorConfig::sharedDefaults();

    int w, h;
    if (index < defaults->numScreenSize())
    {
        const SimulatorScreenSize &size = defaults->getScreenSize(index);
        w = size.width;
        h = size.height;

        if (IsDlgButtonChecked(m_hwndDialog, IDC_RADIO_LANDSCAPE) == BST_CHECKED)
        {
            int w2 = w;
            w = h;
            h = w2;
        }
    }
    else
    {
        w = -1; h = -1;
    }

    if (w > 0)
    {
        char buff[32];
        sprintf_s(buff, "%d", w);
        SetDlgItemTextA(m_hwndDialog, IDC_EDIT_SCREEN_WIDTH, buff);
        sprintf_s(buff, "%d", h);
        SetDlgItemTextA(m_hwndDialog, IDC_EDIT_SCREEN_HEIGHT, buff);

        Edit_Enable(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_WIDTH), FALSE);
        Edit_Enable(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_HEIGHT), FALSE);
    }
    else
    {
        Edit_Enable(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_WIDTH), TRUE);
        Edit_Enable(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_HEIGHT), TRUE);
        SetFocus(GetDlgItem(m_hwndDialog, IDC_EDIT_SCREEN_WIDTH));
    }
}
//--------------------------------------------------------------------
void CWrapperConfigDialog::OnScreenSizeChanged()
{
	HWND list = GetDlgItem(m_hWndDialog, IDC_COMBO_SCREEN_SIZE);
	int index = ComboBox_GetCurSel(list);
	CSimulatorConfig *defaults = CSimulatorConfig::GetInstance();

	int w, h;
	if (index < defaults->GetScreenSizeCount())
	{
		const SSimulatorScreenSize &size = defaults->GetScreenSize(index);
		w = size.m_nWidth;
		h = size.m_nHeight;

		if (IsDlgButtonChecked(m_hWndDialog, IDC_RADIO_LANDSCAPE) == BST_CHECKED)
		{
			int w2 = w;
			w = h;
			h = w2;
		}
	}
	else
	{
		w = -1; h = -1;
	}

	if (w > 0)
	{
		char buff[32];
		sprintf_s(buff, "%d", w);
		SetDlgItemTextA(m_hWndDialog, IDC_EDIT_SCREEN_WIDTH, buff);
		sprintf_s(buff, "%d", h);
		SetDlgItemTextA(m_hWndDialog, IDC_EDIT_SCREEN_HEIGHT, buff);

		Edit_Enable(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_WIDTH), FALSE);
		Edit_Enable(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_HEIGHT), FALSE);
	}
	else
	{
		Edit_Enable(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_WIDTH), TRUE);
		Edit_Enable(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_HEIGHT), TRUE);
		SetFocus(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_WIDTH));
	}
}
Exemple #6
0
void CMultiLineEditWnd::Init(CMultiLineEditUI* pOwner)
{
   RECT rcPos = pOwner->GetPos();
   ::InflateRect(&rcPos, -1, -3);
   Create(pOwner->m_pManager->GetPaintWindow(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 0, rcPos);
   SetWindowFont(m_hWnd, pOwner->m_pManager->GetThemeFont(UIFONT_NORMAL), TRUE);
   Edit_SetText(m_hWnd, pOwner->m_sText);
   Edit_SetModify(m_hWnd, FALSE);
   SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
   Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
   Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
   if( pOwner->IsVisible() ) ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
   m_pOwner = pOwner;
}
Exemple #7
0
void CSingleLineEditWnd::Init(CSingleLineEditUI* pOwner)
{
   CRect rcPos = pOwner->GetPos();
   rcPos.Deflate(1, 3);
   Create(pOwner->GetManager()->GetPaintWindow(), NULL, WS_CHILD | pOwner->m_uEditStyle, 0, rcPos);
   SetWindowFont(m_hWnd, pOwner->GetManager()->GetThemeFont(UIFONT_NORMAL), TRUE);
   Edit_SetText(m_hWnd, pOwner->GetText());
   Edit_SetModify(m_hWnd, FALSE);
   SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
   Edit_SetSel(m_hWnd, 0, -1);
   Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
   Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
   ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
   ::SetFocus(m_hWnd);
   m_pOwner = pOwner;
}
void CMultiLineEditWnd::Init(CMultiLineEditUI* pOwner)
{
    CRect rcPos = pOwner->GetPos();
#if 1
    Create(pOwner->m_pCanvas->GetHWND(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0, rcPos);
#else
    Create(pOwner->m_pManager->GetPaintWindow(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0, rcPos);
#endif
    SetWindowFont(m_hWnd, pOwner->GetManager()->GetDefaultFont(), TRUE);
    Edit_SetText(m_hWnd, pOwner->m_sText);
    Edit_SetModify(m_hWnd, FALSE);
    SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
    Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
    Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
    if( pOwner->IsVisible() ) ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
    m_pOwner = pOwner;
}
bool
ObjectReference::enable( bool bEnabled )
{
	bool ret = false;
	if ( uiDialog::enable( bEnabled ) )
	{
		assert( hwndEdit );
		Edit_Enable( hwndEdit, uiDialog::enable() );
		assert( hwndBrowseButton );
		Button_Enable( hwndBrowseButton, uiDialog::enable() );
		updateGoToObjectButton();
		return true;
	}

	eval();
	return ret;
}
void CWindow::initialize() {
    numbers = std::vector< std::vector<int> >(sizeY + blocksNum);
	edits = std::vector< std::vector<HWND> >(sizeY + blocksNum);
    for( int i = 0; i < (sizeY + blocksNum); i++ ) {
        numbers[i].resize(sizeX + blocksNum);
		edits[i].resize(sizeX + blocksNum);
    }
    for( int i = 0; i < (sizeY + blocksNum); i++ ){
        for( int j = 0; j < (sizeX + blocksNum); j++ ) {
            numbers[i][j] = 0;
        }
    }

	RECT rect;
	::GetClientRect( handle, &rect ); 
	int width = rect.right - rect.left;
	int height = rect.bottom - rect.top;

    qWidth = ( width - 5 ) / ( sizeX + blocksNum ) + 1;
    qHeight = ( height - 5 ) / ( sizeY + blocksNum ) + 1;

	for( int i = 0; i < sizeY + blocksNum; i++ ) {
        for( int j = 0; j < sizeX + blocksNum; j++ ) {
            RECT rect;
            rect.left = j * qWidth;
            rect.top = i * qHeight;
            rect.right = (j + 1) * qWidth;
            rect.bottom = (i + 1) * qHeight;
            if( (i < blocksNum) ^ (j < blocksNum) ) {
				HFONT font = CreateFont(qWidth / (1.1) , 0, 0, 0, 0, 0u, 0U, 0U, ANSI_CHARSET, 0U, 0U, 0U, 0U, TEXT("Arial"));
				edits[i][j] = CreateWindowEx(NULL, L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_GROUP | WS_BORDER | ES_CENTER | ES_NUMBER, 
        rect.left, rect.top, qWidth - 0.1, qHeight - 0.1, handle, NULL, GetModuleHandle(NULL), NULL);
				if (i != blocksNum - 1 && j != blocksNum - 1) {
					Edit_Enable(edits[i][j], false);
				}
				iEdit[edits[i][j]] = i;
				jEdit[edits[i][j]] = j;
				SendMessage(edits[i][j], WM_SETFONT, (WPARAM) font, MAKELPARAM(TRUE, 0));
			}          
        }
    }
}
Exemple #11
0
static void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
   LPSECURITYALARMPARAMS lpsecurity = GetDlgProp (hwnd);
   HWND hwndUsers    = GetDlgItem (hwnd, IDC_SALARM_BYUSER );
   HWND hwndTables = GetDlgItem (hwnd, IDC_SALARM_ONTABLE );
   HWND hwndName   = GetDlgItem (hwnd, IDC_SALARM_NAME );        

   int idu;    
   int i, n, idt;   
   int ires;
   char szName [MAXOBJECTNAME];

   switch (id)
   {
       case IDOK:
           if (!FillStructureFromControls (hwnd, lpsecurity))
               break;
           //
           // Call the low level function to write data on disk
           //

           ires = DBAAddObject
               (GetVirtNodeName (GetCurMdiNodeHandle ()),
               OTLL_SECURITYALARM,
               (void *) lpsecurity );

           if (ires != RES_SUCCESS)
           {
               FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM);
               ErrorMessage   ((UINT)IDS_E_CREATE_SECURITY_FAILED, ires);
               break;
           }
           else
               EndDialog (hwnd, TRUE);
           
           FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM);
           break;

       case IDCANCEL:
           EndDialog (hwnd, FALSE);
           FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM);
           break;

       case IDC_SALARM_BYUSER:
           if (Edit_GetText (hwndName, szName, sizeof (szName)) != 0 &&
              CAListBox_GetSelCount (hwndUsers) > 1)   {
                idu=CAListBox_GetCurSel (hwndUsers);
                n = CAListBox_GetCount (hwndUsers);
                for (i=0; i<n; i++)
                       CAListBox_SetSel (hwndUsers, FALSE, i);
               CAListBox_SetCurSel (hwndUsers, idu);
               CAListBox_SetSel (hwndUsers, TRUE, idu);
               //"Multiple auth-id is not allowed if the security alarm has a name."
               MessageBox(hwnd,
                   ResourceString(IDS_ERR_USING_CHECKPOINT),
                   NULL, MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
                   EnableDisableOKButton (hwnd);
             }
           else if (CAListBox_GetSelCount (hwndUsers) > 1)
                  Edit_Enable(hwndName,FALSE);
                else
                  Edit_Enable(hwndName,TRUE);
               
           EnableDisableOKButton (hwnd);
           break;

       case IDC_SALARM_ONTABLE:
           if (codeNotify == CALBN_CHECKCHANGE) {
               idt = CAListBox_GetCurSel (hwndTables);              
                n = CAListBox_GetCount (hwndTables);                
       
                for (i=0; i<n; i++)
                  CAListBox_SetSel (hwndTables, FALSE, i);      
           
               CAListBox_SetCurSel (hwndTables, idt);              
                CAListBox_SetSel (hwndTables, TRUE, idt);
               if (bNoDisplayMessageDB == FALSE) {
                  int iret;
                  //"Only one database can be checked. Previous database, if any, was unchecked.\nDon't display this message any more?"
                  iret = MessageBox(hwnd, ResourceString(IDS_ERR_DATABASE_BE_CHECKED),
                         NULL, MB_OKCANCEL | MB_ICONEXCLAMATION | MB_TASKMODAL);
                  if (iret == IDOK)
                     bNoDisplayMessageDB=TRUE;
               }
           }
           EnableDisableOKButton (hwnd);
           break;

       case IDC_SALARM_SUCCESS:
       case IDC_SALARM_FAILURE:
       case IDC_SALARM_SUCCESSFAILURE:
       case IDC_SALARM_SELECT:
       case IDC_SALARM_DELETE:
       case IDC_SALARM_INSERT:
       case IDC_SALARM_UPDATE:
       case IDC_SALARM_CONNECT:
       case IDC_SALARM_DISCONNECT:
           EnableDisableOKButton (hwnd);
           break;

       case IDC_SALARM_USER:
           if (Button_GetCheck (hwndCtl))
           {
               CAListBox_ResetContent (hwndUsers);
               CAListBoxFillUsers     (hwndUsers);
               EnableDisableOKButton (hwnd);
           }
           break;

       case IDC_SALARM_GROUP:
           if (Button_GetCheck (hwndCtl))
           {
               CAListBox_ResetContent (hwndUsers);
               CAListBoxFillGroups    (hwndUsers);
               EnableDisableOKButton (hwnd);
           }
           break;

       case IDC_SALARM_ROLE:
           if (Button_GetCheck (hwndCtl))
           {
               CAListBox_ResetContent (hwndUsers);
               CAListBoxFillRoles     (hwndUsers);
               EnableDisableOKButton  (hwnd);
           }
           break;

       case IDC_SALARM_PUBLIC:
           if (Button_GetCheck (hwndCtl))
           {
               CAListBox_ResetContent (hwndUsers);
               EnableDisableOKButton  (hwnd);
           }
           break;

       case IDC_SALARM_DBEVENT:
           if (codeNotify == CBN_SELCHANGE)
           {
               char szItem [MAXOBJECTNAME];

               ZEROINIT (szItem);
               ComboBox_GetText (hwndCtl, szItem, sizeof (szItem));

               if (x_strcmp (szItem, szSecurityDBEvent) == 0)
               {
                   lpsecurity->bDBEvent = FALSE;
                   EnableControl (hwnd, FALSE);
               }
               else
                   EnableControl (hwnd, TRUE);
           }
           break;
   }
}
Exemple #12
0
LRESULT CALLBACK Candify::DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	Candify *pApp;

	pApp = (Candify*)GetWindowLong(hWnd, GWL_USERDATA);

	switch (message) {
	case WM_INITDIALOG: 
		{
			HWND hUsernameEdit, hPasswordEdit, hConnectButton, hExitButton;
			HWND hPlaylistCombo, hPlayButton;
			
			hUsernameEdit = GetDlgItem(hWnd, IDC_USERNAMEEDIT);
			hPasswordEdit = GetDlgItem(hWnd, IDC_PASSWORDEDIT);
			hConnectButton = GetDlgItem(hWnd, IDC_CONNECTBUTTON);
			hExitButton = GetDlgItem(hWnd, IDC_EXITBUTTON);
			hPlaylistCombo = GetDlgItem(hWnd, IDC_PLAYLISTCOMBO);
			hPlayButton = GetDlgItem(hWnd, IDC_PLAYBUTTON);

			pApp->SubclassControl(hUsernameEdit);
			pApp->SubclassControl(hPasswordEdit);
			pApp->SubclassControl(hConnectButton);
			pApp->SubclassControl(hExitButton);
			pApp->SubclassControl(hPlaylistCombo);
			pApp->SubclassControl(hPlayButton);

			ComboBox_SetMinVisible(hPlaylistCombo, 5);

			SetFocus(hUsernameEdit);
		}
		break;
	case WM_DLGLOGGEDIN:
		{
			HWND hUsernameEdit, hPasswordEdit, hConnectButton;
			hUsernameEdit = GetDlgItem(hWnd, IDC_USERNAMEEDIT);
			hPasswordEdit = GetDlgItem(hWnd, IDC_PASSWORDEDIT);
			hConnectButton = GetDlgItem(hWnd, IDC_CONNECTBUTTON);

			Edit_Enable(hUsernameEdit, FALSE);
			Edit_Enable(hPasswordEdit, FALSE);
			Button_Enable(hConnectButton, FALSE);
		}
		break;
	case WM_DLGUPDATEPLAYLISTS:
		{
			HWND hPlaylistCombo, hPlayButton;
			LPCSTR *playlists;
			int nPlaylists;

			hPlaylistCombo = GetDlgItem(hWnd, IDC_PLAYLISTCOMBO);
			hPlayButton = GetDlgItem(hWnd, IDC_PLAYBUTTON);

			ComboBox_Enable(hPlaylistCombo, TRUE);
			Button_Enable(hPlayButton, TRUE);

			ComboBox_ResetContent(hPlaylistCombo);

			nPlaylists = pApp->m_lpSpotify->getPlaylists(&playlists);
			for (int i = 0; i < nPlaylists; i++) {
				ComboBox_AddString(hPlaylistCombo, playlists[i]);
				free((LPVOID)playlists[i]);
			}
			delete[] playlists;
		}
		break;
	case WM_DLGLOGINFAILED:
		{
			HWND hConnectButton;

			MessageBox(hWnd, "Login failed!", "Candify", MB_ICONINFORMATION);

			hConnectButton = GetDlgItem(hWnd, IDC_CONNECTBUTTON);
			Button_Enable(hConnectButton, true);
		}
		break;
	case WM_COMMAND:
		{
			switch (LOWORD(wParam)) {
			case IDC_EXITBUTTON:
				{
					PostQuitMessage(0);
				}
				break;
			case IDC_CONNECTBUTTON:
				{
					HWND hConnectButton;
					CHAR szUsername[100], szPassword[100];

					hConnectButton = GetDlgItem(hWnd, IDC_CONNECTBUTTON);
					Button_Enable(hConnectButton, false);

					GetDlgItemText(hWnd, IDC_USERNAMEEDIT, szUsername, 
						sizeof(szUsername)/sizeof(*szUsername));
					GetDlgItemText(hWnd, IDC_PASSWORDEDIT, szPassword, 
						sizeof(szPassword)/sizeof(*szPassword));
					pApp->Connect(szUsername, szPassword);
				}
				break;
			case IDC_PLAYBUTTON:
				{
					CHAR szPlaylist[100];
					GetDlgItemText(hWnd, IDC_PLAYLISTCOMBO, 
						szPlaylist, sizeof(szPlaylist)/sizeof(*szPlaylist));
					pApp->m_lpSpotify->setPlaylist(szPlaylist);
					ShowWindow(pApp->m_hWnd, SW_SHOW);
					EndDialog(hWnd, 0);
				}
				break;
			}
		}
		break;
	}

	return FALSE;
}
Exemple #13
0
BOOL event_dialog::onCommand(INT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (LOWORD(wParam))
  {
    case IDOK:
    {      
      char event_string[7];
      GetDlgItemText(hSelf, ID_EVENTBOX, event_string, 7);
      
      char arg_string[4][50];
      GetDlgItemText(hSelf, ID_EVENTARG1, arg_string[0], 49);
      GetDlgItemText(hSelf, ID_EVENTARG2, arg_string[1], 49);
      GetDlgItemText(hSelf, ID_EVENTARG3, arg_string[2], 49);
      GetDlgItemText(hSelf, ID_EVENTARG4, arg_string[3], 49);      
      
      event->sender = 0;
      if (sscanf(event_string, "%x", &event->event))
      {
        bool success = true;
        for (int lp=0; lp<event->count && success; lp++)
        {
          if (arg_string[lp][0] == '0' && arg_string[lp][1] == 'x')
            success = sscanf(arg_string[lp], "%x", &event->args[lp]);
          else
            success = sscanf(arg_string[lp], "%i", &event->args[lp]);
        }
      
        if (success)
        {
          EndDialog(hSelf, (INT_PTR)event);
          return TRUE;
        }
      }
      
      MessageBox(NULL, "Please enter only numeric or hexadecimal arguments.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
      return FALSE;
    }
  }
  
  switch (HIWORD(wParam))
  {
    case BN_CLICKED:
    {
      switch (LOWORD(wParam))
      {
        case ID_RADIOARGN:
        
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARGN), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG1), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG2), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG3), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG4), BST_UNCHECKED);
        
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG1), false);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG2), false);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG3), false);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG4), false);
        
        event->count = 0;
        break;
        
        case ID_RADIOARG1:
        
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARGN), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG1), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG2), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG3), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG4), BST_UNCHECKED);
        
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG1), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG2), false);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG3), false);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG4), false);
        
        event->count = 1;
        break;
        
        case ID_RADIOARG2:
        
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARGN), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG1), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG2), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG3), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG4), BST_UNCHECKED);
        
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG1), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG2), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG3), false);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG4), false);
        
        event->count = 2;
        break;
        
        case ID_RADIOARG3:
        
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARGN), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG1), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG2), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG3), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG4), BST_UNCHECKED);
        
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG1), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG2), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG3), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG4), false);
        
        event->count = 3;
        break;
        
        case ID_RADIOARG4:
        
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARGN), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG1), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG2), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG3), BST_CHECKED);
        Button_SetCheck(GetDlgItem(hSelf, ID_RADIOARG4), BST_CHECKED);
        
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG1), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG2), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG3), true);
        Edit_Enable(GetDlgItem(hSelf, ID_EVENTARG4), true);
        
        event->count = 4;
        break;
      } 
    }   
  }     
}