[User32Test]
[reactos.git] / rostests / winetests / user32 / msg.c
index fa57426..a0c610b 100755 (executable)
 #define WM_LBTRACKPOINT  0x0131
 #endif
 
+#ifdef __i386__
+#define ARCH "x86"
+#elif defined __x86_64__
+#define ARCH "amd64"
+#else
+#define ARCH "none"
+#endif
+
+static BOOL   (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
+static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
+static BOOL   (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
+static BOOL   (WINAPI *pGetCurrentActCtx)(HANDLE *);
+static void   (WINAPI *pReleaseActCtx)(HANDLE);
+
 /* encoded DRAWITEMSTRUCT into an LPARAM */
 typedef struct
 {
@@ -1705,11 +1719,11 @@ static const struct message WmSHOWNATopInvisible[] = {
     { 0 }
 };
 
-static int after_end_dialog, test_def_id;
+static BOOL after_end_dialog, test_def_id, paint_loop_done;
 static int sequence_cnt, sequence_size;
 static struct recvd_message* sequence;
 static int log_all_parent_messages;
-static int paint_loop_done;
+static CRITICAL_SECTION sequence_cs;
 
 /* user32 functions */
 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
@@ -1721,6 +1735,9 @@ static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
 static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
+static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
+static UINT_PTR (WINAPI *pSetSystemTimer)(HWND, UINT_PTR, UINT, TIMERPROC);
+static UINT_PTR (WINAPI *pKillSystemTimer)(HWND, UINT_PTR);
 /* kernel32 functions */
 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
 
@@ -1744,6 +1761,9 @@ static void init_procs(void)
     GET_PROC(user32, UnhookWinEvent)
     GET_PROC(user32, GetMonitorInfoA)
     GET_PROC(user32, MonitorFromPoint)
+    GET_PROC(user32, UpdateLayeredWindow)
+    GET_PROC(user32, SetSystemTimer)
+    GET_PROC(user32, KillSystemTimer)
 
     GET_PROC(kernel32, GetCPInfoExA)
 
@@ -1794,7 +1814,8 @@ static void add_message_(int line, const struct recvd_message *msg)
 {
     struct recvd_message *seq;
 
-    if (!sequence) 
+    EnterCriticalSection( &sequence_cs );
+    if (!sequence)
     {
        sequence_size = 10;
        sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
@@ -1806,7 +1827,7 @@ static void add_message_(int line, const struct recvd_message *msg)
     }
     assert(sequence);
 
-    seq = &sequence[sequence_cnt];
+    seq = &sequence[sequence_cnt++];
     seq->hwnd = msg->hwnd;
     seq->message = msg->message;
     seq->flags = msg->flags;
@@ -1815,6 +1836,7 @@ static void add_message_(int line, const struct recvd_message *msg)
     seq->line   = line;
     seq->descr  = msg->descr;
     seq->output[0] = 0;
+    LeaveCriticalSection( &sequence_cs );
 
     if (msg->descr)
     {
@@ -1899,8 +1921,6 @@ static void add_message_(int line, const struct recvd_message *msg)
                 sprintf( seq->output + strlen(seq->output), " (flags %x)", msg->flags );
         }
     }
-
-    sequence_cnt++;
 }
 
 /* try to make sure pending X events have been processed before continuing */
@@ -1914,16 +1934,18 @@ static void flush_events(void)
     while (diff > 0)
     {
         if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
         diff = time - GetTickCount();
     }
 }
 
 static void flush_sequence(void)
 {
+    EnterCriticalSection( &sequence_cs );
     HeapFree(GetProcessHeap(), 0, sequence);
     sequence = 0;
     sequence_cnt = sequence_size = 0;
+    LeaveCriticalSection( &sequence_cs );
 }
 
 static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
@@ -2010,7 +2032,7 @@ static void dump_sequence(const struct message *expected, const char *context, c
         ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
 
 
-static void ok_sequence_(const struct message *expected_list, const char *context, int todo,
+static void ok_sequence_(const struct message *expected_list, const char *context, BOOL todo,
                          const char *file, int line)
 {
     static const struct recvd_message end_of_sequence;
@@ -3352,7 +3374,7 @@ static BOOL mdi_RegisterWindowClasses(void)
     cls.cbWndExtra = 0;
     cls.hInstance = GetModuleHandleA(0);
     cls.hIcon = 0;
-    cls.hCursor = LoadCursorA(0, IDC_ARROW);
+    cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
     cls.lpszMenuName = NULL;
     cls.lpszClassName = "MDI_frame_class";
@@ -3872,7 +3894,7 @@ static void test_mdi_messages(void)
 
     /* test maximization of MDI child with invisible parent */
     client_cs.hWindowMenu = 0;
-    mdi_client = CreateWindow("MDI_client_class",
+    mdi_client = CreateWindowA("MDI_client_class",
                                  NULL,
                                  WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
                                  0, 0, 660, 430,
@@ -3888,11 +3910,11 @@ static void test_mdi_messages(void)
                                 mdi_client, 0, GetModuleHandleA(0), NULL);
     ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
 
-    SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
+    SendMessageA(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
     ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
     zoomed = IsZoomed(mdi_child);
     ok(zoomed, "wrong zoomed state %d\n", zoomed);
-    
+
     ShowWindow(mdi_client, SW_SHOW);
     ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
 
@@ -4742,17 +4764,17 @@ static void test_messages(void)
 
     flush_sequence();
 
-    test_def_id = 1;
-    SendMessage(hwnd, WM_NULL, 0, 0);
+    test_def_id = TRUE;
+    SendMessageA(hwnd, WM_NULL, 0, 0);
 
     flush_sequence();
-    after_end_dialog = 1;
+    after_end_dialog = TRUE;
     EndDialog( hwnd, 0 );
     ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
 
     DestroyWindow(hwnd);
-    after_end_dialog = 0;
-    test_def_id = 0;
+    after_end_dialog = FALSE;
+    test_def_id = FALSE;
 
     hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
                            0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
@@ -4856,13 +4878,13 @@ static void test_messages(void)
     UpdateWindow(hwnd);
     flush_events();
     flush_sequence();
-    SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
+    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconA(0, (LPCSTR)IDI_APPLICATION));
     ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
 
     ShowWindow(hwnd, SW_HIDE);
     flush_events();
     flush_sequence();
-    SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
+    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconA(0, (LPCSTR)IDI_APPLICATION));
     ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
     DestroyWindow(hwnd);
     flush_sequence();
@@ -4874,17 +4896,17 @@ static void test_messages(void)
     UpdateWindow(hwnd);
     flush_events();
     flush_sequence();
-    SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
+    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconA(0, (LPCSTR)IDI_APPLICATION));
     ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
 
     ShowWindow(hwnd, SW_HIDE);
     flush_events();
     flush_sequence();
-    SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
+    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconA(0, (LPCSTR)IDI_APPLICATION));
     ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
 
     flush_sequence();
-    res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x8000000b, 0);
     if (!res)
     {
         todo_wine win_skip( "Message 0x3b not supported\n" );
@@ -4892,26 +4914,26 @@ static void test_messages(void)
     }
     ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
     ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
-    res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x0000000b, 0);
     ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
     ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
-    res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x0000000f, 0);
     ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
     ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
 
     flush_sequence();
-    res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x80000008, 0);
     ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
     ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
-    res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x00000008, 0);
     ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
     ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
 
-    res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x80000004, 0);
     ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
     ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
 
-    res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
+    res = SendMessageA(hwnd, 0x3B, 0x80000001, 0);
     ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
     ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
 
@@ -5379,10 +5401,10 @@ static void subclass_button(void)
 
     old_button_proc = cls.lpfnWndProc;
 
-    cls.hInstance = GetModuleHandle(0);
+    cls.hInstance = GetModuleHandleA(NULL);
     cls.lpfnWndProc = button_hook_proc;
     cls.lpszClassName = "my_button_class";
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
     if (!RegisterClassA(&cls)) assert(0);
 }
 
@@ -5488,20 +5510,20 @@ static void test_button_messages(void)
 
         ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
        SetFocus(hwnd);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
        ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
 
        SetFocus(0);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
        ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
 
         ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
 
-        SendMessage(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
         ok_sequence(button[i].setstyle, "BM_SETSTYLE on a button", FALSE);
 
         style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -5509,17 +5531,17 @@ static void test_button_messages(void)
         /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
         ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
 
-        state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
+        state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
         ok(state == 0, "expected state 0, got %04x\n", state);
 
         flush_sequence();
 
-        SendMessage(hwnd, BM_SETSTATE, TRUE, 0);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, BM_SETSTATE, TRUE, 0);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
         ok_sequence(button[i].setstate, "BM_SETSTATE/TRUE on a button", FALSE);
 
-        state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
+        state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
         ok(state == 0x0004, "expected state 0x0004, got %04x\n", state);
 
         style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -5528,29 +5550,29 @@ static void test_button_messages(void)
 
         flush_sequence();
 
-        SendMessage(hwnd, BM_SETSTATE, FALSE, 0);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, BM_SETSTATE, FALSE, 0);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
         ok_sequence(button[i].clearstate, "BM_SETSTATE/FALSE on a button", FALSE);
 
-        state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
+        state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
         ok(state == 0, "expected state 0, got %04x\n", state);
 
         style = GetWindowLongA(hwnd, GWL_STYLE);
         style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
         ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
 
-        state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
+        state = SendMessageA(hwnd, BM_GETCHECK, 0, 0);
         ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state);
 
         flush_sequence();
 
-        SendMessage(hwnd, BM_SETCHECK, BST_UNCHECKED, 0);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, BM_SETCHECK, BST_UNCHECKED, 0);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
         ok_sequence(WmSetCheckIgnoredSeq, "BM_SETCHECK on a button", FALSE);
 
-        state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
+        state = SendMessageA(hwnd, BM_GETCHECK, 0, 0);
         ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state);
 
         style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -5559,12 +5581,12 @@ static void test_button_messages(void)
 
         flush_sequence();
 
-        SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0);
-        SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        SendMessageA(hwnd, BM_SETCHECK, BST_CHECKED, 0);
+        SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
         ok_sequence(button[i].setcheck, "BM_SETCHECK on a button", FALSE);
 
-        state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
+        state = SendMessageA(hwnd, BM_GETCHECK, 0, 0);
         if (button[i].style == BS_PUSHBUTTON ||
             button[i].style == BS_DEFPUSHBUTTON ||
             button[i].style == BS_GROUPBOX ||
@@ -5659,10 +5681,10 @@ static void subclass_static(void)
 
     old_static_proc = cls.lpfnWndProc;
 
-    cls.hInstance = GetModuleHandle(0);
+    cls.hInstance = GetModuleHandleA(NULL);
     cls.lpfnWndProc = static_hook_proc;
     cls.lpszClassName = "my_static_class";
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
     if (!RegisterClassA(&cls)) assert(0);
 }
 
@@ -5699,7 +5721,7 @@ static void test_static_messages(void)
        flush_sequence();
 
        trace("static style %08x\n", static_ctrl[i].style);
-       SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
+       SendMessageA(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
        ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
 
        DestroyWindow(hwnd);
@@ -5720,6 +5742,21 @@ static const struct message WmKeyDownComboSeq[] =
     { 0 }
 };
 
+static const struct message WmSetPosComboSeq[] =
+{
+    { WM_WINDOWPOSCHANGING, sent },
+    { WM_NCCALCSIZE, sent|wparam, TRUE },
+    { WM_CHILDACTIVATE, sent },
+    { WM_WINDOWPOSCHANGED, sent },
+    { WM_MOVE, sent|defwinproc },
+    { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
+    { WM_WINDOWPOSCHANGING, sent|defwinproc },
+    { WM_NCCALCSIZE, sent|defwinproc|wparam, TRUE },
+    { WM_WINDOWPOSCHANGED, sent|defwinproc },
+    { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
+    { 0 }
+};
+
 static WNDPROC old_combobox_proc;
 
 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -5762,10 +5799,10 @@ static void subclass_combobox(void)
 
     old_combobox_proc = cls.lpfnWndProc;
 
-    cls.hInstance = GetModuleHandle(0);
+    cls.hInstance = GetModuleHandleA(NULL);
     cls.lpfnWndProc = combobox_hook_proc;
     cls.lpszClassName = "my_combobox_class";
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
     if (!RegisterClassA(&cls)) assert(0);
 }
 
@@ -5781,32 +5818,36 @@ static void test_combobox_messages(void)
     ok(parent != 0, "Failed to create parent window\n");
     flush_sequence();
 
-    combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
+    combo = CreateWindowExA(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
                            0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
     ok(combo != 0, "Failed to create combobox window\n");
 
     UpdateWindow(combo);
 
-    ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
+    ret = SendMessageA(combo, WM_GETDLGCODE, 0, 0);
     ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
 
-    ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
+    ret = SendMessageA(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
     ok(ret == 0, "expected 0, got %ld\n", ret);
-    ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
+    ret = SendMessageA(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
     ok(ret == 1, "expected 1, got %ld\n", ret);
-    ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
+    ret = SendMessageA(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
     ok(ret == 2, "expected 2, got %ld\n", ret);
 
-    SendMessage(combo, CB_SETCURSEL, 0, 0);
+    SendMessageA(combo, CB_SETCURSEL, 0, 0);
     SetFocus(combo);
     flush_sequence();
 
     log_all_parent_messages++;
-    SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
-    SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
+    SendMessageA(combo, WM_KEYDOWN, VK_DOWN, 0);
+    SendMessageA(combo, WM_KEYUP, VK_DOWN, 0);
     log_all_parent_messages--;
     ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
 
+    flush_sequence();
+    SetWindowPos(combo, 0, 10, 10, 120, 130, SWP_NOZORDER);
+    ok_sequence(WmSetPosComboSeq, "repositioning messages on a ComboBox", FALSE);
+
     DestroyWindow(combo);
     DestroyWindow(parent);
 }
@@ -5867,14 +5908,14 @@ static void test_wmime_keydown_message(void)
     flush_events();
     flush_sequence();
 
-    SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
-    SendMessage(hwnd, WM_CHAR, 'A', 1);
+    SendMessageA(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
+    SendMessageA(hwnd, WM_CHAR, 'A', 1);
     ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
 
-    while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
+    while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) )
     {
         TranslateMessage(&msg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
 
@@ -6277,7 +6318,7 @@ static void test_paint_messages(void)
     flush_sequence();
     SetRectRgn( hrgn, -4, -4, -1, -1 );
     RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
-    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
     {
         if (msg.hwnd == hwnd && msg.message == WM_PAINT)
         {
@@ -6290,7 +6331,7 @@ static void test_paint_messages(void)
             ret = GetUpdateRect( hwnd, &rect, TRUE );
             ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
         }
-        DispatchMessage( &msg );
+        DispatchMessageA( &msg );
     }
     ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
 
@@ -6343,7 +6384,7 @@ static void test_paint_messages(void)
     RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
     ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
 
-    SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
+    SetWindowLongA( hparent, GWL_STYLE, GetWindowLongA(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
     flush_sequence();
     RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
     RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
@@ -6364,7 +6405,7 @@ static void test_paint_messages(void)
 
     /* flush all paint messages */
     flush_events();
-    SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
+    SetWindowLongA( hparent, GWL_STYLE, GetWindowLongA(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
     flush_sequence();
 
     /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
@@ -6407,26 +6448,26 @@ static void test_paint_messages(void)
     SetRectRgn( hrgn, 20, 20, 30, 30 );
     check_update_rgn( hparent, hrgn );
     /* no WM_PAINT in child while parent still pending */
-    while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
-    while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
 
     flush_sequence();
     RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
     /* no WM_PAINT in child while parent still pending */
-    while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
     RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
     /* now that parent is valid child should get WM_PAINT */
-    while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
-    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmEmptySeq, "No other message", FALSE );
 
     /* same thing with WS_CLIPCHILDREN in parent */
     flush_sequence();
-    SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
+    SetWindowLongA( hparent, GWL_STYLE, GetWindowLongA(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
     ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
     /* changing style invalidates non client area, but we need to invalidate something else to see it */
     RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
@@ -6439,10 +6480,10 @@ static void test_paint_messages(void)
     SetRectRgn( hrgn, 20, 20, 30, 30 );
     check_update_rgn( hparent, hrgn );
     /* no WM_PAINT in child while parent still pending */
-    while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
     /* WM_PAINT in parent first */
-    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
     ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
 
     /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
@@ -6489,7 +6530,7 @@ static void test_paint_messages(void)
     flush_events();
     ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
 
-    assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
+    assert( GetWindowLongA(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
     UpdateWindow( hparent );
     flush_events();
     flush_sequence();
@@ -6510,13 +6551,13 @@ static void test_paint_messages(void)
     flush_events();
     ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
 
-    SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
+    SetWindowLongA( hparent, GWL_STYLE, GetWindowLongA(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
     ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
     RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
     flush_events();
     ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
 
-    assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
+    assert( !(GetWindowLongA(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
     UpdateWindow( hparent );
     flush_events();
     flush_sequence();
@@ -6537,8 +6578,8 @@ static void test_paint_messages(void)
     flush_events();
     ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
 
-    ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
-    ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
+    ok(GetWindowLongA( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
+    ok(GetWindowLongA( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
 
     UpdateWindow( hparent );
     flush_events();
@@ -6644,10 +6685,10 @@ static DWORD WINAPI thread_proc(void *param)
 
     SetEvent(wnd_event->start_event);
 
-    while (GetMessage(&msg, 0, 0, 0))
+    while (GetMessageA(&msg, 0, 0, 0))
     {
        TranslateMessage(&msg);
-       DispatchMessage(&msg);
+       DispatchMessageA(&msg);
     }
 
     ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
@@ -6672,7 +6713,7 @@ static DWORD CALLBACK create_grand_child_thread( void *param )
     {
         MsgWaitForMultipleObjects(0, NULL, FALSE, 1000, QS_ALLINPUT);
         if (!IsWindow( hchild )) break;  /* will be destroyed when parent thread exits */
-        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     }
     return 0;
 }
@@ -6696,16 +6737,73 @@ static DWORD CALLBACK create_child_thread( void *param )
     {
         DWORD ret = MsgWaitForMultipleObjects(1, &child_event.start_event, FALSE, 1000, QS_SENDMESSAGE);
         if (ret != 1) break;
-        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     }
     ret = WaitForSingleObject( wnd_event->stop_event, 5000 );
     ok( !ret, "WaitForSingleObject failed %x\n", ret );
     return 0;
 }
 
+static const char manifest_dep[] =
+"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
+"<assemblyIdentity version=\"1.2.3.4\"  name=\"testdep1\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
+"    <file name=\"testdep.dll\" />"
+"</assembly>";
+
+static const char manifest_main[] =
+"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
+"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
+"<dependency>"
+" <dependentAssembly>"
+"  <assemblyIdentity type=\"win32\" name=\"testdep1\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
+" </dependentAssembly>"
+"</dependency>"
+"</assembly>";
+
+static void create_manifest_file(const char *filename, const char *manifest)
+{
+    WCHAR path[MAX_PATH];
+    HANDLE file;
+    DWORD size;
+
+    MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
+    file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    WriteFile(file, manifest, strlen(manifest), &size, NULL);
+    CloseHandle(file);
+}
+
+static HANDLE test_create(const char *file)
+{
+    WCHAR path[MAX_PATH];
+    ACTCTXW actctx;
+    HANDLE handle;
+
+    MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH);
+    memset(&actctx, 0, sizeof(ACTCTXW));
+    actctx.cbSize = sizeof(ACTCTXW);
+    actctx.lpSource = path;
+
+    handle = pCreateActCtxW(&actctx);
+    ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %u\n", GetLastError());
+
+    ok(actctx.cbSize == sizeof(actctx), "cbSize=%d\n", actctx.cbSize);
+    ok(actctx.dwFlags == 0, "dwFlags=%d\n", actctx.dwFlags);
+    ok(actctx.lpSource == path, "lpSource=%p\n", actctx.lpSource);
+    ok(actctx.wProcessorArchitecture == 0, "wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
+    ok(actctx.wLangId == 0, "wLangId=%d\n", actctx.wLangId);
+    ok(actctx.lpAssemblyDirectory == NULL, "lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
+    ok(actctx.lpResourceName == NULL, "lpResourceName=%p\n", actctx.lpResourceName);
+    ok(actctx.lpApplicationName == NULL, "lpApplicationName=%p\n", actctx.lpApplicationName);
+    ok(actctx.hModule == NULL, "hModule=%p\n", actctx.hModule);
+
+    return handle;
+}
+
 static void test_interthread_messages(void)
 {
-    HANDLE hThread;
+    HANDLE hThread, context, handle, event;
+    ULONG_PTR cookie;
     DWORD tid;
     WNDPROC proc;
     MSG msg;
@@ -6774,6 +6872,7 @@ static void test_interthread_messages(void)
     wnd_event.hwnd = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                               100, 100, 200, 200, 0, 0, 0, NULL);
     ok (wnd_event.hwnd != 0, "Failed to create parent window\n");
+    flush_events();
     flush_sequence();
     log_all_parent_messages++;
     wnd_event.start_event = CreateEventA( NULL, TRUE, FALSE, NULL );
@@ -6783,7 +6882,7 @@ static void test_interthread_messages(void)
     {
         ret = MsgWaitForMultipleObjects(1, &wnd_event.start_event, FALSE, 1000, QS_SENDMESSAGE);
         if (ret != 1) break;
-        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     }
     ok( !ret, "MsgWaitForMultipleObjects failed %x\n", ret );
     /* now wait for the thread without processing messages; this shouldn't deadlock */
@@ -6802,6 +6901,60 @@ static void test_interthread_messages(void)
     ok_sequence(WmExitThreadSeq, "destroy child on thread exit", FALSE);
     log_all_parent_messages--;
     DestroyWindow( wnd_event.hwnd );
+
+    /* activation context tests */
+    if (!pActivateActCtx)
+    {
+        win_skip("Activation contexts are not supported, skipping\n");
+        return;
+    }
+
+    create_manifest_file("testdep1.manifest", manifest_dep);
+    create_manifest_file("main.manifest", manifest_main);
+
+    context = test_create("main.manifest");
+    DeleteFileA("testdep1.manifest");
+    DeleteFileA("main.manifest");
+
+    handle = (void*)0xdeadbeef;
+    ret = pGetCurrentActCtx(&handle);
+    ok(ret, "GetCurentActCtx failed: %u\n", GetLastError());
+    ok(handle == 0, "active context %p\n", handle);
+
+    wnd_event.start_event = CreateEventW(NULL, 0, 0, NULL);
+    hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
+    ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
+    ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(wnd_event.start_event);
+
+    /* context is activated after thread creation, so it doesn't inherit it by default */
+    ret = pActivateActCtx(context, &cookie);
+    ok(ret, "activation failed: %u\n", GetLastError());
+
+    handle = 0;
+    ret = pGetCurrentActCtx(&handle);
+    ok(ret, "GetCurentActCtx failed: %u\n", GetLastError());
+    ok(handle != 0, "active context %p\n", handle);
+
+    /* destination window will test for active context */
+    ret = SendMessageA(wnd_event.hwnd, WM_USER+10, 0, 0);
+    ok(ret, "thread window returned %d\n", ret);
+
+    event = CreateEventW(NULL, 0, 0, NULL);
+    ret = PostMessageA(wnd_event.hwnd, WM_USER+10, 0, (LPARAM)event);
+    ok(ret, "thread window returned %d\n", ret);
+    ok(WaitForSingleObject(event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(event);
+
+    ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
+    ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
+
+    ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    CloseHandle(hThread);
+
+    ret = pDeactivateActCtx(0, cookie);
+    ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+    pReleaseActCtx(context);
 }
 
 
@@ -7130,10 +7283,10 @@ static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
         log_msg.descr = "accel";
         add_message(&log_msg);
 
-        if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
+        if (!hAccel || !TranslateAcceleratorA(hwnd, hAccel, &msg))
         {
             TranslateMessage(&msg);
-            DispatchMessage(&msg);
+            DispatchMessageA(&msg);
         }
     }
 }
@@ -7161,7 +7314,7 @@ static void test_accelerators(void)
     state = GetKeyState(VK_CAPITAL);
     ok(state == 0, "wrong CapsLock state %04x\n", state);
 
-    hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
+    hAccel = LoadAcceleratorsA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1));
     assert(hAccel != 0);
 
     flush_events();
@@ -7221,7 +7374,7 @@ static void test_accelerators(void)
     ret = DestroyAcceleratorTable(hAccel);
     ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
 
-    hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
+    hAccel = LoadAcceleratorsA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(2));
     assert(hAccel != 0);
 
     trace("testing VK_N press/release\n");
@@ -7437,6 +7590,19 @@ static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
        case WM_NCHITTEST:
            return HTCLIENT;
 
+       case WM_USER+10:
+       {
+           HANDLE handle, event = (HANDLE)lParam;
+           BOOL ret;
+
+           handle = (void*)0xdeadbeef;
+           ret = pGetCurrentActCtx(&handle);
+           ok(ret, "failed to get current context, %u\n", GetLastError());
+           ok(handle == 0, "got active context %p\n", handle);
+           if (event) SetEvent(event);
+           return 1;
+       }
+
        /* ignore */
        case WM_MOUSEMOVE:
        case WM_MOUSEACTIVATE:
@@ -7611,13 +7777,13 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam
 static INT_PTR CALLBACK StopQuitMsgCheckProcA(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 {
     if (message == WM_CREATE)
-        PostMessage(hwnd, WM_CLOSE, 0, 0);
+        PostMessageA(hwnd, WM_CLOSE, 0, 0);
     else if (message == WM_CLOSE)
     {
         /* Only the first WM_QUIT will survive the window destruction */
-        PostMessage(hwnd, WM_USER, 0x1234, 0x5678);
-        PostMessage(hwnd, WM_QUIT, 0x1234, 0x5678);
-        PostMessage(hwnd, WM_QUIT, 0x4321, 0x8765);
+        PostMessageA(hwnd, WM_USER, 0x1234, 0x5678);
+        PostMessageA(hwnd, WM_QUIT, 0x1234, 0x5678);
+        PostMessageA(hwnd, WM_QUIT, 0x4321, 0x8765);
     }
 
     return DefWindowProcA(hwnd, message, wp, lp);
@@ -7716,13 +7882,13 @@ static LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
                 if (PeekMessageA(&msg2, 0, 0, 0, 1))
                 {
                     TranslateMessage(&msg2);
-                    DispatchMessage(&msg2);
+                    DispatchMessageA(&msg2);
                 }
                 i--;
             }
             else ok(broken(1), "infinite loop\n");
             if ( i == 0)
-                paint_loop_done = 1;
+                paint_loop_done = TRUE;
             return DefWindowProcA(hWnd,msg,wParam,lParam);
         }
     }
@@ -7783,7 +7949,7 @@ static BOOL RegisterWindowClasses(void)
     cls.cbWndExtra = 0;
     cls.hInstance = GetModuleHandleA(0);
     cls.hIcon = 0;
-    cls.hCursor = LoadCursorA(0, IDC_ARROW);
+    cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
     cls.lpszMenuName = NULL;
     cls.lpszClassName = "TestWindowClass";
@@ -8134,7 +8300,15 @@ static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
 {
 }
 
-#define TIMER_ID  0x19
+#define TIMER_ID               0x19
+#define TIMER_COUNT_EXPECTED   64
+#define TIMER_COUNT_TOLERANCE  9
+
+static int count = 0;
+static void CALLBACK callback_count(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+    count++;
+}
 
 static DWORD WINAPI timer_thread_proc(LPVOID x)
 {
@@ -8154,9 +8328,11 @@ static DWORD WINAPI timer_thread_proc(LPVOID x)
 static void test_timers(void)
 {
     struct timer_info info;
+    DWORD start;
     DWORD id;
+    MSG msg;
 
-    info.hWnd = CreateWindow ("TestWindowClass", NULL,
+    info.hWnd = CreateWindowA("TestWindowClass", NULL,
        WS_OVERLAPPEDWINDOW ,
        CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
        NULL, NULL, 0);
@@ -8164,7 +8340,7 @@ static void test_timers(void)
     info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
     ok(info.id, "SetTimer failed\n");
     ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
-    info.handles[0] = CreateEvent(NULL,0,0,NULL);
+    info.handles[0] = CreateEventW(NULL,0,0,NULL);
     info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
 
     WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
@@ -8176,23 +8352,53 @@ static void test_timers(void)
 
     ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
 
-    ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
-}
+    /* Check the minimum allowed timeout for a timer.  MSDN indicates that it should be 10.0 ms,
+     * but testing indicates that the minimum timeout is actually about 15.6 ms.  Since there is
+     * some measurement error between test runs we're allowing for Â±8 counts (~2 ms).
+     */
+    count = 0;
+    id = SetTimer(info.hWnd, TIMER_ID, 0, callback_count);
+    ok(id != 0, "did not get id from SetTimer.\n");
+    ok(id==TIMER_ID, "SetTimer timer ID different\n");
+    start = GetTickCount();
+    while (GetTickCount()-start < 1001 && GetMessageA(&msg, info.hWnd, 0, 0))
+        DispatchMessageA(&msg);
+    ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE
+       || broken(abs(count-43) < TIMER_COUNT_TOLERANCE) /* w2k3 */,
+       "did not get expected count for minimum timeout (%d != ~%d).\n",
+       count, TIMER_COUNT_EXPECTED);
+    ok(KillTimer(info.hWnd, id), "KillTimer failed\n");
+    /* Perform the same check on SetSystemTimer (only available on w2k3 and older) */
+    if (pSetSystemTimer)
+    {
+        int syscount = 0;
+
+        count = 0;
+        id = pSetSystemTimer(info.hWnd, TIMER_ID, 0, callback_count);
+        ok(id != 0, "did not get id from SetSystemTimer.\n");
+        ok(id==TIMER_ID, "SetTimer timer ID different\n");
+        start = GetTickCount();
+        while (GetTickCount()-start < 1001 && GetMessageA(&msg, info.hWnd, 0, 0))
+        {
+            if (msg.message == WM_SYSTIMER)
+                syscount++;
+            DispatchMessageA(&msg);
+        }
+        ok(abs(syscount-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE,
+           "did not get expected count for minimum timeout (%d != ~%d).\n",
+           syscount, TIMER_COUNT_EXPECTED);
+        todo_wine ok(count == 0, "did not get expected count for callback timeout (%d != 0).\n",
+                                 count);
+        ok(pKillSystemTimer(info.hWnd, id), "KillSystemTimer failed\n");
+    }
 
-static int count = 0;
-static VOID CALLBACK callback_count(
-    HWND hwnd,
-    UINT uMsg,
-    UINT_PTR idEvent,
-    DWORD dwTime
-)
-{
-    count++;
+    ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
 }
 
 static void test_timers_no_wnd(void)
 {
     UINT_PTR id, id2;
+    DWORD start;
     MSG msg;
 
     count = 0;
@@ -8201,15 +8407,31 @@ static void test_timers_no_wnd(void)
     id2 = SetTimer(NULL, id, 200, callback_count);
     ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
     Sleep(150);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(count == 0, "did not get zero count as expected (%i).\n", count);
     Sleep(150);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(count == 1, "did not get one count as expected (%i).\n", count);
     KillTimer(NULL, id);
     Sleep(250);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(count == 1, "killing replaced timer did not work (%i).\n", count);
+
+    /* Check the minimum allowed timeout for a timer.  MSDN indicates that it should be 10.0 ms,
+     * but testing indicates that the minimum timeout is actually about 15.6 ms.  Since there is
+     * some measurement error between test runs we're allowing for Â±8 counts (~2 ms).
+     */
+    count = 0;
+    id = SetTimer(NULL, 0, 0, callback_count);
+    ok(id != 0, "did not get id from SetTimer.\n");
+    start = GetTickCount();
+    while (GetTickCount()-start < 1001 && GetMessageA(&msg, NULL, 0, 0))
+        DispatchMessageA(&msg);
+    ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE,
+       "did not get expected count for minimum timeout (%d != ~%d).\n",
+       count, TIMER_COUNT_EXPECTED);
+    KillTimer(NULL, id);
+    /* Note: SetSystemTimer doesn't support a NULL window, see test_timers */
 }
 
 /* Various win events with arbitrary parameters */
@@ -8399,10 +8621,10 @@ static DWORD WINAPI win_event_global_thread_proc(void *param)
     pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
     SetEvent(hevent);
 
-    while (GetMessage(&msg, 0, 0, 0))
+    while (GetMessageA(&msg, 0, 0, 0))
     {
        TranslateMessage(&msg);
-       DispatchMessage(&msg);
+       DispatchMessageA(&msg);
     }
     return 0;
 }
@@ -8435,10 +8657,10 @@ static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
 
     SetEvent(hevent);
 
-    while (GetMessage(&msg, 0, 0, 0))
+    while (GetMessageA(&msg, 0, 0, 0))
     {
        TranslateMessage(&msg);
-       DispatchMessage(&msg);
+       DispatchMessageA(&msg);
     }
     return 0;
 }
@@ -8466,10 +8688,10 @@ static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
     mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
 
     SetEvent(hevent);
-    while (GetMessage(&msg, 0, 0, 0))
+    while (GetMessageA(&msg, 0, 0, 0))
     {
         TranslateMessage(&msg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     return 0;
 }
@@ -8654,7 +8876,7 @@ static void test_winevents(void)
     ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
 
     while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
 
     ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
     flush_sequence();
@@ -8820,22 +9042,22 @@ static void test_scrollwindowex(void)
     trace("start scroll\n");
     ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
             SW_ERASE|SW_INVALIDATE);
-    ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
+    ok_sequence(WmEmptySeq, "ScrollWindowEx", FALSE);
     trace("end scroll\n");
     flush_sequence();
     flush_events();
-    ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
+    ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", FALSE);
     flush_events();
     flush_sequence();
 
     /* Now without the SW_ERASE flag */
     trace("start scroll\n");
     ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
-    ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
+    ok_sequence(WmEmptySeq, "ScrollWindowEx", FALSE);
     trace("end scroll\n");
     flush_sequence();
     flush_events();
-    ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
+    ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", FALSE);
     flush_events();
     flush_sequence();
 
@@ -8849,7 +9071,7 @@ static void test_scrollwindowex(void)
     trace("end scroll\n");
     flush_sequence();
     flush_events();
-    ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
+    ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", FALSE);
     flush_events();
     flush_sequence();
 
@@ -8859,7 +9081,7 @@ static void test_scrollwindowex(void)
     trace("end scroll\n");
     flush_sequence();
     flush_events();
-    ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
+    ok_sequence(ScrollWindowPaint1, "ScrollWindow", FALSE);
 
     ok(DestroyWindow(hchild), "failed to destroy window\n");
     ok(DestroyWindow(hwnd), "failed to destroy window\n");
@@ -8992,7 +9214,7 @@ static void test_DestroyWindow(void)
     ret = DestroyWindow(parent);
     ok( ret, "DestroyWindow() error %d\n", GetLastError());
     test_DestroyWindow_flag = FALSE;
-    ok_sequence(destroy_window_with_children, "destroy window with children", 0);
+    ok_sequence(destroy_window_with_children, "destroy window with children", FALSE);
 
     ok(!IsWindow(parent), "parent still exists\n");
     ok(!IsWindow(child1), "child1 still exists\n");
@@ -9035,13 +9257,13 @@ static void test_DispatchMessage(void)
     SetRect( &rect, -5, -5, 5, 5 );
     RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
     count = 0;
-    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
     {
-        if (msg.message != WM_PAINT) DispatchMessage( &msg );
+        if (msg.message != WM_PAINT) DispatchMessageA( &msg );
         else
         {
             flush_sequence();
-            DispatchMessage( &msg );
+            DispatchMessageA( &msg );
             /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
             if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
             else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
@@ -9054,9 +9276,9 @@ static void test_DispatchMessage(void)
     flush_sequence();
     RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
     count = 0;
-    while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
     {
-        if (msg.message != WM_PAINT) DispatchMessage( &msg );
+        if (msg.message != WM_PAINT) DispatchMessageA( &msg );
         else
         {
             HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
@@ -9071,6 +9293,26 @@ static void test_DispatchMessage(void)
             if (++count > 10) break;
         }
     }
+
+    flush_sequence();
+    RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
+    count = 0;
+    while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
+    {
+        if (msg.message != WM_PAINT) DispatchMessageA( &msg );
+        else
+        {
+            HDC hdc;
+
+            flush_sequence();
+            hdc = BeginPaint( hwnd, NULL );
+            ok( !hdc, "got valid hdc %p from BeginPaint\n", hdc );
+            ok( !EndPaint( hwnd, NULL ), "EndPaint succeeded\n" );
+            ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
+            ok( !count, "Got multiple WM_PAINTs\n" );
+            if (++count > 10) break;
+        }
+    }
     DestroyWindow(hwnd);
 }
 
@@ -9103,7 +9345,7 @@ static void wait_for_thread( HANDLE thread )
     while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
     {
         MSG msg;
-        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA(&msg);
     }
 }
 
@@ -9213,6 +9455,17 @@ static const struct message sl_edit_setfocus[] =
     { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
     { 0 }
 };
+static const struct message sl_edit_invisible[] =
+{
+    { HCBT_SETFOCUS, hook },
+    { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
+    { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
+    { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
+    { WM_KILLFOCUS, sent|parent },
+    { WM_SETFOCUS, sent },
+    { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
+    { 0 }
+};
 static const struct message ml_edit_setfocus[] =
 {
     { HCBT_SETFOCUS, hook },
@@ -9335,10 +9588,10 @@ static void subclass_edit(void)
 
     old_edit_proc = cls.lpfnWndProc;
 
-    cls.hInstance = GetModuleHandle(0);
+    cls.hInstance = GetModuleHandleA(NULL);
     cls.lpfnWndProc = edit_hook_proc;
     cls.lpszClassName = "my_edit_class";
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
     if (!RegisterClassA(&cls)) assert(0);
 }
 
@@ -9362,6 +9615,10 @@ static void test_edit_messages(void)
     dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
     ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
 
+    flush_sequence();
+    SetFocus(hwnd);
+    ok_sequence(sl_edit_invisible, "SetFocus(hwnd) on an invisible edit", FALSE);
+
     ShowWindow(hwnd, SW_SHOW);
     UpdateWindow(hwnd);
     SetFocus(0);
@@ -9540,7 +9797,7 @@ static void test_PeekMessage(void)
     }
     if (qstatus & QS_POSTMESSAGE)
     {
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) /* nothing */ ;
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) /* nothing */ ;
         qstatus = GetQueueStatus(qs_all_input);
     }
     ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
@@ -9974,8 +10231,7 @@ static void wait_move_event(HWND hwnd, int x, int y)
 {
     MSG msg;
     DWORD time;
-    BOOL  ret;
-    int go = 0;
+    BOOL ret, go = FALSE;
 
     time = GetTickCount();
     while (GetTickCount() - time < 200 && !go) {
@@ -10000,7 +10256,7 @@ static void test_PeekMessage2(void)
     x1 = y1 = x2 = y2 = x3 = y3 = 0;
 
     /* Initialise window and make sure it is ready for events */
-    hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
+    hwnd = CreateWindowA("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
                         10, 10, 800, 800, NULL, NULL, NULL, NULL);
     assert(hwnd);
     trace("Window for test_PeekMessage2 %p\n", hwnd);
@@ -10096,8 +10352,8 @@ static INT_PTR CALLBACK wm_quit_dlg_proc(HWND hwnd, UINT message, WPARAM wp, LPA
     switch (message)
     {
     case WM_INITDIALOG:
-        PostMessage(hwnd, WM_QUIT, 0x1234, 0x5678);
-        PostMessage(hwnd, WM_USER, 0xdead, 0xbeef);
+        PostMessageA(hwnd, WM_QUIT, 0x1234, 0x5678);
+        PostMessageA(hwnd, WM_USER, 0xdead, 0xbeef);
         return 0;
 
     case WM_GETDLGCODE:
@@ -10139,55 +10395,55 @@ static void test_quit_message(void)
     flush_events();
     PostQuitMessage(0xbeef);
 
-    ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
+    ret = PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE);
     ok(ret, "PeekMessage failed with error %d\n", GetLastError());
     ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
     ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
 
-    ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
+    ret = PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0);
     ok(ret, "PostMessage failed with error %d\n", GetLastError());
 
-    ret = GetMessage(&msg, NULL, 0, 0);
+    ret = GetMessageA(&msg, NULL, 0, 0);
     ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
     ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
 
     /* note: WM_QUIT message received after WM_USER message */
-    ret = GetMessage(&msg, NULL, 0, 0);
+    ret = GetMessageA(&msg, NULL, 0, 0);
     ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
     ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
     ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
 
-    ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
+    ret = PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE);
     ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
 
     /* now test with PostThreadMessage - different behaviour! */
-    PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
+    PostThreadMessageA(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
 
-    ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
+    ret = PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE);
     ok(ret, "PeekMessage failed with error %d\n", GetLastError());
     ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
     ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
 
-    ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
+    ret = PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0);
     ok(ret, "PostMessage failed with error %d\n", GetLastError());
 
     /* note: we receive the WM_QUIT message first this time */
-    ret = GetMessage(&msg, NULL, 0, 0);
+    ret = GetMessageA(&msg, NULL, 0, 0);
     ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
     ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
     ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
 
-    ret = GetMessage(&msg, NULL, 0, 0);
+    ret = GetMessageA(&msg, NULL, 0, 0);
     ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
     ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
 
     flush_events();
     flush_sequence();
-    ret = DialogBoxParam(GetModuleHandle(0), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc, 0);
+    ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc, 0);
     ok(ret == 1, "expected 1, got %d\n", ret);
     ok_sequence(WmQuitDialogSeq, "WmQuitDialogSeq", FALSE);
     memset(&msg, 0xab, sizeof(msg));
-    ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
+    ret = PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE);
     ok(ret, "PeekMessage failed\n");
     ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
     ok(msg.wParam == 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg.wParam);
@@ -10199,7 +10455,7 @@ static void test_quit_message(void)
     CreateWindowExA(0, "StopQuitClass", "Stop Quit Test", WS_OVERLAPPEDWINDOW,
                     0, 0, 100, 100, NULL, NULL, NULL, NULL);
     flush_sequence();
-    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
     {
         struct recvd_message rmsg;
         rmsg.hwnd = msg.hwnd;
@@ -10212,7 +10468,7 @@ static void test_quit_message(void)
             /* The hwnd can only be checked here */
             ok(!msg.hwnd, "The WM_QUIT hwnd was %p instead of NULL\n", msg.hwnd);
         add_message(&rmsg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmStopQuitSeq, "WmStopQuitSeq", FALSE);
 }
@@ -10237,7 +10493,7 @@ static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
 
     do
     {
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
         {
             /* Timer proc messages are not dispatched to the window proc,
              * and therefore not logged.
@@ -10254,7 +10510,7 @@ static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
                 s_msg.descr = "msg_loop";
                 add_message(&s_msg);
             }
-            DispatchMessage(&msg);
+            DispatchMessageA(&msg);
         }
 
         end_ticks = GetTickCount();
@@ -10314,31 +10570,31 @@ static void test_TrackMouseEvent(void)
 
     default_hover_time = 0xdeadbeef;
     SetLastError(0xdeadbeef);
-    ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
+    ret = SystemParametersInfoA(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
     ok(ret || broken(GetLastError() == 0xdeadbeef),  /* win9x */
        "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
     if (!ret) default_hover_time = 400;
     trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
 
     SetLastError(0xdeadbeef);
-    ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
+    ret = SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
     ok(ret || broken(GetLastError() == 0xdeadbeef),  /* win9x */
        "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
     if (!ret) hover_width = 4;
     SetLastError(0xdeadbeef);
-    ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
+    ret = SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
     ok(ret || broken(GetLastError() == 0xdeadbeef),  /* win9x */
        "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
     if (!ret) hover_height = 4;
     trace("hover rect is %u x %d\n", hover_width, hover_height);
 
-    hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
+    hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
                          WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                          CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
                          NULL, NULL, 0);
     assert(hwnd);
 
-    hchild = CreateWindowEx(0, "TestWindowClass", NULL,
+    hchild = CreateWindowExA(0, "TestWindowClass", NULL,
                          WS_CHILD | WS_BORDER | WS_VISIBLE,
                          50, 50, 200, 200, hwnd,
                          NULL, NULL, 0);
@@ -10912,12 +11168,12 @@ static void test_ShowWindow(void)
     RECT win_rc, work_rc = {0, 0, 0, 0};
 
 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
-    hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
+    hwnd = CreateWindowExA(0, "ShowWindowClass", NULL, WS_BASE,
                           120, 120, 90, 90,
                           0, 0, 0, NULL);
     assert(hwnd);
 
-    style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
+    style = GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BASE;
     ok(style == 0, "expected style 0, got %08x\n", style);
 
     flush_events();
@@ -10983,11 +11239,11 @@ static void test_ShowWindow(void)
 
         idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
 
-        style = GetWindowLong(hwnd, GWL_STYLE);
+        style = GetWindowLongA(hwnd, GWL_STYLE);
         trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
         ret = ShowWindow(hwnd, sw[i].cmd);
         ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
-        style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
+        style = GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BASE;
         ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
 
         sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
@@ -11010,11 +11266,6 @@ static void test_ShowWindow(void)
         }
         else
         {
-            if (wp.ptMinPosition.x != sw[i].wp_min.x || wp.ptMinPosition.y != sw[i].wp_min.y)
-            todo_wine
-            ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y,
-               "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
-            else
             ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y,
                "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
         }
@@ -11126,36 +11377,36 @@ static const struct message WmCreateDialogParamSeq_2[] = {
 
 static void test_dialog_messages(void)
 {
-    WNDCLASS cls;
+    WNDCLASSA cls;
     HWND hdlg, hedit1, hedit2, hfocus;
     LRESULT ret;
 
 #define set_selection(hctl, start, end) \
-    ret = SendMessage(hctl, EM_SETSEL, start, end); \
+    ret = SendMessageA(hctl, EM_SETSEL, start, end); \
     ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
 
 #define check_selection(hctl, start, end) \
-    ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
+    ret = SendMessageA(hctl, EM_GETSEL, 0, 0); \
     ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
 
     subclass_edit();
 
-    hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
+    hdlg = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
                           WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
                           0, 0, 100, 100, 0, 0, 0, NULL);
     ok(hdlg != 0, "Failed to create custom dialog window\n");
 
-    hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
+    hedit1 = CreateWindowExA(0, "my_edit_class", NULL,
                            WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
                            0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
     ok(hedit1 != 0, "Failed to create edit control\n");
-    hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
+    hedit2 = CreateWindowExA(0, "my_edit_class", NULL,
                            WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
                            0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
     ok(hedit2 != 0, "Failed to create edit control\n");
 
-    SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
-    SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
+    SendMessageA(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
+    SendMessageA(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
 
     hfocus = GetFocus();
     ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
@@ -11175,7 +11426,7 @@ static void test_dialog_messages(void)
     ok(hfocus == 0, "wrong focus %p\n", hfocus);
 
     flush_sequence();
-    ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
+    ret = DefDlgProcA(hdlg, WM_SETFOCUS, 0, 0);
     ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
     ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
 
@@ -11186,7 +11437,7 @@ static void test_dialog_messages(void)
     check_selection(hedit2, 0, 3);
 
     flush_sequence();
-    ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
+    ret = DefDlgProcA(hdlg, WM_SETFOCUS, 0, 0);
     ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
     ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
 
@@ -11205,34 +11456,34 @@ static void test_dialog_messages(void)
 #undef set_selection
 #undef check_selection
 
-    ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
+    ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
     cls.lpszClassName = "MyDialogClass";
-    cls.hInstance = GetModuleHandle(0);
+    cls.hInstance = GetModuleHandleA(NULL);
     /* need a cast since a dlgproc is used as a wndproc */
     cls.lpfnWndProc = test_dlg_proc;
-    if (!RegisterClass(&cls)) assert(0);
+    if (!RegisterClassA(&cls)) assert(0);
 
-    hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
+    hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
     ok(IsWindow(hdlg), "CreateDialogParam failed\n");
     ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
     EndDialog(hdlg, 0);
     DestroyWindow(hdlg);
     flush_sequence();
 
-    hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
+    hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
     ok(IsWindow(hdlg), "CreateDialogParam failed\n");
     ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
     EndDialog(hdlg, 0);
     DestroyWindow(hdlg);
     flush_sequence();
 
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
 }
 
 static void test_EndDialog(void)
 {
     HWND hparent, hother, hactive, hdlg;
-    WNDCLASS cls;
+    WNDCLASSA cls;
 
     hparent = CreateWindowExA(0, "TestParentClass", "Test parent",
                               WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_DISABLED,
@@ -11244,12 +11495,11 @@ static void test_EndDialog(void)
                               100, 100, 200, 200, 0, 0, 0, NULL);
     ok (hother != 0, "Failed to create parent window\n");
 
-    ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
+    ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
     cls.lpszClassName = "MyDialogClass";
-    cls.hInstance = GetModuleHandle(0);
-    /* need a cast since a dlgproc is used as a wndproc */
-    cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
-    if (!RegisterClass(&cls)) assert(0);
+    cls.hInstance = GetModuleHandleA(NULL);
+    cls.lpfnWndProc = test_dlg_proc;
+    if (!RegisterClassA(&cls)) assert(0);
 
     flush_sequence();
     SetForegroundWindow(hother);
@@ -11259,7 +11509,7 @@ static void test_EndDialog(void)
     /* create a dialog where the parent is disabled, this parent should still
        receive the focus when the dialog exits (even though "normally" a
        disabled window should not receive the focus) */
-    hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", hparent, test_dlg_proc, 0);
+    hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", hparent, test_dlg_proc, 0);
     ok(IsWindow(hdlg), "CreateDialogParam failed\n");
     SetForegroundWindow(hdlg);
     hactive = GetForegroundWindow();
@@ -11272,7 +11522,7 @@ static void test_EndDialog(void)
 
     DestroyWindow( hother );
     DestroyWindow( hparent );
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
 }
 
 static void test_nullCallback(void)
@@ -11804,6 +12054,93 @@ static void test_dbcs_wm_char(void)
     DestroyWindow(hwnd2);
 }
 
+static void test_unicode_wm_char(void)
+{
+    HWND hwnd;
+    MSG msg;
+    struct message seq[2];
+    HKL hkl_orig, hkl_greek;
+    DWORD cp;
+    LCID thread_locale;
+
+    hkl_orig = GetKeyboardLayout( 0 );
+    GetLocaleInfoW( LOWORD( hkl_orig ), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (WCHAR*)&cp, sizeof(cp) / sizeof(WCHAR) );
+    if (cp != 1252)
+    {
+        skip( "Default codepage %d\n", cp );
+        return;
+    }
+
+    hkl_greek = LoadKeyboardLayoutA( "00000408", 0 );
+    if (!hkl_greek || hkl_greek == hkl_orig /* win2k */)
+    {
+        skip( "Unable to load Greek keyboard layout\n" );
+        return;
+    }
+
+    hwnd = CreateWindowExW( 0, testWindowClassW, NULL, WS_OVERLAPPEDWINDOW,
+                            100, 100, 200, 200, 0, 0, 0, NULL );
+    flush_sequence();
+
+    PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 );
+
+    ok( GetMessageW( &msg, hwnd, 0, 0 ), "no message\n" );
+    ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
+    ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
+    ok( msg.wParam == 0x3b1, "bad wparam %lx\n", msg.wParam );
+    ok( msg.lParam == 0, "bad lparam %lx\n", msg.lParam );
+
+    DispatchMessageW( &msg );
+
+    memset( seq, 0, sizeof(seq) );
+    seq[0].message = WM_CHAR;
+    seq[0].flags = sent|wparam;
+    seq[0].wParam = 0x3b1;
+
+    ok_sequence( seq, "unicode WM_CHAR", FALSE );
+
+    flush_sequence();
+
+    /* greek alpha -> 'a' in cp1252 */
+    PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 );
+
+    ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
+    ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
+    ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
+    ok( msg.wParam == 0x61, "bad wparam %lx\n", msg.wParam );
+    ok( msg.lParam == 0, "bad lparam %lx\n", msg.lParam );
+
+    DispatchMessageA( &msg );
+
+    seq[0].wParam = 0x61;
+    ok_sequence( seq, "unicode WM_CHAR", FALSE );
+
+    thread_locale = GetThreadLocale();
+    ActivateKeyboardLayout( hkl_greek, 0 );
+    ok( GetThreadLocale() == thread_locale, "locale changed from %08x to %08x\n",
+        thread_locale, GetThreadLocale() );
+
+    flush_sequence();
+
+    /* greek alpha -> 0xe1 in cp1253 */
+    PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 );
+
+    ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
+    ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
+    ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
+    ok( msg.wParam == 0xe1, "bad wparam %lx\n", msg.wParam );
+    ok( msg.lParam == 0, "bad lparam %lx\n", msg.lParam );
+
+    DispatchMessageA( &msg );
+
+    seq[0].wParam = 0x3b1;
+    ok_sequence( seq, "unicode WM_CHAR", FALSE );
+
+    DestroyWindow( hwnd );
+    ActivateKeyboardLayout( hkl_orig, 0 );
+    UnloadKeyboardLayout( hkl_greek );
+}
+
 #define ID_LISTBOX 0x000f
 
 static const struct message wm_lb_setcursel_0[] =
@@ -11955,11 +12292,11 @@ static void test_listbox_messages(void)
 
     check_lb_state(listbox, 0, LB_ERR, 0, 0);
 
-    ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
+    ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
     ok(ret == 0, "expected 0, got %ld\n", ret);
-    ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
+    ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
     ok(ret == 1, "expected 1, got %ld\n", ret);
-    ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
+    ret = SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
     ok(ret == 2, "expected 2, got %ld\n", ret);
 
     check_lb_state(listbox, 3, LB_ERR, 0, 0);
@@ -11969,56 +12306,56 @@ static void test_listbox_messages(void)
     log_all_parent_messages++;
 
     trace("selecting item 0\n");
-    ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
+    ret = SendMessageA(listbox, LB_SETCURSEL, 0, 0);
     ok(ret == 0, "expected 0, got %ld\n", ret);
     ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
     check_lb_state(listbox, 3, 0, 0, 0);
     flush_sequence();
 
     trace("selecting item 1\n");
-    ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
+    ret = SendMessageA(listbox, LB_SETCURSEL, 1, 0);
     ok(ret == 1, "expected 1, got %ld\n", ret);
     ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
     check_lb_state(listbox, 3, 1, 1, 0);
 
     trace("selecting item 2\n");
-    ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
+    ret = SendMessageA(listbox, LB_SETCURSEL, 2, 0);
     ok(ret == 2, "expected 2, got %ld\n", ret);
     ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
     check_lb_state(listbox, 3, 2, 2, 0);
 
     trace("clicking on item 0\n");
-    ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
+    ret = SendMessageA(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
     ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
-    ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
+    ret = SendMessageA(listbox, WM_LBUTTONUP, 0, 0);
     ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
     ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
     check_lb_state(listbox, 3, 0, 0, 0);
     flush_sequence();
 
     trace("deleting item 0\n");
-    ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
+    ret = SendMessageA(listbox, LB_DELETESTRING, 0, 0);
     ok(ret == 2, "expected 2, got %ld\n", ret);
     ok_sequence(wm_lb_deletestring, "LB_DELETESTRING 0", FALSE );
     check_lb_state(listbox, 2, -1, 0, 0);
     flush_sequence();
 
     trace("deleting item 0\n");
-    ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
+    ret = SendMessageA(listbox, LB_DELETESTRING, 0, 0);
     ok(ret == 1, "expected 1, got %ld\n", ret);
     ok_sequence(wm_lb_deletestring, "LB_DELETESTRING 0", FALSE );
     check_lb_state(listbox, 1, -1, 0, 0);
     flush_sequence();
 
     trace("deleting item 0\n");
-    ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
+    ret = SendMessageA(listbox, LB_DELETESTRING, 0, 0);
     ok(ret == 0, "expected 0, got %ld\n", ret);
     ok_sequence(wm_lb_deletestring_reset, "LB_DELETESTRING 0", FALSE );
     check_lb_state(listbox, 0, -1, 0, 0);
     flush_sequence();
 
     trace("deleting item 0\n");
-    ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
+    ret = SendMessageA(listbox, LB_DELETESTRING, 0, 0);
     ok(ret == LB_ERR, "expected LB_ERR, got %ld\n", ret);
     check_lb_state(listbox, 0, -1, 0, 0);
     flush_sequence();
@@ -12236,11 +12573,11 @@ static void test_menu_messages(void)
     cls.cbWndExtra = 0;
     cls.hInstance = GetModuleHandleA(0);
     cls.hIcon = 0;
-    cls.hCursor = LoadCursorA(0, IDC_ARROW);
+    cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
     cls.lpszMenuName = NULL;
     cls.lpszClassName = "TestMenuClass";
-    UnregisterClass(cls.lpszClassName, cls.hInstance);
+    UnregisterClassA(cls.lpszClassName, cls.hInstance);
     if (!RegisterClassA(&cls)) assert(0);
 
     SetLastError(0xdeadbeef);
@@ -12249,11 +12586,12 @@ static void test_menu_messages(void)
     ok(hwnd != 0, "LoadMenuA error %u\n", GetLastError());
 
     SetLastError(0xdeadbeef);
-    hmenu = LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
+    hmenu = LoadMenuA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1));
     ok(hmenu != 0, "LoadMenuA error %u\n", GetLastError());
 
     SetMenu(hwnd, hmenu);
     SetForegroundWindow( hwnd );
+    flush_events();
 
     set_menu_style(hmenu, MNS_NOTIFYBYPOS);
     style = get_menu_style(hmenu);
@@ -12278,10 +12616,10 @@ static void test_menu_messages(void)
     keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
     keybd_event(VK_RETURN, 0, 0, 0);
     keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
     {
         TranslateMessage(&msg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     if (!sequence_cnt)  /* we didn't get any message */
     {
@@ -12307,10 +12645,10 @@ static void test_menu_messages(void)
     keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
     keybd_event(VK_RETURN, 0, 0, 0);
     keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
     {
         TranslateMessage(&msg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(wm_popup_menu_2, "submenu of a popup menu command", FALSE);
 
@@ -12322,10 +12660,10 @@ static void test_menu_messages(void)
     keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
     keybd_event(VK_ESCAPE, 0, 0, 0);
     keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
     {
         TranslateMessage(&msg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(wm_single_menu_item, "single menu item command", FALSE);
 
@@ -12355,10 +12693,10 @@ static void test_menu_messages(void)
     keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
     keybd_event(VK_RETURN, 0, 0, 0);
     keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
     {
         TranslateMessage(&msg);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(wm_popup_menu_3, "submenu of a popup menu command", FALSE);
 
@@ -12372,7 +12710,7 @@ static void test_paintingloop(void)
 {
     HWND hwnd;
 
-    paint_loop_done = 0;
+    paint_loop_done = FALSE;
     hwnd = CreateWindowExA(0x0,"PaintLoopWindowClass",
                                "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW,
                                 100, 100, 100, 100, 0, 0, 0, NULL );
@@ -12386,7 +12724,7 @@ static void test_paintingloop(void)
         if (PeekMessageA(&msg, 0, 0, 0, 1))
         {
             TranslateMessage(&msg);
-            DispatchMessage(&msg);
+            DispatchMessageA(&msg);
         }
     }
     DestroyWindow(hwnd);
@@ -12396,7 +12734,7 @@ static void test_defwinproc(void)
 {
     HWND hwnd;
     MSG msg;
-    int gotwmquit = FALSE;
+    BOOL gotwmquit = FALSE;
     hwnd = CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP, 0,0,0,0,0,0,0, NULL);
     assert(hwnd);
     DefWindowProcA( hwnd, WM_ENDSESSION, 1, 0);
@@ -12404,7 +12742,7 @@ static void test_defwinproc(void)
         if( msg.message == WM_QUIT) gotwmquit = TRUE;
         DispatchMessageA( &msg );
     }
-    ok( gotwmquit == FALSE, "Unexpected WM_QUIT message!\n");
+    ok(!gotwmquit, "Unexpected WM_QUIT message!\n");
     DestroyWindow( hwnd);
 }
 
@@ -12606,8 +12944,8 @@ static void test_PostMessage(void)
 
     flush_events();
 
-    PostMessage(hwnd, WM_USER+1, 0x1234, 0x5678);
-    PostMessage(0, WM_USER+2, 0x5678, 0x1234);
+    PostMessageA(hwnd, WM_USER+1, 0x1234, 0x5678);
+    PostMessageA(0, WM_USER+2, 0x5678, 0x1234);
 
     for (i = 0; i < sizeof(data)/sizeof(data[0]); i++)
     {
@@ -12666,7 +13004,7 @@ static DWORD CALLBACK do_wait_idle_child_thread( void *arg )
 {
     MSG msg;
 
-    PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
+    PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
     Sleep( 200 );
     MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
     return 0;
@@ -12674,7 +13012,7 @@ static DWORD CALLBACK do_wait_idle_child_thread( void *arg )
 
 static void do_wait_idle_child( int arg )
 {
-    WNDCLASS cls;
+    WNDCLASSA cls;
     MSG msg;
     HWND hwnd = 0;
     HANDLE thread;
@@ -12683,13 +13021,13 @@ static void do_wait_idle_child( int arg )
     HANDLE end_event = OpenEventA( EVENT_ALL_ACCESS, FALSE, "test_WaitForInputIdle_end" );
 
     memset( &cls, 0, sizeof(cls) );
-    cls.lpfnWndProc   = DefWindowProc;
+    cls.lpfnWndProc   = DefWindowProcA;
     cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
-    cls.hCursor       = LoadCursor(0, IDC_ARROW);
+    cls.hCursor       = LoadCursorA(0, (LPCSTR)IDC_ARROW);
     cls.lpszClassName = "TestClass";
-    RegisterClass( &cls );
+    RegisterClassA( &cls );
 
-    PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );  /* create the msg queue */
+    PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );  /* create the msg queue */
 
     ok( start_event != 0, "failed to create start event, error %u\n", GetLastError() );
     ok( end_event != 0, "failed to create end event, error %u\n", GetLastError() );
@@ -12702,40 +13040,40 @@ static void do_wait_idle_child( int arg )
     case 1:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
+        PeekMessageA( &msg, 0, 0, 0, PM_REMOVE );
         break;
     case 2:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
-        PostThreadMessage( GetCurrentThreadId(), WM_COMMAND, 0x1234, 0xabcd );
-        PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
+        PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
+        PostThreadMessageA( GetCurrentThreadId(), WM_COMMAND, 0x1234, 0xabcd );
+        PeekMessageA( &msg, 0, 0, 0, PM_REMOVE );
         break;
     case 3:
         SetEvent( start_event );
         Sleep( 200 );
-        SendMessage( HWND_BROADCAST, WM_WININICHANGE, 0, 0 );
+        SendMessageA( HWND_BROADCAST, WM_WININICHANGE, 0, 0 );
         break;
     case 4:
         SetEvent( start_event );
         Sleep( 200 );
         hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessage( &msg );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessageA( &msg );
         break;
     case 5:
         SetEvent( start_event );
         Sleep( 200 );
         hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
         break;
     case 6:
         SetEvent( start_event );
         Sleep( 200 );
         hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
-        while (PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ))
+        while (PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ))
         {
-            GetMessage( &msg, 0, 0, 0 );
-            DispatchMessage( &msg );
+            GetMessageA( &msg, 0, 0, 0 );
+            DispatchMessageA( &msg );
         }
         break;
     case 7:
@@ -12744,20 +13082,20 @@ static void do_wait_idle_child( int arg )
         hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
         SetTimer( hwnd, 3, 1, NULL );
         Sleep( 200 );
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessage( &msg );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessageA( &msg );
         break;
     case 8:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
         MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
         break;
     case 9:
         SetEvent( start_event );
         Sleep( 200 );
         hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
-        for (;;) GetMessage( &msg, 0, 0, 0 );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
+        for (;;) GetMessageA( &msg, 0, 0, 0 );
         break;
     case 10:
         SetEvent( start_event );
@@ -12765,21 +13103,21 @@ static void do_wait_idle_child( int arg )
         hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
         SetTimer( hwnd, 3, 1, NULL );
         Sleep( 200 );
-        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+        while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
         break;
     case 11:
         SetEvent( start_event );
         Sleep( 200 );
         return;  /* exiting the process makes WaitForInputIdle return success too */
     case 12:
-        PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
         Sleep( 200 );
         MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
         SetEvent( start_event );
         break;
     case 13:
         SetEvent( start_event );
-        PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
         Sleep( 200 );
         thread = CreateThread( NULL, 0, do_wait_idle_child_thread, NULL, 0, &id );
         WaitForSingleObject( thread, 10000 );
@@ -12788,37 +13126,37 @@ static void do_wait_idle_child( int arg )
     case 14:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, HWND_TOPMOST, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, HWND_TOPMOST, 0, 0, PM_NOREMOVE );
         break;
     case 15:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, HWND_BROADCAST, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, HWND_BROADCAST, 0, 0, PM_NOREMOVE );
         break;
     case 16:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, HWND_BOTTOM, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, HWND_BOTTOM, 0, 0, PM_NOREMOVE );
         break;
     case 17:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, (HWND)0xdeadbeef, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, (HWND)0xdeadbeef, 0, 0, PM_NOREMOVE );
         break;
     case 18:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, HWND_NOTOPMOST, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, HWND_NOTOPMOST, 0, 0, PM_NOREMOVE );
         break;
     case 19:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, HWND_MESSAGE, 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, HWND_MESSAGE, 0, 0, PM_NOREMOVE );
         break;
     case 20:
         SetEvent( start_event );
         Sleep( 200 );
-        PeekMessage( &msg, GetDesktopWindow(), 0, 0, PM_NOREMOVE );
+        PeekMessageA( &msg, GetDesktopWindow(), 0, 0, PM_NOREMOVE );
         break;
     }
     WaitForSingleObject( end_event, 2000 );
@@ -12835,19 +13173,19 @@ static LRESULT CALLBACK wait_idle_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM l
 
 static DWORD CALLBACK wait_idle_thread( void *arg )
 {
-    WNDCLASS cls;
+    WNDCLASSA cls;
     MSG msg;
     HWND hwnd;
 
     memset( &cls, 0, sizeof(cls) );
     cls.lpfnWndProc   = wait_idle_proc;
     cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
-    cls.hCursor       = LoadCursor(0, IDC_ARROW);
+    cls.hCursor       = LoadCursorA(0, (LPCSTR)IDC_ARROW);
     cls.lpszClassName = "TestClass";
-    RegisterClass( &cls );
+    RegisterClassA( &cls );
 
     hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
-    while (GetMessage( &msg, 0, 0, 0 )) DispatchMessage( &msg );
+    while (GetMessageA( &msg, 0, 0, 0 )) DispatchMessageA( &msg );
     DestroyWindow(hwnd);
     return 0;
 }
@@ -12921,7 +13259,7 @@ static void test_WaitForInputIdle( char *argv0 )
         }
     }
     CloseHandle( start_event );
-    PostThreadMessage( id, WM_QUIT, 0, 0 );
+    PostThreadMessageA( id, WM_QUIT, 0, 0 );
     WaitForSingleObject( thread, 10000 );
     CloseHandle( thread );
 }
@@ -12974,16 +13312,16 @@ static void test_SetParent(void)
     HWND parent1, parent2, child, popup;
     RECT rc, rc_old;
 
-    parent1 = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
+    parent1 = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
                             100, 100, 200, 200, 0, 0, 0, NULL);
     ok(parent1 != 0, "Failed to create parent1 window\n");
 
-    parent2 = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
+    parent2 = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
                             400, 100, 200, 200, 0, 0, 0, NULL);
     ok(parent2 != 0, "Failed to create parent2 window\n");
 
     /* WS_CHILD window */
-    child = CreateWindowEx(0, "TestWindowClass", NULL, WS_CHILD | WS_VISIBLE,
+    child = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD | WS_VISIBLE,
                            10, 10, 150, 150, parent1, 0, 0, NULL);
     ok(child != 0, "Failed to create child window\n");
 
@@ -13013,7 +13351,7 @@ static void test_SetParent(void)
        rc.left, rc.top, rc.right, rc.bottom );
 
     /* WS_POPUP window */
-    popup = CreateWindowEx(0, "TestWindowClass", NULL, WS_POPUP | WS_VISIBLE,
+    popup = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP | WS_VISIBLE,
                            20, 20, 100, 100, 0, 0, 0, NULL);
     ok(popup != 0, "Failed to create popup window\n");
 
@@ -13075,7 +13413,7 @@ static void test_keyflags(void)
     BYTE keyboard_state[256];
     MSG msg;
 
-    test_window = CreateWindowEx(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+    test_window = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                            100, 100, 200, 200, 0, 0, 0, NULL);
 
     flush_events();
@@ -13083,8 +13421,8 @@ static void test_keyflags(void)
 
     /* keyup without a keydown */
     keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmKeyReleaseOnly, "key release only", TRUE);
 
     key_state = GetAsyncKeyState(0x41);
@@ -13095,8 +13433,8 @@ static void test_keyflags(void)
 
     /* keydown */
     keybd_event(0x41, 0, 0, 0);
-    while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmKeyPressNormal, "key press only", FALSE);
 
     key_state = GetAsyncKeyState(0x41);
@@ -13107,8 +13445,8 @@ static void test_keyflags(void)
 
     /* keydown repeat */
     keybd_event(0x41, 0, 0, 0);
-    while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmKeyPressRepeat, "key press repeat", FALSE);
 
     key_state = GetAsyncKeyState(0x41);
@@ -13119,8 +13457,8 @@ static void test_keyflags(void)
 
     /* keyup */
     keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmKeyReleaseNormal, "key release repeat", FALSE);
 
     key_state = GetAsyncKeyState(0x41);
@@ -13139,8 +13477,8 @@ static void test_keyflags(void)
 
     /* keydown */
     keybd_event(0x41, 0, 0, 0);
-    while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmKeyPressRepeat, "key press after setkeyboardstate", TRUE);
 
     key_state = GetAsyncKeyState(0x41);
@@ -13159,8 +13497,8 @@ static void test_keyflags(void)
 
     /* keyup */
     keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmKeyReleaseOnly, "key release after setkeyboardstate", TRUE);
 
     key_state = GetAsyncKeyState(0x41);
@@ -13284,7 +13622,7 @@ static void test_hotkey(void)
         return;
     }
 
-    test_window = CreateWindowEx(0, "HotkeyWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+    test_window = CreateWindowExA(0, "HotkeyWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                            100, 100, 200, 200, 0, 0, 0, NULL);
 
     flush_sequence();
@@ -13318,7 +13656,7 @@ static void test_hotkey(void)
         goto end;
     }
 
-    hKBD_hook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, GetModuleHandle(NULL), 0);
+    hKBD_hook = SetWindowsHookExA(WH_KEYBOARD_LL, KeyboardHookProc, GetModuleHandleA(NULL), 0);
     if (!hKBD_hook) win_skip("WH_KEYBOARD_LL is not supported\n");
 
     /* Same key combination, different id */
@@ -13359,21 +13697,21 @@ static void test_hotkey(void)
 
     /* Inject the appropriate key sequence */
     keybd_event(VK_LWIN, 0, 0, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmHotkeyPressLWIN, "window hotkey press LWIN", FALSE);
 
     keybd_event(hotkey_letter, 0, 0, 0);
     queue_status = GetQueueStatus(QS_HOTKEY);
     ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         if (msg.message == WM_HOTKEY)
         {
             ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
             ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
         }
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyPress, "window hotkey press", FALSE);
 
@@ -13384,40 +13722,40 @@ static void test_hotkey(void)
     ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
 
     keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmHotkeyRelease, "window hotkey release", TRUE);
 
     keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmHotkeyReleaseLWIN, "window hotkey release LWIN", FALSE);
 
     /* normal posted WM_HOTKEY messages set QS_HOTKEY */
-    PostMessage(test_window, WM_HOTKEY, 0, 0);
+    PostMessageA(test_window, WM_HOTKEY, 0, 0);
     queue_status = GetQueueStatus(QS_HOTKEY);
     ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
     queue_status = GetQueueStatus(QS_POSTMESSAGE);
     ok((queue_status & (QS_POSTMESSAGE << 16)) == QS_POSTMESSAGE << 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
     flush_sequence();
 
     /* Send and process all messages at once */
-    PostMessage(test_window, WM_APP, 0, 0);
+    PostMessageA(test_window, WM_APP, 0, 0);
     keybd_event(VK_LWIN, 0, 0, 0);
     keybd_event(hotkey_letter, 0, 0, 0);
     keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
     keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
 
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         if (msg.message == WM_HOTKEY)
         {
             ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
             ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
         }
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyCombined, "window hotkey combined", FALSE);
 
@@ -13431,22 +13769,22 @@ static void test_hotkey(void)
     keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
     keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
 
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
-        DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
+        DispatchMessageA(&msg);
     ok_sequence(WmHotkeyPrevious, "window hotkey previous", FALSE);
 
     /* New key combination works */
     keybd_event(hotkey_letter, 0, 0, 0);
     keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
 
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         if (msg.message == WM_HOTKEY)
         {
             ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
             ok(msg.lParam == MAKELPARAM(0, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
         }
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyNew, "window hotkey new", FALSE);
 
@@ -13467,15 +13805,15 @@ static void test_hotkey(void)
 
     /* Inject the appropriate key sequence */
     keybd_event(VK_LWIN, 0, 0, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyPressLWIN, "thread hotkey press LWIN", FALSE);
 
     keybd_event(hotkey_letter, 0, 0, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         if (msg.message == WM_HOTKEY)
         {
@@ -13491,23 +13829,23 @@ static void test_hotkey(void)
         }
         else
             ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyPress, "thread hotkey press", FALSE);
 
     keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyRelease, "thread hotkey release", TRUE);
 
     keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     {
         ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
-        DispatchMessage(&msg);
+        DispatchMessageA(&msg);
     }
     ok_sequence(WmHotkeyReleaseLWIN, "thread hotkey release LWIN", FALSE);
 
@@ -13564,7 +13902,7 @@ static void test_SetFocus(void)
     HANDLE hthread;
     DWORD ret, tid;
 
-    wnd_event.start_event = CreateEvent(NULL, 0, 0, NULL);
+    wnd_event.start_event = CreateEventW(NULL, 0, 0, NULL);
     ok(wnd_event.start_event != 0, "CreateEvent error %d\n", GetLastError());
     hthread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
     ok(hthread != 0, "CreateThread error %d\n", GetLastError());
@@ -13572,10 +13910,10 @@ static void test_SetFocus(void)
     ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
     CloseHandle(wnd_event.start_event);
 
-    parent = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
+    parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
                             0, 0, 0, 0, 0, 0, 0, NULL);
     ok(parent != 0, "failed to create parent window\n");
-    child = CreateWindowEx(0, "TestWindowClass", NULL, WS_CHILD,
+    child = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
                            0, 0, 0, 0, parent, 0, 0, NULL);
     ok(child != 0, "failed to create child window\n");
 
@@ -13593,14 +13931,14 @@ static void test_SetFocus(void)
     log_all_parent_messages++;
 
     old_focus = SetFocus(child);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmSetFocus_1, "SetFocus on a child window", TRUE);
     ok(old_focus == parent, "expected old focus %p, got %p\n", parent, old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == child, "expected focus %p, got %p\n", child, GetFocus());
 
     old_focus = SetFocus(parent);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmSetFocus_2, "SetFocus on a parent window", FALSE);
     ok(old_focus == child, "expected old focus %p, got %p\n", child, old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13610,7 +13948,7 @@ static void test_SetFocus(void)
     old_focus = SetFocus((HWND)0xdeadbeef);
     ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
        "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetFocus on an invalid window", FALSE);
     ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13620,7 +13958,7 @@ static void test_SetFocus(void)
     old_focus = SetFocus(GetDesktopWindow());
     ok(GetLastError() == ERROR_ACCESS_DENIED /* Vista+ */ ||
        broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetFocus on a desktop window", TRUE);
     ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13630,7 +13968,7 @@ static void test_SetFocus(void)
     old_focus = SetFocus(wnd_event.hwnd);
     ok(GetLastError() == ERROR_ACCESS_DENIED /* Vista+ */ ||
        broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetFocus on another thread window", TRUE);
     ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13640,7 +13978,7 @@ static void test_SetFocus(void)
     old_active = SetActiveWindow((HWND)0xdeadbeef);
     ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
        "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetActiveWindow on an invalid window", FALSE);
     ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13650,7 +13988,7 @@ static void test_SetFocus(void)
     old_active = SetActiveWindow(GetDesktopWindow());
 todo_wine
     ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetActiveWindow on a desktop window", TRUE);
     ok(old_active == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13660,7 +13998,7 @@ todo_wine
     old_active = SetActiveWindow(wnd_event.hwnd);
 todo_wine
     ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetActiveWindow on another thread window", TRUE);
     ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13678,13 +14016,13 @@ todo_wine {
     flush_sequence();
 
     old_focus = SetFocus(wnd_event.hwnd);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(old_focus == wnd_event.hwnd, "expected old focus %p, got %p\n", wnd_event.hwnd, old_focus);
     ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
     ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
 
     old_focus = SetFocus(parent);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(old_focus == parent, "expected old focus %p, got %p\n", parent, old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
@@ -13693,7 +14031,7 @@ todo_wine {
     flush_sequence();
 
     old_active = SetActiveWindow(wnd_event.hwnd);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(old_active == parent, "expected old focus %p, got %p\n", parent, old_active);
     ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
     ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
@@ -13712,7 +14050,7 @@ todo_wine {
     ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
 
     old_focus = SetFocus(parent);
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok(old_focus == parent, "expected old focus %p, got %p\n", parent, old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
@@ -13726,7 +14064,7 @@ todo_wine
     ok(GetLastError() == ERROR_INVALID_PARAMETER /* Vista+ */ ||
        broken(GetLastError() == 0) /* XP */ ||
        broken(GetLastError() == 0xdeadbeef), "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmSetFocus_3, "SetFocus on a child window", TRUE);
     ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13735,7 +14073,7 @@ todo_wine
     SetLastError(0xdeadbeef);
     old_active = SetActiveWindow(child);
     ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
-    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
     ok_sequence(WmEmptySeq, "SetActiveWindow on a child window", FALSE);
     ok(old_active == parent, "expected old active %p, got %p\n", parent, old_active);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
@@ -13746,13 +14084,195 @@ todo_wine
     DestroyWindow(child);
     DestroyWindow(parent);
 
-    ret = PostMessage(wnd_event.hwnd, WM_QUIT, 0, 0);
+    ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
     ok(ret, "PostMessage(WM_QUIT) error %d\n", GetLastError());
     ret = WaitForSingleObject(hthread, INFINITE);
     ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
     CloseHandle(hthread);
 }
 
+static const struct message WmSetLayeredStyle[] = {
+    { WM_STYLECHANGING, sent },
+    { WM_STYLECHANGED, sent },
+    { WM_GETTEXT, sent|defwinproc|optional },
+    { 0 }
+};
+
+static const struct message WmSetLayeredStyle2[] = {
+    { WM_STYLECHANGING, sent },
+    { WM_STYLECHANGED, sent },
+    { WM_WINDOWPOSCHANGING, sent|optional|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
+    { WM_NCCALCSIZE, sent|optional|wparam|defwinproc, 1 },
+    { WM_WINDOWPOSCHANGED, sent|optional|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
+    { WM_MOVE, sent|optional|defwinproc|wparam, 0 },
+    { WM_SIZE, sent|optional|defwinproc|wparam, SIZE_RESTORED },
+    { 0 }
+};
+
+struct layered_window_info
+{
+    HWND   hwnd;
+    HDC    hdc;
+    SIZE   size;
+    HANDLE event;
+    BOOL   ret;
+};
+
+static DWORD CALLBACK update_layered_proc( void *param )
+{
+    struct layered_window_info *info = param;
+    POINT src = { 0, 0 };
+
+    info->ret = pUpdateLayeredWindow( info->hwnd, 0, NULL, &info->size,
+                                      info->hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( info->ret, "failed\n");
+    SetEvent( info->event );
+    return 0;
+}
+
+static void test_layered_window(void)
+{
+    HWND hwnd;
+    HDC hdc;
+    HBITMAP bmp;
+    BOOL ret;
+    SIZE size;
+    POINT pos, src;
+    RECT rect, client;
+    HANDLE thread;
+    DWORD tid;
+    struct layered_window_info info;
+
+    if (!pUpdateLayeredWindow)
+    {
+        win_skip( "UpdateLayeredWindow not supported\n" );
+        return;
+    }
+
+    hdc = CreateCompatibleDC( 0 );
+    bmp = CreateCompatibleBitmap( hdc, 300, 300 );
+    SelectObject( hdc, bmp );
+
+    hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_CAPTION | WS_THICKFRAME | WS_SYSMENU,
+                           100, 100, 300, 300, 0, 0, 0, NULL);
+    ok( hwnd != 0, "failed to create window\n" );
+    ShowWindow( hwnd, SW_SHOWNORMAL );
+    UpdateWindow( hwnd );
+    flush_events();
+    flush_sequence();
+
+    GetWindowRect( hwnd, &rect );
+    GetClientRect( hwnd, &client );
+    ok( client.right < rect.right - rect.left, "wrong client area\n" );
+    ok( client.bottom < rect.bottom - rect.top, "wrong client area\n" );
+
+    src.x = src.y = 0;
+    pos.x = pos.y = 300;
+    size.cx = size.cy = 250;
+    ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
+    ok_sequence( WmSetLayeredStyle, "WmSetLayeredStyle", FALSE );
+
+    ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( ret, "UpdateLayeredWindow failed err %u\n", GetLastError() );
+    ok_sequence( WmEmptySeq, "UpdateLayeredWindow", FALSE );
+    GetWindowRect( hwnd, &rect );
+    ok( rect.left == 300 && rect.top == 300 && rect.right == 550 && rect.bottom == 550,
+        "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+    GetClientRect( hwnd, &rect );
+    ok( rect.right == client.right - 50 && rect.bottom == client.bottom - 50,
+        "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+
+    size.cx = 150;
+    pos.y = 200;
+    ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( ret, "UpdateLayeredWindow failed err %u\n", GetLastError() );
+    ok_sequence( WmEmptySeq, "UpdateLayeredWindow", FALSE );
+    GetWindowRect( hwnd, &rect );
+    ok( rect.left == 300 && rect.top == 200 && rect.right == 450 && rect.bottom == 450,
+        "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+    GetClientRect( hwnd, &rect );
+    ok( rect.right == client.right - 150 && rect.bottom == client.bottom - 50,
+        "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+
+    SetWindowLongA( hwnd, GWL_STYLE,
+                   GetWindowLongA(hwnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU) );
+    ok_sequence( WmSetLayeredStyle2, "WmSetLayeredStyle2", FALSE );
+
+    size.cx = 200;
+    pos.x = 200;
+    ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( ret, "UpdateLayeredWindow failed err %u\n", GetLastError() );
+    ok_sequence( WmEmptySeq, "UpdateLayeredWindow", FALSE );
+    GetWindowRect( hwnd, &rect );
+    ok( rect.left == 200 && rect.top == 200 && rect.right == 400 && rect.bottom == 450,
+        "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+    GetClientRect( hwnd, &rect );
+    ok( (rect.right == 200 && rect.bottom == 250) ||
+        broken(rect.right == client.right - 100 && rect.bottom == client.bottom - 50),
+        "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+
+    size.cx = 0;
+    ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(ERROR_MR_MID_NOT_FOUND) /* win7 */,
+        "wrong error %u\n", GetLastError() );
+    size.cx = 1;
+    size.cy = -1;
+    ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
+    ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+
+    SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED );
+    ok_sequence( WmSetLayeredStyle, "WmSetLayeredStyle", FALSE );
+    GetWindowRect( hwnd, &rect );
+    ok( rect.left == 200 && rect.top == 200 && rect.right == 400 && rect.bottom == 450,
+        "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+    GetClientRect( hwnd, &rect );
+    ok( (rect.right == 200 && rect.bottom == 250) ||
+        broken(rect.right == client.right - 100 && rect.bottom == client.bottom - 50),
+        "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+
+    SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
+    info.hwnd = hwnd;
+    info.hdc = hdc;
+    info.size.cx = 250;
+    info.size.cy = 300;
+    info.event = CreateEventA( NULL, TRUE, FALSE, NULL );
+    info.ret = FALSE;
+    thread = CreateThread( NULL, 0, update_layered_proc, &info, 0, &tid );
+    ok( WaitForSingleObject( info.event, 1000 ) == 0, "wait failed\n" );
+    ok( info.ret, "UpdateLayeredWindow failed in other thread\n" );
+    WaitForSingleObject( thread, 1000 );
+    CloseHandle( thread );
+    GetWindowRect( hwnd, &rect );
+    ok( rect.left == 200 && rect.top == 200 && rect.right == 450 && rect.bottom == 500,
+        "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+    GetClientRect( hwnd, &rect );
+    ok( (rect.right == 250 && rect.bottom == 300) ||
+        broken(rect.right == client.right - 50 && rect.bottom == client.bottom),
+        "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
+
+    DestroyWindow( hwnd );
+    DeleteDC( hdc );
+    DeleteObject( bmp );
+}
+
+static void init_funcs(void)
+{
+    HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
+
+#define X(f) p##f = (void*)GetProcAddress(hKernel32, #f)
+    X(ActivateActCtx);
+    X(CreateActCtxW);
+    X(DeactivateActCtx);
+    X(GetCurrentActCtx);
+    X(ReleaseActCtx);
+#undef X
+}
+
 START_TEST(msg)
 {
     char **test_argv;
@@ -13760,8 +14280,11 @@ START_TEST(msg)
     BOOL (WINAPI *pIsWinEventHookInstalled)(DWORD)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
     HMODULE hModuleImm32;
     BOOL (WINAPI *pImmDisableIME)(DWORD);
+    int argc;
 
-    int argc = winetest_get_mainargs( &test_argv );
+    init_funcs();
+
+    argc = winetest_get_mainargs( &test_argv );
     if (argc >= 3)
     {
         unsigned int arg;
@@ -13771,9 +14294,10 @@ START_TEST(msg)
         return;
     }
 
+    InitializeCriticalSection( &sequence_cs );
     init_procs();
 
-    hModuleImm32 = LoadLibrary("imm32.dll");
+    hModuleImm32 = LoadLibraryA("imm32.dll");
     if (hModuleImm32) {
         pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME");
         if (pImmDisableIME)
@@ -13806,7 +14330,6 @@ START_TEST(msg)
     test_winevents();
 
     /* Fix message sequences before removing 4 lines below */
-#if 1
     if (pUnhookWinEvent && hEvent_hook)
     {
         ret = pUnhookWinEvent(hEvent_hook);
@@ -13814,7 +14337,6 @@ START_TEST(msg)
         pUnhookWinEvent = 0;
     }
     hEvent_hook = 0;
-#endif
 
     test_SetFocus();
     test_SetParent();
@@ -13835,6 +14357,9 @@ START_TEST(msg)
     test_combobox_messages();
     test_wmime_keydown_message();
     test_paint_messages();
+    if(!winetest_interactive)
+    skip("ReactOS ActivateActCtx seems to be broken.\n");
+    else
     test_interthread_messages();
     test_message_conversion();
     test_accelerators();
@@ -13859,12 +14384,14 @@ START_TEST(msg)
     test_EndDialog();
     test_nullCallback();
     test_dbcs_wm_char();
+    test_unicode_wm_char();
     test_menu_messages();
     test_paintingloop();
     test_defwinproc();
     test_clipboard_viewers();
     test_keyflags();
     test_hotkey();
+    test_layered_window();
     /* keep it the last test, under Windows it tends to break the tests
      * which rely on active/foreground windows being correct.
      */
@@ -13881,4 +14408,5 @@ START_TEST(msg)
           GetLastError() == 0xdeadbeef, /* Win9x */
            "unexpected error %d\n", GetLastError());
     }
+    DeleteCriticalSection( &sequence_cs );
 }