Rev 153 | Rev 179 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 153 | Rev 164 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | 8 | ||
9 | 9 | ||
10 | // global variables used in this module only |
10 | // global variables used in this module only |
11 | static wchar_t candidate_email[128] = L""; |
11 | static wchar_t candidate_email[128] = L""; |
12 | static unsigned __int32 candidate_code = 0; // 32 bits |
12 | static unsigned __int32 candidate_code = 0; // 32 bits |
- | 13 | static bool was_donatebutton_clicked = false; |
|
13 | 14 | ||
14 | 15 | ||
15 | // prototypes of local functions |
16 | // prototypes of local functions |
16 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam); |
17 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam); |
17 | static unsigned __int32 RetrieveActivationCode (wchar_t *candidate_email, wchar_t **failure_reason); |
18 | static unsigned __int32 RetrieveActivationCode (wchar_t *candidate_email, wchar_t **failure_reason); |
Line 79... | Line 80... | ||
79 | ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_REGISTRATION_STATUSBAR)); |
80 | ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_REGISTRATION_STATUSBAR)); |
80 | } |
81 | } |
81 | 82 | ||
82 | // else did we click the close button on the title bar ? |
83 | // else did we click the close button on the title bar ? |
83 | else if (message == WM_CLOSE) |
84 | else if (message == WM_CLOSE) |
- | 85 | { |
|
- | 86 | if (was_donatebutton_clicked) |
|
- | 87 | { |
|
- | 88 | MessageBox (hWnd, LOCALIZE (L"Registration_DontForget"), PROGRAM_NAME, MB_ICONWARNING | MB_OK); // users need to be reminded that they MUST write their email in the activation form |
|
- | 89 | SendMessage (GetDlgItem (hWnd, EDITBOX_REGISTRATION_EMAILADDRESS), EM_SETSEL, 0, -1); // select all text |
|
- | 90 | SetFocus (GetDlgItem (hWnd, EDITBOX_REGISTRATION_EMAILADDRESS)); // focus on the email address field |
|
- | 91 | was_donatebutton_clicked = false; // once is enough |
|
- | 92 | return (true); // prevent window close this time |
|
- | 93 | } |
|
- | 94 | else |
|
84 | EndDialog (hWnd, 0); // close the dialog box |
95 | EndDialog (hWnd, 0); // close the dialog box |
- | 96 | } |
|
85 | 97 | ||
86 | // else did we take action on one of the controls ? |
98 | // else did we take action on one of the controls ? |
87 | else if (message == WM_COMMAND) |
99 | else if (message == WM_COMMAND) |
88 | { |
100 | { |
89 | // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key) |
101 | // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key) |
Line 104... | Line 116... | ||
104 | { |
116 | { |
105 | candidate_email[write_index] = tolower (candidate_email[read_index]); // force lowercase |
117 | candidate_email[write_index] = tolower (candidate_email[read_index]); // force lowercase |
106 | write_index++; // keep only valid signs and discard spaces |
118 | write_index++; // keep only valid signs and discard spaces |
107 | } |
119 | } |
108 | candidate_email[write_index] = 0; // ensure string is correctly terminated |
120 | candidate_email[write_index] = 0; // ensure string is correctly terminated |
109 | 121 | ||
110 | EnableWindow (GetDlgItem (hWnd, BUTTON_VALIDATECODE), ((candidate_email[0] != 0) && (wcslen (candidate_email) > 5) && (wcscmp (candidate_email, LOCALIZE (L"Registration_YourEmailHere")) != 0) |
122 | EnableWindow (GetDlgItem (hWnd, BUTTON_VALIDATECODE), ((candidate_email[0] != 0) && (wcslen (candidate_email) > 5) && (wcscmp (candidate_email, LOCALIZE (L"Registration_YourEmailHere")) != 0) |
111 | && (wcschr (candidate_email, L'@') != NULL) && (wcschr (candidate_email, L'.') != NULL))); |
123 | && (wcschr (candidate_email, L'@') != NULL) && (wcschr (candidate_email, L'.') != NULL))); |
112 | } |
124 | } |
113 | 125 | ||
114 | // else was it the validation button ? |
126 | // else was it the validation button ? |
Line 121... | Line 133... | ||
121 | if ((failure_reason != NULL) && (failure_reason[0] != 0)) |
133 | if ((failure_reason != NULL) && (failure_reason[0] != 0)) |
122 | MessageBox (hWnd, failure_reason, PROGRAM_NAME, MB_ICONERROR | MB_OK); // registration failed. Display an error and DON'T make the dialog box disappear |
134 | MessageBox (hWnd, failure_reason, PROGRAM_NAME, MB_ICONERROR | MB_OK); // registration failed. Display an error and DON'T make the dialog box disappear |
123 | 135 | ||
124 | // else is the retrieved data correct ? |
136 | // else is the retrieved data correct ? |
125 | else if (IsRegistrationCorrect (candidate_email, candidate_code)) |
137 | else if (IsRegistrationCorrect (candidate_email, candidate_code)) |
126 | { |
138 | { |
127 | // if so, save activation email and activation code |
139 | // if so, save activation email and activation code |
128 | wcscpy_s (options.registration.user_email, WCHAR_SIZEOF (options.registration.user_email), candidate_email); |
140 | wcscpy_s (options.registration.user_email, WCHAR_SIZEOF (options.registration.user_email), candidate_email); |
129 | options.registration.activation_code = candidate_code; |
141 | options.registration.activation_code = candidate_code; |
130 | MessageBox (hWnd, LOCALIZE (L"Registration_ThankYou"), PROGRAM_NAME, MB_ICONINFORMATION | MB_OK); |
142 | MessageBox (hWnd, LOCALIZE (L"Registration_ThankYou"), PROGRAM_NAME, MB_ICONINFORMATION | MB_OK); |
131 | EndDialog (hWnd, 0); // then display a thank you dialog box and make the dialog box disappear |
143 | EndDialog (hWnd, 0); // then display a thank you dialog box and make the dialog box disappear |
Line 146... | Line 158... | ||
146 | 158 | ||
147 | if (wcscmp (languages[language_id].name, L"French") == 0) |
159 | if (wcscmp (languages[language_id].name, L"French") == 0) |
148 | ShellExecute (NULL, L"open", PAYPAL_URL_FR, NULL, NULL, SW_MAXIMIZE); // open PayPal in French in the default browser, maximized |
160 | ShellExecute (NULL, L"open", PAYPAL_URL_FR, NULL, NULL, SW_MAXIMIZE); // open PayPal in French in the default browser, maximized |
149 | else |
161 | else |
150 | ShellExecute (NULL, L"open", PAYPAL_URL_XX, NULL, NULL, SW_MAXIMIZE); // open PayPal in English (default) the default browser, maximized |
162 | ShellExecute (NULL, L"open", PAYPAL_URL_XX, NULL, NULL, SW_MAXIMIZE); // open PayPal in English (default) the default browser, maximized |
- | 163 | ||
- | 164 | was_donatebutton_clicked = true; // remember the user clicked the Donate button |
|
151 | } |
165 | } |
152 | 166 | ||
153 | // else was it the status bar hyperlink ? |
167 | // else was it the status bar hyperlink ? |
154 | else if (wParam_loword == STATICTEXT_REGISTRATION_STATUSBAR) |
168 | else if (wParam_loword == STATICTEXT_REGISTRATION_STATUSBAR) |
155 | ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the main page in the default browser, maximized |
169 | ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the main page in the default browser, maximized |