         over set-WNDCLASSEX-hIcon
         f IDC_ARROW LoadCursor over set-WNDCLASSEX-hCursor
 
-        class-name-ptr get-global over set-WNDCLASSEX-lpszClassName
-        RegisterClassEx dup win32-error=0/f
-    ] when ;
+        class-name-ptr over set-WNDCLASSEX-lpszClassName
+        RegisterClassEx win32-error=0/f
+    ] [ drop ] if ;
 
 : adjust-RECT ( RECT -- )
     style 0 ex-style AdjustWindowRectEx win32-error=0/f ;

        [ DispatchMessage drop ] bi
    ] if ;

: register-wndclassex ( -- class )
    "WNDCLASSEX" <c-object>
    f GetModuleHandle
    class-name-ptr get-global
    pick GetClassInfoEx zero? [
        "WNDCLASSEX" heap-size over set-WNDCLASSEX-cbSize
        { CS_HREDRAW CS_VREDRAW CS_OWNDC } flags over set-WNDCLASSEX-style
        ui-wndproc over set-WNDCLASSEX-lpfnWndProc

    dup adjust-RECT
    swap [ dup default-position-RECT ] when ;

: get-window-class ( -- class-name )
    class-name-ptr [
        dup expired? [ drop "Factor-window" utf16n malloc-string ] when
        dup register-window-class
        dup
    ] change-global ;

: create-window ( rect -- hwnd )
    make-adjusted-RECT
    [ get-window-class f ] dip
    [
        [ ex-style ] 2dip
        { WS_CLIPSIBLINGS WS_CLIPCHILDREN style } flags
