diff dwt/widgets/Display.d @ 82:43c42c637c9c

First simple example works
author Frank Benoit <benoit@tionex.de>
date Wed, 06 Feb 2008 15:45:27 +0100
parents 1801ddeb8f32
children f353be82b6be
line wrap: on
line diff
--- a/dwt/widgets/Display.d	Wed Feb 06 15:12:11 2008 +0100
+++ b/dwt/widgets/Display.d	Wed Feb 06 15:45:27 2008 +0100
@@ -151,7 +151,7 @@
     //Callback windowCallback;
     //int windowProc_;
     int threadId;
-    TCHAR* windowClass_, windowShadowClass;
+    TCHAR[] windowClass_, windowShadowClass;
     static int WindowClassCount;
     static const char[] WindowName = "SWT_Window"; //$NON-NLS-1$
     static const char[] WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$
@@ -827,6 +827,7 @@
             alphaData = data.alphaData;
             transparentPixel = data.transparentPixel;
             break;
+        default:
     }
     BITMAP bm;
     OS.GetObject (hBitmap, BITMAP.sizeof, &bm);
@@ -878,6 +879,7 @@
                     green = cast(byte)((transparentPixel & 0xFF0000) >> 16);
                     red = cast(byte)((transparentPixel & 0xFF00) >> 8);
                     break;
+                default:
             }
         }
     }
@@ -991,6 +993,7 @@
                     green = cast(byte)((transparentPixel & 0xFF0000) >> 16);
                     red = cast(byte)((transparentPixel & 0xFF00) >> 8);
                     break;
+                default:
             }
         }
     }
@@ -1191,6 +1194,7 @@
             //embeddedProc_ = getMsgProc_ = 0;
             break;
         }
+        default:
     }
     return OS.DefWindowProc (hwnd, msg, wParam, lParam);
 }
@@ -1440,6 +1444,7 @@
             //FALL THROUGH
         case DWT.MouseUp:
             return clickCount;
+        default:
     }
     return 0;
 }
@@ -1997,7 +2002,7 @@
     if (embeddedHwnd is null) {
         auto hInstance = OS.GetModuleHandle (null);
         embeddedHwnd = OS.CreateWindowEx (0,
-            windowClass_,
+            windowClass_.ptr,
             null,
             OS.WS_OVERLAPPED,
             0, 0, 0, 0,
@@ -2027,6 +2032,7 @@
                     //OS.MoveMemory (lParam, msg, MSG.sizeof);
                 }
             }
+            default:
         }
     }
     return OS.CallNextHookEx (msgHook, code, wParam, lParam);
@@ -2156,6 +2162,7 @@
             gc.dispose ();
             return downArrow;
         }
+        default:
     }
     return null;
 }
@@ -2374,6 +2381,7 @@
             auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
             return warningIcon = Image.win32_new (this, DWT.ICON, hIcon);
         }
+        default:
     }
     return null;
 }
@@ -2494,8 +2502,8 @@
     threadId = OS.GetCurrentThreadId ();
 
     /* Use the character encoding for the default locale */
-    windowClass_ = StrToTCHARz ( WindowName ~ to!(char[])(WindowClassCount));
-    windowShadowClass = StrToTCHARz ( WindowShadowName ~ to!(char[])(WindowClassCount));
+    windowClass_ = StrToTCHARs ( 0, WindowName ~ to!(char[])(WindowClassCount), true );
+    windowShadowClass = StrToTCHARs ( 0, WindowShadowName ~ to!(char[])(WindowClassCount), true );
     WindowClassCount++;
 
     /* Register the DWT window class */
@@ -2506,25 +2514,23 @@
     lpWndClass.lpfnWndProc = &windowProcFunc;
     lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;
     lpWndClass.hCursor = OS.LoadCursor (null, cast(wchar*)OS.IDC_ARROW);
-    int len = strlenz( windowClass_ );
-    int byteCount = len * TCHAR.sizeof;
-    lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-    lpWndClass.lpszClassName[ 0 .. len ] = windowClass_[ 0 .. len ];
+    int byteCount = windowClass_.length * TCHAR.sizeof;
+    lpWndClass.lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+    OS.MoveMemory (lpWndClass.lpszClassName, windowClass_.ptr, byteCount);
     OS.RegisterClass (&lpWndClass);
     OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
 
     /* Register the DWT drop shadow window class */
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) lpWndClass.style |= OS.CS_DROPSHADOW;
-    len = strlenz( windowShadowClass );
-    byteCount = len * TCHAR.sizeof;
-    lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-    lpWndClass.lpszClassName[ 0 .. len ] = windowShadowClass[ 0 .. len ];
+    byteCount = windowShadowClass.length * TCHAR.sizeof;
+    lpWndClass.lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+    OS.MoveMemory (lpWndClass.lpszClassName, windowShadowClass.ptr, byteCount);
     OS.RegisterClass (&lpWndClass);
     OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
 
     /* Create the message only HWND */
     hwndMessage = OS.CreateWindowEx (0,
-        windowClass_,
+        windowClass_.ptr,
         null,
         OS.WS_OVERLAPPED,
         0, 0, 0, 0,
@@ -2909,6 +2915,7 @@
                         }
                         break;
                     }
+                    default:
                 }
                 if (!accentKey && !ignoreNextKey) {
                     keyMsg.hwnd = control.handle;
@@ -2937,6 +2944,7 @@
                             }
                         }
                     }
+                    default:
                 }
             }
             if (consumed) {
@@ -3026,6 +3034,7 @@
                 case 1:
                 case OS.SPI_SETHIGHCONTRAST:
                     OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null);
+                default:
             }
             break;
         }
@@ -3134,6 +3143,7 @@
             }
             break;
         }
+        default:
     }
     return OS.CallNextHookEx (filterHook, code, wParam, lParam);
 }
@@ -3156,6 +3166,7 @@
         case OS.VK_SUBTRACT:    return '-';
         case OS.VK_DECIMAL: return '.';
         case OS.VK_DIVIDE:      return '/';
+        default:
     }
     return 0;
 }
@@ -3323,6 +3334,7 @@
             OS.HeapFree (hHeap, 0, pInputs);
             return result;
         }
+        default:
     }
     return false;
 }
@@ -3498,10 +3510,10 @@
     /* Unregister the DWT window class */
     auto hHeap = OS.GetProcessHeap ();
     auto hInstance = OS.GetModuleHandle (null);
-    OS.UnregisterClass (windowClass_, hInstance);
+    OS.UnregisterClass (windowClass_.ptr, hInstance);
 
     /* Unregister the DWT drop shadow window class */
-    OS.UnregisterClass (windowShadowClass, hInstance);
+    OS.UnregisterClass (windowShadowClass.ptr, hInstance);
     windowClass_ = windowShadowClass = null;
     //windowCallback.dispose ();
     //windowCallback = null;
@@ -4310,6 +4322,7 @@
                 default:
             }
             break;
+        default:
     }
     return false;
 }
@@ -4524,7 +4537,7 @@
 }
 
 char[] windowClass(){
-    return TCHARzToStr( windowClass_ );
+    return TCHARsToStr( windowClass_ );
 }
 
 }