Moved the dp before window creation so dimensions could be obtained