I used this to center a window and display a jpeg.

The pic dimensions are 183 x 170 but I had to increase those to display the whole pic in
the window.

Is there a way to avoid that?


;    Center the window
;      Values from Paint info    width of anti.jpg = 183
;                                          height              = 170
      mov Wwd,190 ;183          width     
      mov Wht, 205    ; orig. 170 height

      invoke GetSystemMetrics,SM_CXSCREEN
      invoke TopXY,Wwd,eax
      mov Wtx, eax

      invoke GetSystemMetrics,SM_CYSCREEN
      invoke TopXY,Wht,eax
      mov Wty, eax

  invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR ClassName,
                            ADDR AppName,
                            WS_OVERLAPPED or WS_SYSMENU,
                            Wtx,Wty,Wwd,Wht,
                            NULL,NULL,
                            hInst,NULL

Posted on 2010-09-24 12:17:09 by skywalker
skywalker,

Looks like you forgot about window's non-client area (borders, title, menu, etc.). AdjustWindowRect() can be used to calculate desired window rectangle for given client area size.
Posted on 2010-09-24 15:50:14 by baldr