Skip to content

Commit

Permalink
fix: apply dll load macro to win32gui
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiFati committed Jun 24, 2024
1 parent c32cf79 commit a1cbfc3
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions win32/src/win32gui.i
Original file line number Diff line number Diff line change
Expand Up @@ -266,42 +266,33 @@ for (PyMethodDef *pmd = win32guiMethods; pmd->ml_name; pmd++)
)
pmd->ml_flags = METH_VARARGS | METH_KEYWORDS;

HMODULE hmodule=GetModuleHandle(TEXT("user32.dll"));
if (hmodule==NULL)
hmodule=LoadLibrary(TEXT("user32.dll"));
if (hmodule){
pfnSetLayeredWindowAttributes=(SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes");
pfnGetLayeredWindowAttributes=(GetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"GetLayeredWindowAttributes");
pfnUpdateLayeredWindow=(UpdateLayeredWindowfunc)GetProcAddress(hmodule,"UpdateLayeredWindow");
pfnAnimateWindow=(AnimateWindowfunc)GetProcAddress(hmodule,"AnimateWindow");
pfnGetMenuInfo=(GetMenuInfofunc)GetProcAddress(hmodule,"GetMenuInfo");
pfnSetMenuInfo=(SetMenuInfofunc)GetProcAddress(hmodule,"SetMenuInfo");
pfnDrawTextW=(DrawTextWfunc)GetProcAddress(hmodule, "DrawTextW");
}

hmodule=GetModuleHandle(TEXT("gdi32.dll"));
if (hmodule==NULL)
hmodule=LoadLibrary(TEXT("gdi32.dll"));
if (hmodule){
pfnAngleArc=(AngleArcfunc)GetProcAddress(hmodule,"AngleArc");
pfnPlgBlt=(PlgBltfunc)GetProcAddress(hmodule,"PlgBlt");
pfnGetWorldTransform=(GetWorldTransformfunc)GetProcAddress(hmodule,"GetWorldTransform");
pfnSetWorldTransform=(SetWorldTransformfunc)GetProcAddress(hmodule,"SetWorldTransform");
pfnModifyWorldTransform=(ModifyWorldTransformfunc)GetProcAddress(hmodule,"ModifyWorldTransform");
pfnCombineTransform=(CombineTransformfunc)GetProcAddress(hmodule,"CombineTransform");
pfnMaskBlt=(MaskBltfunc)GetProcAddress(hmodule,"MaskBlt");
pfnGetLayout=(GetLayoutfunc)GetProcAddress(hmodule,"GetLayout");
pfnSetLayout=(SetLayoutfunc)GetProcAddress(hmodule,"SetLayout");
}

hmodule=GetModuleHandle(TEXT("msimg32.dll"));
if (hmodule==NULL)
hmodule=LoadLibrary(TEXT("msimg32.dll"));
if (hmodule){
pfnGradientFill=(GradientFillfunc)GetProcAddress(hmodule,"GradientFill");
pfnTransparentBlt=(TransparentBltfunc)GetProcAddress(hmodule,"TransparentBlt");
pfnAlphaBlend=(AlphaBlendfunc)GetProcAddress(hmodule,"AlphaBlend");
}
PYWIN_BEGIN_LOAD_LIBRARY("user32.dll")
pfnSetLayeredWindowAttributes = (SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes");
pfnGetLayeredWindowAttributes = (GetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"GetLayeredWindowAttributes");
pfnUpdateLayeredWindow = (UpdateLayeredWindowfunc)GetProcAddress(hmodule,"UpdateLayeredWindow");
pfnAnimateWindow = (AnimateWindowfunc)GetProcAddress(hmodule,"AnimateWindow");
pfnGetMenuInfo = (GetMenuInfofunc)GetProcAddress(hmodule,"GetMenuInfo");
pfnSetMenuInfo = (SetMenuInfofunc)GetProcAddress(hmodule,"SetMenuInfo");
pfnDrawTextW = (DrawTextWfunc)GetProcAddress(hmodule, "DrawTextW");
PYWIN_END_LOAD_LIBRARY

PYWIN_BEGIN_LOAD_LIBRARY("gdi32.dll")
pfnAngleArc = (AngleArcfunc)GetProcAddress(hmodule,"AngleArc");
pfnPlgBlt = (PlgBltfunc)GetProcAddress(hmodule,"PlgBlt");
pfnGetWorldTransform = (GetWorldTransformfunc)GetProcAddress(hmodule,"GetWorldTransform");
pfnSetWorldTransform = (SetWorldTransformfunc)GetProcAddress(hmodule,"SetWorldTransform");
pfnModifyWorldTransform = (ModifyWorldTransformfunc)GetProcAddress(hmodule,"ModifyWorldTransform");
pfnCombineTransform = (CombineTransformfunc)GetProcAddress(hmodule,"CombineTransform");
pfnMaskBlt = (MaskBltfunc)GetProcAddress(hmodule,"MaskBlt");
pfnGetLayout = (GetLayoutfunc)GetProcAddress(hmodule,"GetLayout");
pfnSetLayout = (SetLayoutfunc)GetProcAddress(hmodule,"SetLayout");
PYWIN_END_LOAD_LIBRARY

PYWIN_BEGIN_LOAD_LIBRARY("msimg32.dll")
pfnGradientFill = (GradientFillfunc)GetProcAddress(hmodule,"GradientFill");
pfnTransparentBlt = (TransparentBltfunc)GetProcAddress(hmodule,"TransparentBlt");
pfnAlphaBlend = (AlphaBlendfunc)GetProcAddress(hmodule,"AlphaBlend");
PYWIN_END_LOAD_LIBRARY
%}

%{
Expand Down

0 comments on commit a1cbfc3

Please sign in to comment.