summaryrefslogtreecommitdiff
path: root/alf/alf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alf.cpp')
-rw-r--r--alf/alf.cpp51
1 files changed, 13 insertions, 38 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index 40b4156..64b4cc4 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -55,7 +55,7 @@ ALF_ApplyFontsPriv(HWND win, ALFWindowPriv *priv)
void
ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv)
{
- priv->fonts.dpi = priv->app->compatFn->GetDpiForWindow(win);
+ priv->fonts.dpi = ALF_Compat_GetDpiForWindow(win);
if (LOBYTE(LOWORD(GetVersion())) < 4) {
// NT 3.x uses System font for everything, we copy that
@@ -68,7 +68,7 @@ ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv)
ZeroMemory(&ncm, sizeof(ncm));
ncm.cbSize = ALF_SizeOf_NONCLIENTMETRICS();
- if (priv->app->compatFn->SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0, priv->fonts.dpi)) {
+ if (ALF_Compat_SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0, priv->fonts.dpi)) {
priv->fonts.lfMessageFont = ncm.lfMessageFont;
} else {
// FIXME! fallback to default font, 8pt MS Shell Dlg
@@ -202,7 +202,7 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
tmp.right = priv->layout.totalMinWidth;
tmp.bottom = priv->layout.totalMinHeight;
- if (priv->app->compatFn->AdjustWindowRectExForDpi(
+ if (ALF_Compat_AdjustWindowRectExForDpi(
&tmp,
GetWindowLong(hwnd, GWL_STYLE),
GetMenu(hwnd) != NULL,
@@ -341,7 +341,6 @@ ALF_CreateApplication(HINSTANCE hInstance)
InitCommonControls();
- app->compatFn = ALF_CreateCompatFuncTable();
ALF_RegisterComboClass(app);
ALF_RegisterPanelClass(app);
@@ -353,43 +352,20 @@ ALF_TeardownApplication(ALFAPP app)
{
UnregisterClass(app->comboClass, app->hInstance);
UnregisterClass(app->panelClass, app->hInstance);
- HeapFree(GetProcessHeap(), 0, app->compatFn);
HeapFree(GetProcessHeap(), 0, app);
}
-static void
-ALF_IntToHex(TCHAR *buf, unsigned long num, int chars)
-{
- char letters[] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- for (int i = 0; i < chars; ++i) {
- buf[chars-i-1] = letters[(num >> (i*4)) & 0xf];
- }
-}
-
-static void
-ALF_UuidToString(const GUID *guid, TCHAR *buf)
-{
- ALF_IntToHex(buf, guid->Data1, 8);
- buf[8] = '-';
- ALF_IntToHex(buf + 9, guid->Data2, 4);
- buf[13] = '-';
- ALF_IntToHex(buf + 14, guid->Data3, 4);
- buf[18] = '-';
- for (int i = 0; i < 8; ++i) {
- ALF_IntToHex(buf + 19 + 2*i, guid->Data4[i], 2);
- }
- buf[35] = 0;
-}
-
void
-ALF_BuildRandomClassName(ALFAPP app, const TCHAR* prefix, TCHAR* buf)
+ALF_BuildRandomClassName(const TCHAR* prefix, TCHAR* buf, DWORD cchBuf)
{
- UUID uuid;
- app->compatFn->UuidCreate(&uuid);
+ LONG_PTR c1, c2;
+ ALF_UniqueCounterValue(&c1, &c2);
+
+ DWORD_PTR params[] = { (DWORD_PTR)prefix, (DWORD_PTR)c1, (DWORD_PTR)c2 };
- lstrcpy(buf, prefix);
- ALF_UuidToString(&uuid, &buf[lstrlen(buf)]);
+ FormatMessage(FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING,
+ TEXT("%1.%2!d!.%3!d!"), 0, 0,
+ buf, cchBuf, (va_list*)params);
}
LPTSTR
@@ -404,7 +380,7 @@ ALF_RegisterWindowClass(ALFAPP app, const ALFWindowClassParams *params)
ZeroMemory(classNameBuf, sizeof(classNameBuf));
classNamePtr = classNameBuf;
- ALF_BuildRandomClassName(app, TEXT("ALFWindow."), classNameBuf);
+ ALF_BuildRandomClassName(TEXT("ALFWindow"), classNameBuf, 256);
}
cls.style = params->classStyle;
@@ -419,7 +395,7 @@ ALF_RegisterWindowClass(ALFAPP app, const ALFWindowClassParams *params)
cls.lpszClassName = classNamePtr;
cls.cbWndExtra = sizeof(void*);
cls.cbClsExtra = sizeof(void*)*2;
- cls.lpfnWndProc = DefWindowProc;
+ cls.lpfnWndProc = ALF_WindowProc;
ATOM classatom = RegisterClass(&cls);
if (!classatom)
@@ -432,7 +408,6 @@ ALF_RegisterWindowClass(ALFAPP app, const ALFWindowClassParams *params)
HWND tmp = CreateWindowEx(0, MAKEINTATOM(classatom), TEXT("dummy"), 0, 0, 0, 0, 0, NULL, 0, app->hInstance, 0);
SetClassLongPtr(tmp, 0, (LONG_PTR)pvtbl);
SetClassLongPtr(tmp, sizeof(void*), (LONG_PTR)app);
- SetClassLongPtr(tmp, GCLP_WNDPROC, (LONG_PTR)ALF_WindowProc);
DestroyWindow(tmp);
return MAKEINTATOM(classatom);