2

I recently discovered how on Windows in emacs elisp I can maximize an emacs frame: How do I set the size of Emacs' window?.

(defun w32-maximize-frame ()
  "Maximize the current frame"
  (interactive)
  (w32-send-sys-command 61488))

What I would prefer to do is have my emacs window "snap" to it's maximum vertical size using Windows 7 "snap" feature.

(defun w32-snap-max-vertical-frame ()
  "Maximize the vertical size of the current frame"
  (interactive)
  ; insert magic here
  )

Is there a similar windows message I can send to any window, or my emacs window to have it snap to maximum vertical size?

(As a start, I can google that 61488 above is 0xF300 and corresponds to WM_SYSCOMMAND SC_MAXIMIZE which is an entry in a window's system menu, and "snap to vertical" is not in that menu, so I don't think it would occur through a WM_SYSCOMMAND message....)

Community
  • 1
  • 1
Jerry Asher
  • 836
  • 2
  • 10
  • 23

2 Answers2

2

According to this blog post, you need to execute:

PostMessage(hwndTarget, WM_NCLBUTTONDBLCLK, HTTOP, 0);

I had a look, but it looks like emacs doesn't have a w32-send-mesage equivalent. If you do find one, WM_NCLBUTTONDBLCLK is 163, and HTTOP is 12.

vhallac
  • 13,301
  • 3
  • 25
  • 36
1

Not sure what you're asking. You speak of both Emacs frames and Emacs windows, but I still somehow get the impression that perhaps you really mean that you want to maximize a frame but in the vertical directon only. Is that right?

If so, see command maximize-frame-vertically in frame-cmds.el. There are also commands maximize-frame-horizontally and maximize-frame, and commands to restore the frame to its sizes (vertical, horizontal, or both) before maximizing.

Drew
  • 29,895
  • 7
  • 74
  • 104
  • That was very useful, and will probably suffice. It's slightly different that what I want, but hey, I'll take it, thank you. "Windows Snap" has a very nice property in that I have two different monitors of differing vertical heights, and a snapped window when it moves from monitor to monitor will re-adjust its height to fit each window maximally. – Jerry Asher Jan 01 '12 at 23:00