From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-041.btinternet.com (mailomta20-re.btinternet.com [213.120.69.113]) by sourceware.org (Postfix) with ESMTPS id 1EC47385E451 for ; Fri, 8 Mar 2024 18:36:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EC47385E451 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dronecode.org.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1EC47385E451 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=213.120.69.113 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709922969; cv=none; b=A/dikHo011d1dCFcjhcUlf05VUMIn6RF1Mv1elu+ulCD6jBkr6QVknLbDRcFCyzQp9ybfj3yEbCTMV4031c9j5Koijqy/Oqy62Ujb9NxVs3eMUHpHzAJko+68XciTiGG3enqTHlvC5sKkXwEnBT/8+qlUhgQRil86w+QT1jQZEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709922969; c=relaxed/simple; bh=rehJoJUeT4H3E7Q4Fw0SW9xVg7IOoHD4kxxzpmXnaZs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=opENmc+HC0ZlXR3n5Hq738sOvjkuV/7L6/zoP+ZV/QM/UvGCjADKXgrIp/pP81gvCzbmUUBBOuRKjmLiccFQE3C1hGjvGAR98mx3hkGRnCbaAfE0fQGuWjmUSMsQ3S7ZP6bWSiCUh1CWkDB7lHdXMy9FfX4YFbGen7rUZCRN6Rw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from re-prd-rgout-004.btmx-prd.synchronoss.net ([10.2.54.7]) by re-prd-fep-041.btinternet.com with ESMTP id <20240308183605.UJON21578.re-prd-fep-041.btinternet.com@re-prd-rgout-004.btmx-prd.synchronoss.net>; Fri, 8 Mar 2024 18:36:05 +0000 Authentication-Results: btinternet.com; none X-SNCR-Rigid: 6577B87C0AB06947 X-Originating-IP: [81.153.98.185] X-OWM-Source-IP: 81.153.98.185 X-OWM-Env-Sender: jon.turney@dronecode.org.uk X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvledrieehgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepleeitdejhfdtveekheeugeffgeevfedtjeejveefhfeiffefkedtvdetheehieejnecukfhppeekuddrudehfedrleekrddukeehnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehhvghloheplhhotggrlhhhohhsthdrlhhotggrlhguohhmrghinhdpihhnvghtpeekuddrudehfedrleekrddukeehpdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegthihgfihinhdqrghpphhssegthihgfihinhdrtghomhdprhgtphhtthhopehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkpdhrvghvkffrpehhohhsthekuddqudehfedqleekqddukeehrdhrrghnghgvkeduqdduheefrdgsthgtvghnthhrrghlphhluhhsrdgtohhmpdgruhhthhgpuhhsvghrpehjohhnthhurhhnvgihsegsthhinhhtvghrnhgvthdrtghomhdpghgvohfk rfepifeupdfovfetjfhoshhtpehrvgdqphhrugdqrhhgohhuthdqtddtge X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (81.153.98.185) by re-prd-rgout-004.btmx-prd.synchronoss.net (authenticated as jonturney@btinternet.com) id 6577B87C0AB06947; Fri, 8 Mar 2024 18:36:05 +0000 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 11/16] Drop hinstance global Date: Fri, 8 Mar 2024 18:34:30 +0000 Message-ID: <20240308183440.4263-12-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308183440.4263-1-jon.turney@dronecode.org.uk> References: <20240308183440.4263-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: We do not need to retain the hInstance value passed into WinMain(), as it's always available as GetModuleHandle(NULL). Note that DialogBox() accepts NULL meaning "the current executable" in any case. Future work: there's still some completely unnecessary storing it in class Window and passing it around. --- dialog.h | 3 --- gui/SitePage.cc | 3 +-- install.cc | 2 +- main.cc | 5 +---- msg.cc | 5 ++--- netio.cc | 10 +++++----- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/dialog.h b/dialog.h index 63c98ee..ebbf661 100644 --- a/dialog.h +++ b/dialog.h @@ -20,9 +20,6 @@ #include "win32.h" -/* global instance for the application; set in main.cc */ -extern HINSTANCE hinstance; - /* used by main.cc to select the next do_* function */ extern int next_dialog; diff --git a/gui/SitePage.cc b/gui/SitePage.cc index 1cdb1bf..9dacebc 100644 --- a/gui/SitePage.cc +++ b/gui/SitePage.cc @@ -367,8 +367,7 @@ int check_dropped_mirrors (HWND h) { if (unattended_mode) return CACHE_ACCEPT_WARN; - return DialogBox (hinstance, MAKEINTRESOURCE (IDD_DROPPED), h, - drop_proc); + return DialogBox (NULL, MAKEINTRESOURCE (IDD_DROPPED), h, drop_proc); } return CACHE_ACCEPT_NOWARN; } diff --git a/install.cc b/install.cc index 628dbd0..001529b 100644 --- a/install.cc +++ b/install.cc @@ -660,7 +660,7 @@ Installer::_installOne (packagemeta &pkgm, dlg_data.processlist = plm.c_str (); dlg_data.iteration = iteration; - rc = DialogBoxParam(hinstance, MAKEINTRESOURCE (IDD_FILE_INUSE), owner, FileInuseDlgProc, (LPARAM)&dlg_data); + rc = DialogBoxParam(NULL, MAKEINTRESOURCE (IDD_FILE_INUSE), owner, FileInuseDlgProc, (LPARAM)&dlg_data); } else { diff --git a/main.cc b/main.cc index 4c391f5..8a68232 100644 --- a/main.cc +++ b/main.cc @@ -86,8 +86,6 @@ extern char **_argv; bool is_new_install = false; std::string SetupIniDir; -HINSTANCE hinstance; - static StringChoiceOption::StringChoices symlink_types({ {"native", SymlinkTypeNative}, {"lnk", SymlinkTypeShortcut}, @@ -176,7 +174,7 @@ main_display () } // Init window class lib - Window::SetAppInstance (hinstance); + Window::SetAppInstance (GetModuleHandle(NULL)); // Create pages Splash.Create (); @@ -221,7 +219,6 @@ int WINAPI WinMain (HINSTANCE h, HINSTANCE hPrevInstance, LPSTR command_line, int cmd_show) { - hinstance = h; // Make sure Windows DLLs only delay-load further DLLs from System32 typedef BOOL (WINAPI *PFNSETDEFAULTDLLDIRECTORIES)(DWORD); diff --git a/msg.cc b/msg.cc index 8e344ff..b53df86 100644 --- a/msg.cc +++ b/msg.cc @@ -23,7 +23,6 @@ #include #include -#include "dialog.h" #include "state.h" #include "String++.h" #include "resource.h" @@ -66,7 +65,7 @@ mbox (HWND owner, const char *buf, const char *name, int type) } char caption[32]; - LoadString (hinstance, IDS_MBOX_CAPTION, caption, sizeof (caption)); + LoadString (GetModuleHandle(NULL), IDS_MBOX_CAPTION, caption, sizeof (caption)); return MessageBox (owner, buf, caption, type); } @@ -76,7 +75,7 @@ mbox (HWND owner, const char *name, int type, int id, va_list args) { char buf[1000], fmt[1000]; - if (LoadString (hinstance, id, fmt, sizeof (fmt)) <= 0) + if (LoadString (GetModuleHandle(NULL), id, fmt, sizeof (fmt)) <= 0) ExitProcess (0); vsnprintf (buf, 1000, fmt, args); diff --git a/netio.cc b/netio.cc index 631532a..d6bfc24 100644 --- a/netio.cc +++ b/netio.cc @@ -185,9 +185,9 @@ auth_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) } static int -auth_common (HINSTANCE h, int id, HWND owner) +auth_common (int id, HWND owner) { - return DialogBox (h, MAKEINTRESOURCE (id), owner, auth_proc); + return DialogBox (NULL, MAKEINTRESOURCE (id), owner, auth_proc); } int @@ -195,7 +195,7 @@ NetIO::get_auth (HWND owner) { user = &net_user; passwd = &net_passwd; - return auth_common (hinstance, IDD_NET_AUTH, owner); + return auth_common (IDD_NET_AUTH, owner); } int @@ -203,7 +203,7 @@ NetIO::get_proxy_auth (HWND owner) { user = &net_proxy_user; passwd = &net_proxy_passwd; - return auth_common (hinstance, IDD_PROXY_AUTH, owner); + return auth_common (IDD_PROXY_AUTH, owner); } int @@ -221,7 +221,7 @@ NetIO::get_ftp_auth (HWND owner) } user = &net_ftp_user; passwd = &net_ftp_passwd; - return auth_common (hinstance, IDD_FTP_AUTH, owner); + return auth_common (IDD_FTP_AUTH, owner); } const char * -- 2.43.0