home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <windowsx.h>
-
- #include <commctrl.h>
- #include <wininet.h>
- #include "comctlhd.h"
- #include "cdlgopt.h"
- #include "clist.h"
- #include "cdlg.h"
- #include "capp.h"
- #include "resource.h"
-
- extern CApp *lpCApp;
-
- //**********************************************************************
- // CDlgOpt::CDlgOpt
- //
- // Purpose: Constructor for CDlgOpt class
- // Parameters: None
- //
- //********************************************************************
-
- CDlgOpt::CDlgOpt()
- {
- return;
- }
-
-
- //**********************************************************************
- // CDlgOpt::~CDlgOpt
- //
- // Purpose: Destructor for CDlgOpt class
- //********************************************************************
-
- CDlgOpt::~CDlgOpt()
- {
- return;
- }
-
- //**********************************************************************
- // CDlgOpt::Init
- //
- // Purpose: Create and show modal dialog
- //
- // Parameters: None
- //
- // Return Value:
- // BOOL - TRUE if initialization succeeded, FALSE otherwise.
- //
- //********************************************************************
-
- BOOL CDlgOpt::Init(HINSTANCE hInst, HWND hWnd, DLGDATA *pdata)
- {
- return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hWnd, (int (__stdcall *)(void))DialogProc, (LPARAM)pdata);
-
-
- }
-
-
- //**********************************************************************
- // CDlgOpt::DialogProc
- //
- // Purpose: Dialog procedure for connect options dialog
- //
- //
- //********************************************************************
-
-
- BOOL CALLBACK CDlgOpt::DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- DLGDATA *pdata;
- DWORD idc;
- CDlgOpt *lpCDlgOpt = lpCApp->m_pCDlgOpt;
- switch (message)
- {
- case WM_INITDIALOG:
- //initialization data is passed in via lParam
- pdata = (DLGDATA *)lParam;
-
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITPROXY),FALSE);
-
- //check the current setting of access type
- switch (pdata->dwAccessType)
- {
- case INTERNET_OPEN_TYPE_PRECONFIG:
- idc = IDC_OPTPRE;
- break;
- case INTERNET_OPEN_TYPE_DIRECT:
- idc = IDC_OPTLOCAL;
- break;
- case INTERNET_OPEN_TYPE_PROXY:
- idc = IDC_OPTCERN;
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITPROXY),TRUE);
- break;
- default:
- idc = IDC_OPTLOCAL;
- break;
-
- }
- Button_SetCheck(GetDlgItem(hWnd,idc), 1);
- //is this going to be anonymous logon
- if (pdata->anonymous)
- {
- Button_SetCheck(GetDlgItem(hWnd,IDC_CHECK1), 1);
- SetWindowText(GetDlgItem(hWnd, IDC_EDITUSER), pdata->pszUser);
- SetWindowText(GetDlgItem(hWnd, IDC_EDITPWD), pdata->pszPwd);
- Edit_Enable(GetDlgItem(hWnd, IDC_EDITUSER), FALSE);
- }
- else
- {
- Edit_Enable(GetDlgItem(hWnd, IDC_EDITUSER), FALSE);
- Edit_Enable(GetDlgItem(hWnd, IDC_EDITPWD), FALSE);
- }
- SetFocus(GetDlgItem(hWnd, IDC_EDITPWD));
-
- return FALSE;
-
- case WM_COMMAND: // message: command from application menu
- switch (LOWORD(wParam))
- {
- case IDC_CHECK1:
- if (Button_GetCheck(GetDlgItem(hWnd,IDC_CHECK1)))
- {
- Edit_SetText(GetDlgItem(hWnd,IDC_EDITUSER),"anonymous");
- Edit_SetText(GetDlgItem(hWnd,IDC_EDITPWD),"anonymous");
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITUSER),FALSE);
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITPWD),TRUE);
- }
- else
- {
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITUSER),TRUE);
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITPWD),TRUE);
- }
-
- break;
- case IDC_OPTPRE:
- case IDC_OPTLOCAL:
- Edit_SetText(GetDlgItem(hWnd,IDC_EDITPROXY), "");
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITPROXY),FALSE);
- break;
-
- case IDC_OPTCERN:
- Edit_Enable(GetDlgItem(hWnd,IDC_EDITPROXY),TRUE);
- break;
- case ID_SET:
- //committ the changes and copy the dialog box values
- //to the CDlgOpt class member variables
- lpCDlgOpt->m_anonymous = Button_GetCheck(GetDlgItem(hWnd,IDC_CHECK1));
- GetWindowText(GetDlgItem(hWnd,IDC_EDITUSER),lpCDlgOpt->m_pszUser,20);
- GetWindowText(GetDlgItem(hWnd,IDC_EDITPWD),lpCDlgOpt->m_pszPwd,20);
-
- if (0 == lstrlen(lpCDlgOpt->m_pszPwd))
- {
- MessageBox(hWnd, "Please enter a password", "Error", MB_ICONEXCLAMATION | MB_OK) ;
- return FALSE;
- }
- if ( 0 == lstrlen(lpCDlgOpt->m_pszUser))
- {
- if (!lpCDlgOpt->m_anonymous)
- {
- MessageBox(hWnd, "Please enter a user name", "Error", MB_ICONEXCLAMATION | MB_OK) ;
- return FALSE;
-
- }
- else {
- lstrcpy(lpCDlgOpt->m_pszUser, "anonymous"); }
- }
-
-
- if (Button_GetCheck(GetDlgItem(hWnd,IDC_OPTPRE)))
- lpCDlgOpt->m_dwAccessType = INTERNET_OPEN_TYPE_PRECONFIG;
- if (Button_GetCheck(GetDlgItem(hWnd,IDC_OPTLOCAL)))
- lpCDlgOpt->m_dwAccessType = INTERNET_OPEN_TYPE_DIRECT;
- if (Button_GetCheck(GetDlgItem(hWnd,IDC_OPTCERN)))
- {
- lpCDlgOpt->m_dwAccessType = INTERNET_OPEN_TYPE_PROXY;
- GetWindowText(GetDlgItem(hWnd,IDC_EDITPROXY),lpCDlgOpt->m_pszProxy,20);
- }
- else {
- //make sure the proxy string is initialized since it gets
- //copied over after the dialog is dismissed
- lstrcpy(lpCDlgOpt->m_pszProxy, "");
- }
-
-
- EndDialog(hWnd,ID_SET);
- break;
- case ID_END: // close dialog
- EndDialog(hWnd,ID_END);
- break;
- default:
- return FALSE;
- }
-
- case WM_DESTROY: // message: window being destroyed
- return 0;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-