Print thread ids in traces with only 4 digits now that they are small
integers.

diff --git a/dlls/msvcrt/main.c b/dlls/msvcrt/main.c
index 82eabab..b5c55bc 100644
--- a/dlls/msvcrt/main.c
+++ b/dlls/msvcrt/main.c
@@ -43,9 +43,9 @@
 {
   MSVCRT_thread_data *tls;
 
-  TRACE("(%p, %s, %p) pid(%ld), tid(%ld), tls(%ld)\n",
+  TRACE("(%p, %s, %p) pid(%lx), tid(%lx), tls(%ld)\n",
         hinstDLL, msvcrt_get_reason(fdwReason), lpvReserved,
-        (long)GetCurrentProcessId(), (long)GetCurrentThreadId(),
+        GetCurrentProcessId(), GetCurrentThreadId(),
         (long)MSVCRT_tls_index);
 
   switch (fdwReason)
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index a0e9710..3b29f5b 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -117,12 +117,12 @@
         {
             const char *name = (char *)crit->DebugInfo;
             if (!name) name = "?";
-            ERR( "section %p %s wait timed out, retrying (60 sec) tid=%08lx\n",
+            ERR( "section %p %s wait timed out, retrying (60 sec) tid=%04lx\n",
                  crit, debugstr_a(name), GetCurrentThreadId() );
             res = WaitForSingleObject( sem, 60000L );
             if ( res == WAIT_TIMEOUT && TRACE_ON(relay) )
             {
-                ERR( "section %p %s wait timed out, retrying (5 min) tid=%08lx\n",
+                ERR( "section %p %s wait timed out, retrying (5 min) tid=%04lx\n",
                      crit, debugstr_a(name), GetCurrentThreadId() );
                 res = WaitForSingleObject( sem, 300000L );
             }
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c
index 90d1a08..3cb26f7 100644
--- a/dlls/ntdll/debugtools.c
+++ b/dlls/ntdll/debugtools.c
@@ -307,7 +307,7 @@
     int ret = 0;
 
     if (TRACE_ON(tid))
-        ret = wine_dbg_printf( "%08lx:", NtCurrentTeb()->tid );
+        ret = wine_dbg_printf( "%04lx:", NtCurrentTeb()->tid );
     if (cls < sizeof(classes)/sizeof(classes[0]))
         ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function );
     if (format)
diff --git a/dlls/user/hook.c b/dlls/user/hook.c
index 6d237ff..7dacc47 100644
--- a/dlls/user/hook.c
+++ b/dlls/user/hook.c
@@ -228,7 +228,7 @@
     LRESULT ret;
 
     if (TRACE_ON(relay))
-        DPRINTF( "%08lx:Call hook proc %p (id=%s,code=%x,wp=%08x,lp=%08lx)\n",
+        DPRINTF( "%04lx:Call hook proc %p (id=%s,code=%x,wp=%08x,lp=%08lx)\n",
                  GetCurrentThreadId(), proc, hook_names[id-WH_MINHOOK], code, wparam, lparam );
 
     if (!prev_unicode == !next_unicode) ret = proc( code, wparam, lparam );
@@ -236,7 +236,7 @@
     else ret = call_hook_AtoW( proc, id, code, wparam, lparam );
 
     if (TRACE_ON(relay))
-        DPRINTF( "%08lx:Ret  hook proc %p (id=%s,code=%x,wp=%08x,lp=%08lx) retval=%08lx\n",
+        DPRINTF( "%04lx:Ret  hook proc %p (id=%s,code=%x,wp=%08x,lp=%08lx) retval=%08lx\n",
                  GetCurrentThreadId(), proc, hook_names[id-WH_MINHOOK], code, wparam, lparam, ret );
 
     return ret;
diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c
index fb7d332..94262fc 100644
--- a/graphics/x11drv/dib.c
+++ b/graphics/x11drv/dib.c
@@ -5464,7 +5464,7 @@
   INT ret = DIB_Status_None;
 
   if (dib) {
-    TRACE("Locking %p from thread %08lx\n", bmp, GetCurrentThreadId());
+    TRACE("Locking %p from thread %04lx\n", bmp, GetCurrentThreadId());
     EnterCriticalSection(&(dib->lock));
     ret = dib->status;
     if (req != DIB_Status_None)
diff --git a/if1632/relay.c b/if1632/relay.c
index f038f5d..39c4665 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -254,7 +254,7 @@
     call = get_entry_point( frame, funstr, &ordinal );
     if (!call) return; /* happens for the two snoop register relays */
     if (!RELAY_ShowDebugmsgRelay(funstr)) return;
-    DPRINTF( "%08lx:Call %s(",GetCurrentThreadId(),funstr);
+    DPRINTF( "%04lx:Call %s(",GetCurrentThreadId(),funstr);
     VA_START16( args16 );
 
     if (call->lret == 0xcb66)  /* cdecl */
@@ -364,7 +364,7 @@
     call = get_entry_point( frame, funstr, &ordinal );
     if (!call) return;
     if (!RELAY_ShowDebugmsgRelay(funstr)) return;
-    DPRINTF( "%08lx:Ret  %s() ",GetCurrentThreadId(),funstr);
+    DPRINTF( "%04lx:Ret  %s() ",GetCurrentThreadId(),funstr);
 
     if (call->arg_types[0] & ARG_REGISTER)
     {
@@ -412,7 +412,7 @@
     {
         CONTEXT86 *context = (CONTEXT86 *)target;
 
-        DPRINTF("%08lx:CallTo16(func=%04lx:%04x,ds=%04lx",
+        DPRINTF("%04lx:CallTo16(func=%04lx:%04x,ds=%04lx",
                 GetCurrentThreadId(),
                 context->SegCs, LOWORD(context->Eip), context->SegDs );
         while (nb_args--) DPRINTF( ",%04x", *--stack16 );
@@ -425,7 +425,7 @@
     }
     else
     {
-        DPRINTF("%08lx:CallTo16(func=%04x:%04x,ds=%04x",
+        DPRINTF("%04lx:CallTo16(func=%04x:%04x,ds=%04x",
                 GetCurrentThreadId(),
                 HIWORD(target), LOWORD(target), SELECTOROF(teb->cur_stack) );
         while (nb_args--) DPRINTF( ",%04x", *--stack16 );
@@ -446,7 +446,7 @@
 
     if (!reg_func)
     {
-        DPRINTF("%08lx:RetFrom16() ss:sp=%04x:%04x retval=%08x\n",
+        DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x retval=%08x\n",
                 GetCurrentThreadId(),
                 SELECTOROF(NtCurrentTeb()->cur_stack),
                 OFFSETOF(NtCurrentTeb()->cur_stack), ret_val);
@@ -455,7 +455,7 @@
     {
         CONTEXT86 *context = (CONTEXT86 *)ret_val;
 
-        DPRINTF("%08lx:RetFrom16() ss:sp=%04x:%04x ",
+        DPRINTF("%04lx:RetFrom16() ss:sp=%04x:%04x ",
                 GetCurrentThreadId(),
                 SELECTOROF(NtCurrentTeb()->cur_stack),
                 OFFSETOF(NtCurrentTeb()->cur_stack));
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 81c1567..f6908ec 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -624,11 +624,11 @@
     {
         DLLENTRYPROC entry = (void*)((char*)module + nt->OptionalHeader.AddressOfEntryPoint);
         if (TRACE_ON(relay))
-            DPRINTF("%08lx:Call PE DLL (proc=%p,module=%p,type=%ld,res=%p)\n",
+            DPRINTF("%04lx:Call PE DLL (proc=%p,module=%p,type=%ld,res=%p)\n",
                     GetCurrentThreadId(), entry, module, type, lpReserved );
         retv = entry( module, type, lpReserved );
         if (TRACE_ON(relay))
-            DPRINTF("%08lx:Ret  PE DLL (proc=%p,module=%p,type=%ld,res=%p) retval=%x\n",
+            DPRINTF("%04lx:Ret  PE DLL (proc=%p,module=%p,type=%ld,res=%p) retval=%x\n",
                     GetCurrentThreadId(), entry, module, type, lpReserved, retv );
     }
 
diff --git a/relay32/relay386.c b/relay32/relay386.c
index 18523c6..e228567 100644
--- a/relay32/relay386.c
+++ b/relay32/relay386.c
@@ -412,7 +412,7 @@
     {
         get_entry_point( buffer, relay );
 
-        DPRINTF( "%08lx:Call %s(", GetCurrentThreadId(), buffer );
+        DPRINTF( "%04lx:Call %s(", GetCurrentThreadId(), buffer );
         RELAY_PrintArgs( args, nb_args, relay->argtypes );
         DPRINTF( ") ret=%08x\n", ret_addr );
     }
@@ -430,11 +430,11 @@
     {
         BOOL ret64 = (relay->argtypes & 0x80000000) && (nb_args < 16);
         if (ret64)
-            DPRINTF( "%08lx:Ret  %s() retval=%08x%08x ret=%08x\n",
+            DPRINTF( "%04lx:Ret  %s() retval=%08x%08x ret=%08x\n",
                      GetCurrentThreadId(),
                      buffer, (UINT)(ret >> 32), (UINT)ret, ret_addr );
         else
-            DPRINTF( "%08lx:Ret  %s() retval=%08x ret=%08x\n",
+            DPRINTF( "%04lx:Ret  %s() retval=%08x ret=%08x\n",
                      GetCurrentThreadId(),
                      buffer, (UINT)ret, ret_addr );
     }
@@ -478,7 +478,7 @@
     {
         get_entry_point( buffer, relay );
 
-        DPRINTF( "%08lx:Call %s(", GetCurrentThreadId(), buffer );
+        DPRINTF( "%04lx:Call %s(", GetCurrentThreadId(), buffer );
         RELAY_PrintArgs( args, nb_args, relay->argtypes );
         DPRINTF( ") ret=%08lx fs=%04lx\n", context->Eip, context->SegFs );
 
@@ -505,7 +505,7 @@
 
     if (TRACE_ON(relay))
     {
-        DPRINTF( "%08lx:Ret  %s() retval=%08lx ret=%08lx fs=%04lx\n",
+        DPRINTF( "%04lx:Ret  %s() retval=%08lx ret=%08lx fs=%04lx\n",
                  GetCurrentThreadId(),
                  buffer, context->Eax, context->Eip, context->SegFs );
 
diff --git a/relay32/snoop.c b/relay32/snoop.c
index b7007f7..c03b027 100644
--- a/relay32/snoop.c
+++ b/relay32/snoop.c
@@ -315,7 +315,7 @@
 
 	context->Eip = (DWORD)fun->origfun;
 
-	DPRINTF("%08lx:CALL %s.%ld: %s(",GetCurrentThreadId(),dll->name,dll->ordbase+ordinal,fun->name);
+	DPRINTF("%04lx:CALL %s.%ld: %s(",GetCurrentThreadId(),dll->name,dll->ordbase+ordinal,fun->name);
 	if (fun->nrofargs>0) {
 		max = fun->nrofargs; if (max>16) max=16;
 		for (i=0;i<max;i++)
@@ -349,7 +349,7 @@
 	if (ret->args) {
 		int	i,max;
 
-		DPRINTF("%08lx:RET  %s.%ld: %s(",
+		DPRINTF("%04lx:RET  %s.%ld: %s(",
 		        GetCurrentThreadId(),
 		        ret->dll->name,ret->dll->ordbase+ret->ordinal,ret->dll->funs[ret->ordinal].name);
 		max = ret->dll->funs[ret->ordinal].nrofargs;
@@ -365,7 +365,7 @@
 		HeapFree(GetProcessHeap(),0,ret->args);
 		ret->args = NULL;
 	} else
-		DPRINTF("%08lx:RET  %s.%ld: %s() retval = %08lx ret=%08lx\n",
+		DPRINTF("%04lx:RET  %s.%ld: %s() retval = %08lx ret=%08lx\n",
 			GetCurrentThreadId(),
 			ret->dll->name,ret->dll->ordbase+ret->ordinal,ret->dll->funs[ret->ordinal].name,
 			context->Eax, (DWORD)ret->origreturn);
diff --git a/scheduler/thread.c b/scheduler/thread.c
index 1da9f4a..0f595bf 100644
--- a/scheduler/thread.c
+++ b/scheduler/thread.c
@@ -263,7 +263,7 @@
     LPTHREAD_START_ROUTINE func = (LPTHREAD_START_ROUTINE)NtCurrentTeb()->entry_point;
 
     if (TRACE_ON(relay))
-        DPRINTF("%08lx:Starting thread (entryproc=%p)\n", GetCurrentThreadId(), func );
+        DPRINTF("%04lx:Starting thread (entryproc=%p)\n", GetCurrentThreadId(), func );
 
     PROCESS_CallUserSignalProc( USIG_THREAD_INIT, 0 );
     MODULE_DllThreadAttach( NULL );
@@ -886,7 +886,7 @@
  */
 DWORD WINAPI GetCurrentThreadId(void)
 {
-    return (DWORD)NtCurrentTeb()->tid;
+    return NtCurrentTeb()->tid;
 }
 
 #endif  /* __i386__ */
diff --git a/windows/spy.c b/windows/spy.c
index 5e70d45..f17afb6 100644
--- a/windows/spy.c
+++ b/windows/spy.c
@@ -2284,7 +2284,7 @@
             DWORD tid = GetWindowThreadProcessId( hWnd, NULL );
 
             if (tid == GetCurrentThreadId()) strcpy( taskName, "self" );
-            else sprintf( taskName, "tid %08lx", GetCurrentThreadId() );
+            else sprintf( taskName, "tid %04lx", GetCurrentThreadId() );
 
             if (iFlag == SPY_SENDMESSAGE16)
                 TRACE("%*s(%04x) %-16s message [%04x] %s sent from %s wp=%04x lp=%08lx\n",