소스 검색

Merge pull request #610 from pavel-pimenov/add-struct-dlg_header_param-20-04-2018

WinAPI: Add struct dlg_header_param
bel2125 7 년 전
부모
커밋
b08dd2a790
1개의 변경된 파일30개의 추가작업 그리고 76개의 파일을 삭제
  1. 30 76
      src/main.c

+ 30 - 76
src/main.c

@@ -1527,6 +1527,32 @@ struct dlg_proc_param {
 	BOOL (*fRetry)(struct dlg_proc_param *data);
 };
 
+struct dlg_header_param{
+	DLGTEMPLATE dlg_template; /* 18 bytes */
+	WORD menu, dlg_class;
+	wchar_t caption[1];
+	WORD fontsiz;
+	wchar_t fontface[7];
+};
+
+static struct dlg_header_param GetDlgHeader(unsigned pWidth)
+{
+	struct dlg_header_param
+		dialog_header = { { WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE
+		| DS_SETFONT | WS_DLGFRAME,
+		WS_EX_TOOLWINDOW,
+		0,
+		200,
+		200,
+		pWidth,
+		0 },
+		0,
+		0,
+		L"",
+		8,
+		L"Tahoma" };
+	return dialog_header;
+}
 
 /* Dialog proc for settings dialog */
 static INT_PTR CALLBACK
@@ -1829,25 +1855,7 @@ get_password(const char *user,
 	short y;
 	static struct dlg_proc_param s_dlg_proc_param;
 
-	static struct {
-		DLGTEMPLATE dlg_template; /* 18 bytes */
-		WORD menu, dlg_class;
-		wchar_t caption[1];
-		WORD fontsiz;
-		wchar_t fontface[7];
-	} dialog_header = {{WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE
-	                        | DS_SETFONT | WS_DLGFRAME,
-	                    WS_EX_TOOLWINDOW,
-	                    0,
-	                    200,
-	                    200,
-	                    WIDTH,
-	                    0},
-	                   0,
-	                   0,
-	                   L"",
-	                   8,
-	                   L"Tahoma"};
+	const struct dlg_header_param dialog_header = GetDlgHeader(WIDTH);
 
 	DEBUG_ASSERT((user != NULL) && (realm != NULL) && (passwd != NULL));
 
@@ -2124,25 +2132,7 @@ show_settings_dialog()
 	short width, x, y;
 	static struct dlg_proc_param s_dlg_proc_param;
 
-	static struct {
-		DLGTEMPLATE dlg_template; /* 18 bytes */
-		WORD menu, dlg_class;
-		wchar_t caption[1];
-		WORD fontsiz;
-		wchar_t fontface[7];
-	} dialog_header = {{WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE
-	                        | DS_SETFONT | WS_DLGFRAME,
-	                    WS_EX_TOOLWINDOW,
-	                    0,
-	                    200,
-	                    200,
-	                    WIDTH,
-	                    0},
-	                   0,
-	                   0,
-	                   L"",
-	                   8,
-	                   L"Tahoma"};
+	const struct dlg_header_param dialog_header = GetDlgHeader(WIDTH);
 
 	if (s_dlg_proc_param.guard == 0) {
 		memset(&s_dlg_proc_param, 0, sizeof(s_dlg_proc_param));
@@ -2318,25 +2308,7 @@ change_password_file()
 	const char *domain = mg_get_option(g_ctx, "authentication_domain");
 	static struct dlg_proc_param s_dlg_proc_param;
 
-	static struct {
-		DLGTEMPLATE dlg_template; /* 18 bytes */
-		WORD menu, dlg_class;
-		wchar_t caption[1];
-		WORD fontsiz;
-		wchar_t fontface[7];
-	} dialog_header = {{WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE
-	                        | DS_SETFONT | WS_DLGFRAME,
-	                    WS_EX_TOOLWINDOW,
-	                    0,
-	                    200,
-	                    200,
-	                    WIDTH,
-	                    0},
-	                   0,
-	                   0,
-	                   L"",
-	                   8,
-	                   L"Tahoma"};
+	const struct dlg_header_param dialog_header = GetDlgHeader(WIDTH);
 
 	if (s_dlg_proc_param.guard == 0) {
 		memset(&s_dlg_proc_param, 0, sizeof(s_dlg_proc_param));
@@ -2560,25 +2532,7 @@ show_system_info()
 	short y;
 	static struct dlg_proc_param s_dlg_proc_param;
 
-	static struct {
-		DLGTEMPLATE dlg_template; /* 18 bytes */
-		WORD menu, dlg_class;
-		wchar_t caption[1];
-		WORD fontsiz;
-		wchar_t fontface[7];
-	} dialog_header = {{WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE
-	                        | DS_SETFONT | WS_DLGFRAME,
-	                    WS_EX_TOOLWINDOW,
-	                    0,
-	                    200,
-	                    200,
-	                    WIDTH,
-	                    0},
-	                   0,
-	                   0,
-	                   L"",
-	                   8,
-	                   L"Tahoma"};
+	const struct dlg_header_param dialog_header = GetDlgHeader(WIDTH);
 
 	/* Only allow one instance of this dialog to be open. */
 	if (s_dlg_proc_param.guard == 0) {