Skip to content

Commit

Permalink
Stop building and alias winxpgui
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Mar 21, 2024
1 parent e0fda45 commit ab9b32d
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 178 deletions.
1 change: 0 additions & 1 deletion AutoDuck/pywin32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ WIN32_SOURCE = $(WIN32_SOURCE_DIR)/*.cpp \
$(GENDIR)/win32process.d $(GENDIR)/wincerapi.d $(GENDIR)/win32gui.d \
$(GENDIR)/win32inet.d $(GENDIR)/_winxptheme.d \
$(GENDIR)/win32job.d \
winxpgui.d

WIN32COM_SOURCE = \
$(WIN32COM_DIR)\src\*.cpp \
Expand Down
3 changes: 0 additions & 3 deletions AutoDuck/winxpgui.d

This file was deleted.

32 changes: 12 additions & 20 deletions com/win32com/demos/ietoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,26 @@
to catch WM_COMMAND messages.
"""

import array
import struct

# imports section
import sys
import winreg

import commctrl
import pythoncom
import win32com
from win32com import universal
from win32com.axcontrol import axcontrol
from win32com.client import Dispatch, DispatchWithEvents, constants, gencache, getevents
from win32com.shell import shell
from win32com.shell.shellcon import *

try:
# try to get styles (winxp)
import winxpgui as win32gui
except:
# import default module (win2k and lower)
import win32gui

import array
import struct

import commctrl
import win32con
import win32gui
import win32ui
from win32com.axcontrol import axcontrol
from win32com.client import Dispatch, gencache
from win32com.shell import shell
from win32com.shell.shellcon import DBIMF_VARIABLEHEIGHT

# ensure we know the ms internet controls typelib so we have access to IWebBrowser2 later on
win32com.client.gencache.EnsureModule("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1)
gencache.EnsureModule("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1)

#
IDeskBand_methods = ["GetBandInfo"]
Expand Down Expand Up @@ -252,7 +244,7 @@ def SetSite(self, unknown):
# then travel over to a service provider
serviceprovider = cmdtarget.QueryInterface(pythoncom.IID_IServiceProvider)
# finally ask for the internet explorer application, returned as a dispatch object
self.webbrowser = win32com.client.Dispatch(
self.webbrowser = Dispatch(
serviceprovider.QueryService(
"{0002DF05-0000-0000-C000-000000000046}", pythoncom.IID_IDispatch
)
Expand Down Expand Up @@ -326,7 +318,7 @@ def DllRegisterServer():
winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar"
)
subKey = winreg.SetValueEx(
hkey, comclass._reg_clsid_, 0, winreg.REG_BINARY, "\0"
hkey, comclass._reg_clsid_, 0, winreg.REG_BINARY, b"\0"
)
except OSError:
print(
Expand Down
12 changes: 5 additions & 7 deletions com/win32com/server/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ def UnregisterInfoClasses(*classes, **flags):
def ReExecuteElevated(flags):
import tempfile

import win32console
import win32event # we've already checked we are running XP above
import win32process
import winxpgui
from win32com.shell import shellcon
from win32com.shell.shell import ShellExecuteEx

Expand All @@ -560,12 +560,10 @@ def ReExecuteElevated(flags):
# specifying the parent means the dialog is centered over our window,
# which is a good usability clue.
# hwnd is unlikely on the command-line, but flags may come from elsewhere
hwnd = flags.get("hwnd", None)
if hwnd is None:
try:
hwnd = winxpgui.GetConsoleWindow()
except winxpgui.error:
hwnd = 0
try:
hwnd = flags.get("hwnd", win32console.GetConsoleWindow())
except win32console.error:
hwnd = 0
# Redirect output so we give the user some clue what went wrong. This
# also means we need to use COMSPEC. However, the "current directory"
# appears to end up ignored - so we execute things via a temp batch file.
Expand Down
3 changes: 1 addition & 2 deletions com/win32comext/shell/demos/servers/folder_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
import pythoncom
import win32api
import win32con
import win32gui
import winerror
import winxpgui as win32gui # the needs vista, let alone xp!
from win32com.axcontrol import axcontrol # IObjectWithSite
from win32com.propsys import propsys
from win32com.server.exception import COMException
from win32com.server.util import NewEnum as _NewEnum, wrap as _wrap
from win32com.shell import shell, shellcon
from win32com.util import IIDToInterfaceName

GUID = pythoncom.MakeIID

Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ disable_error_code = attr-defined, method-assign, name-defined
exclude = .*((build|adodbapi|Pythonwin/Scintilla|Pythonwin/pywin/idle|[Tt]est|[Dd]emos?)/.*|rasutil.py|setup.py)

; C-modules that will need type-stubs
[mypy-adsi.*,dde,exchange,exchdapi,perfmon,servicemanager,win32api,win32clipboard,win32event,win32evtlog,win32file,win32gui,win32help,win32pdh,win32process,win32ras,win32security,win32service,win32trace,win32ui,win32uiole,win32wnet,wincerapi,winxpgui,_win32sysloader,_winxptheme]
[mypy-adsi.*,dde,exchange,exchdapi,perfmon,servicemanager,win32api,win32console,win32clipboard,win32event,win32evtlog,win32file,win32gui,win32help,win32pdh,win32process,win32ras,win32security,win32service,win32trace,win32ui,win32uiole,win32wnet,wincerapi,_win32sysloader,_winxptheme]
ignore_missing_imports = True

; verstamp is installed from win32verstamp.py called in setup.py
Expand Down
37 changes: 18 additions & 19 deletions pycln.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@
# Many imports with side-effects
all = false
skip_imports = [
# Star imported C wrapped modules
"_winxptheme",
"dde",
"ntsecuritycon",
"odbc",
"win32api",
"win32clipboard",
"win32com",
"win32cryptcon",
"win32event",
"win32file",
"win32gui_struct",
"win32gui",
"win32inet",
"win32inetcon",
"win32pipe",
"win32ras",
"win32ui",
"winxpgui",
# Star imported C wrapped modules
"_winxptheme",
"dde",
"ntsecuritycon",
"odbc",
"win32api",
"win32clipboard",
"win32com",
"win32cryptcon",
"win32event",
"win32file",
"win32gui_struct",
"win32gui",
"win32inet",
"win32inetcon",
"win32pipe",
"win32ras",
"win32ui",
]
51 changes: 2 additions & 49 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
else:
from distutils.dep_util import newer_group

# some modules need a static CRT to avoid problems caused by them having a
# manifest.
static_crt_modules = ["winxpgui"]

build_id_patch = build_id
if not "." in build_id_patch:
build_id_patch = build_id_patch + ".0"
Expand Down Expand Up @@ -404,11 +400,6 @@ def _why_cant_build_extension(self, ext):
if ext.name == "axdebug" and sys.version_info > (3, 10):
return "AXDebug no longer builds on 3.11 and up"

# winxpgui cannot be build for win-arm64 due to manifest file conflicts
# skip extension as we probably don't want this extension for win-arm64 platforms
if self.plat_name == "win-arm64" and ext.name == "winxpgui":
return "winxpgui extension cannot be build for win-arm64"

include_dirs = self.compiler.include_dirs + os.environ.get("INCLUDE", "").split(
os.pathsep
)
Expand Down Expand Up @@ -728,12 +719,6 @@ def build_extension(self, ext):
# with special defines. So we cannot use a shared
# directory for objects, we must use a special one for each extension.
old_build_temp = self.build_temp
want_static_crt = ext.name in static_crt_modules
if want_static_crt:
self.compiler.compile_options.remove("/MD")
self.compiler.compile_options.append("/MT")
self.compiler.compile_options_debug.remove("/MDd")
self.compiler.compile_options_debug.append("/MTd")

try:
build_ext.build_extension(self, ext)
Expand Down Expand Up @@ -769,11 +754,6 @@ def build_extension(self, ext):
self.copy_file(src, dst)
finally:
self.build_temp = old_build_temp
if want_static_crt:
self.compiler.compile_options.remove("/MT")
self.compiler.compile_options.append("/MD")
self.compiler.compile_options_debug.remove("/MTd")
self.compiler.compile_options_debug.append("/MDd")

def get_ext_filename(self, name):
# We need to fixup some target filenames.
Expand Down Expand Up @@ -822,17 +802,6 @@ def swig_sources(self, sources, ext=None):
# Patch up the filenames for various special cases...
if os.path.basename(base) in swig_interface_parents:
swig_targets[source] = base + target_ext
elif (
self.current_extension.name == "winxpgui"
and os.path.basename(base) == "win32gui"
):
# More vile hacks. winxpmodule is built from win32gui.i -
# just different #defines are setup for windows.h.
new_target = os.path.join(
os.path.dirname(base), f"winxpgui_swig{target_ext}"
)
swig_targets[source] = new_target
new_sources.append(new_target)
else:
new_target = f"{base}_swig{target_ext}"
new_sources.append(new_target)
Expand Down Expand Up @@ -1065,9 +1034,6 @@ def spawn(self, cmd):
return
if is_link:
# remove /MANIFESTFILE:... and add MANIFEST:NO
# (but note that for winxpgui, which specifies a manifest via a
# .rc file, this is ignored by the linker - the manifest specified
# in the .rc file is still added)
for i in range(len(cmd)):
if cmd[i].startswith(("/MANIFESTFILE:", "/MANIFEST:EMBED")):
cmd[i] = "/MANIFEST:NO"
Expand Down Expand Up @@ -1328,19 +1294,6 @@ def finalize_options(self):
libraries="gdi32 user32 comdlg32 comctl32 shell32",
define_macros=[("WIN32GUI", None)],
),
# winxpgui is built from win32gui.i, but sets up different #defines before
# including windows.h. It also has an XP style manifest.
WinExt_win32(
"winxpgui",
sources="""
win32/src/winxpgui.rc win32/src/win32dynamicdialog.cpp
win32/src/win32gui.i
""".split(),
libraries="gdi32 user32 comdlg32 comctl32 shell32",
windows_h_version=0x0500,
define_macros=[("WIN32GUI", None), ("WINXPGUI", None)],
extra_swig_commands=["-DWINXPGUI"],
),
# winxptheme
WinExt_win32(
"_winxptheme",
Expand Down Expand Up @@ -2230,7 +2183,7 @@ def convert_optional_data_files(files):
"adodbapi",
]

py_modules = expand_modules("win32\\lib")
py_modules = [*expand_modules("win32\\lib"), "win32\\winxpgui"]
ext_modules = (
win32_extensions + com_extensions + pythonwin_extensions + other_extensions
)
Expand Down Expand Up @@ -2421,7 +2374,7 @@ def maybe_fixup_exes():
# Print the list of extension modules we skipped building.
excluded_extensions = dist.command_obj["build_ext"].excluded_extensions
if excluded_extensions:
skip_whitelist = {"exchdapi", "exchange", "axdebug", "winxpgui"}
skip_whitelist = {"exchdapi", "exchange", "axdebug"}
skipped_ex = []
print("*** NOTE: The following extensions were NOT %s:" % what_string)
for ext, why in excluded_extensions:
Expand Down
21 changes: 4 additions & 17 deletions win32/Demos/win32gui_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@
# * Uses a ListView control.
# * Dynamically resizes content.
# * Uses a second worker thread to fill the list.
# * Demostrates support for windows XP themes.

# If you are on Windows XP, and specify a '--noxp' argument, you will see:
# * alpha-blend issues with icons
# * The buttons are "old" style, rather than based on the XP theme.
# Hence, using:
# import winxpgui as win32gui
# is recommended.
# Please report any problems.
import sys

if "--noxp" in sys.argv:
import win32gui
else:
import winxpgui as win32gui
# * Demonstrates support for windows XP themes.

import array
import os
Expand All @@ -29,6 +15,7 @@
import commctrl
import win32api
import win32con
import win32gui
import win32gui_struct
import winerror

Expand Down Expand Up @@ -261,8 +248,8 @@ def _SetupList(self):
)

# Add an image list - use the builtin shell folder icon - this
# demonstrates the problem with alpha-blending of icons on XP if
# winxpgui is not used in place of win32gui.
# demonstrates that the problem with alpha-blending of icons
# present on XP is not a problem anymore.
il = win32gui.ImageList_Create(
win32api.GetSystemMetrics(win32con.SM_CXSMICON),
win32api.GetSystemMetrics(win32con.SM_CYSMICON),
Expand Down
10 changes: 2 additions & 8 deletions win32/Demos/win32gui_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,14 @@
# * No support for GetMenuItemInfo.

# Based on Andy McKay's demo code.
from win32api import *

# Try and use XP features, so we get alpha-blending etc.
try:
from winxpgui import *
except ImportError:
from win32gui import *

import array
import os
import struct
import sys

import win32con
from win32api import *
from win32gui import *
from win32gui_struct import *

this_dir = os.path.split(sys.argv[0])[0]
Expand Down
1 change: 0 additions & 1 deletion win32/src/_winxptheme.i
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
%{
#define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon
#define _WIN32_WINNT 0x0501
//#define ISOLATION_AWARE_ENABLED 1

#undef PyHANDLE
#include "pywinobjects.h"
Expand Down
Loading

0 comments on commit ab9b32d

Please sign in to comment.