;; w32message.scm ;; Window Message definitions, ;; plus the symbolic-case macro for using them conveniently within a Scheme wndproc. ;; ;; I cobbled these definitions from NT. They may not exist on CE. (define WM_NULL #x0000) (define WM_CREATE #x0001) (define WM_DESTROY #x0002) (define WM_MOVE #x0003) (define WM_SIZE #x0005) (define WM_ACTIVATE #x0006) (define WA_INACTIVE 0) (define WA_ACTIVE 1) (define WA_CLICKACTIVE 2) (define WM_SETFOCUS #x0007) (define WM_KILLFOCUS #x0008) (define WM_ENABLE #x000A) (define WM_SETREDRAW #x000B) (define WM_SETTEXT #x000C) (define WM_GETTEXT #x000D) (define WM_GETTEXTLENGTH #x000E) (define WM_PAINT #x000F) (define WM_CLOSE #x0010) (define WM_QUERYENDSESSION #x0011) (define WM_QUIT #x0012) (define WM_QUERYOPEN #x0013) (define WM_ERASEBKGND #x0014) (define WM_SYSCOLORCHANGE #x0015) (define WM_ENDSESSION #x0016) (define WM_SHOWWINDOW #x0018) (define WM_WININICHANGE #x001A) (define WM_SETTINGCHANGE WM_WININICHANGE) (define WM_DEVMODECHANGE #x001B) (define WM_ACTIVATEAPP #x001C) (define WM_FONTCHANGE #x001D) (define WM_TIMECHANGE #x001E) (define WM_CANCELMODE #x001F) (define WM_SETCURSOR #x0020) (define WM_MOUSEACTIVATE #x0021) (define WM_CHILDACTIVATE #x0022) (define WM_QUEUESYNC #x0023) (define WM_GETMINMAXINFO #x0024) (define WM_PAINTICON #x0026) (define WM_ICONERASEBKGND #x0027) (define WM_NEXTDLGCTL #x0028) (define WM_SPOOLERSTATUS #x002A) (define WM_DRAWITEM #x002B) (define WM_MEASUREITEM #x002C) (define WM_DELETEITEM #x002D) (define WM_VKEYTOITEM #x002E) (define WM_CHARTOITEM #x002F) (define WM_SETFONT #x0030) (define WM_GETFONT #x0031) (define WM_SETHOTKEY #x0032) (define WM_GETHOTKEY #x0033) (define WM_QUERYDRAGICON #x0037) (define WM_COMPAREITEM #x0039) (define WM_COMPACTING #x0041) (define WM_WINDOWPOSCHANGING #x0046) (define WM_WINDOWPOSCHANGED #x0047) (define WM_POWER #x0048) (define PWR_OK 1) (define PWR_FAIL -1) (define PWR_SUSPENDREQUEST 1) (define PWR_SUSPENDRESUME 2) (define PWR_CRITICALRESUME 3) (define WM_COPYDATA #x004A) (define WM_CANCELJOURNAL #x004B) (define WM_NOTIFY #x004E) (define WM_INPUTLANGCHANGEREQUEST #x0050) (define WM_INPUTLANGCHANGE #x0051) (define WM_TCARD #x0052) (define WM_HELP #x0053) (define WM_USERCHANGED #x0054) (define WM_NOTIFYFORMAT #x0055) (define NFR_ANSI 1) (define NFR_UNICODE 2) (define NF_QUERY 3) (define NF_REQUERY 4) (define WM_CONTEXTMENU #x007B) (define WM_STYLECHANGING #x007C) (define WM_STYLECHANGED #x007D) (define WM_DISPLAYCHANGE #x007E) (define WM_GETICON #x007F) (define WM_SETICON #x0080) (define ICON_SMALL 0) (define ICON_BIG 1) (define WM_NCCREATE #x0081) (define WM_NCDESTROY #x0082) (define WM_NCCALCSIZE #x0083) (define WM_NCHITTEST #x0084) (define WM_NCPAINT #x0085) (define WM_NCACTIVATE #x0086) (define WM_GETDLGCODE #x0087) (define WM_NCMOUSEMOVE #x00A0) (define WM_NCLBUTTONDOWN #x00A1) (define WM_NCLBUTTONUP #x00A2) (define WM_NCLBUTTONDBLCLK #x00A3) (define WM_NCRBUTTONDOWN #x00A4) (define WM_NCRBUTTONUP #x00A5) (define WM_NCRBUTTONDBLCLK #x00A6) (define WM_NCMBUTTONDOWN #x00A7) (define WM_NCMBUTTONUP #x00A8) (define WM_NCMBUTTONDBLCLK #x00A9) (define WM_KEYFIRST #x0100) (define WM_KEYDOWN #x0100) (define WM_KEYUP #x0101) (define WM_CHAR #x0102) (define WM_DEADCHAR #x0103) (define WM_SYSKEYDOWN #x0104) (define WM_SYSKEYUP #x0105) (define WM_SYSCHAR #x0106) (define WM_SYSDEADCHAR #x0107) (define WM_KEYLAST #x0108) (define WM_IME_STARTCOMPOSITION #x010D) (define WM_IME_ENDCOMPOSITION #x010E) (define WM_IME_COMPOSITION #x010F) (define WM_IME_KEYLAST #x010F) (define WM_INITDIALOG #x0110) (define WM_COMMAND #x0111) (define WM_SYSCOMMAND #x0112) (define WM_TIMER #x0113) (define WM_HSCROLL #x0114) (define WM_VSCROLL #x0115) (define WM_INITMENU #x0116) (define WM_INITMENUPOPUP #x0117) (define WM_MENUSELECT #x011F) (define WM_MENUCHAR #x0120) (define WM_ENTERIDLE #x0121) (define WM_CTLCOLORMSGBOX #x0132) (define WM_CTLCOLOREDIT #x0133) (define WM_CTLCOLORLISTBOX #x0134) (define WM_CTLCOLORBTN #x0135) (define WM_CTLCOLORDLG #x0136) (define WM_CTLCOLORSCROLLBAR #x0137) (define WM_CTLCOLORSTATIC #x0138) (define WM_MOUSEFIRST #x0200) (define WM_MOUSEMOVE #x0200) (define WM_LBUTTONDOWN #x0201) (define WM_LBUTTONUP #x0202) (define WM_LBUTTONDBLCLK #x0203) (define WM_RBUTTONDOWN #x0204) (define WM_RBUTTONUP #x0205) (define WM_RBUTTONDBLCLK #x0206) (define WM_MBUTTONDOWN #x0207) (define WM_MBUTTONUP #x0208) (define WM_MBUTTONDBLCLK #x0209) (define WM_MOUSELAST #x0209) (define WM_PARENTNOTIFY #x0210) (define MENULOOP_WINDOW 0) (define MENULOOP_POPUP 1) (define WM_ENTERMENULOOP #x0211) (define WM_EXITMENULOOP #x0212) (define WM_NEXTMENU #x0213) (define WM_SIZING #x0214) (define WM_CAPTURECHANGED #x0215) (define WM_MOVING #x0216) (define WM_POWERBROADCAST #x0218) (define WM_DEVICECHANGE #x0219) (define WM_IME_SETCONTEXT #x0281) (define WM_IME_NOTIFY #x0282) (define WM_IME_CONTROL #x0283) (define WM_IME_COMPOSITIONFULL #x0284) (define WM_IME_SELECT #x0285) (define WM_IME_CHAR #x0286) (define WM_IME_KEYDOWN #x0290) (define WM_IME_KEYUP #x0291) (define WM_MDICREATE #x0220) (define WM_MDIDESTROY #x0221) (define WM_MDIACTIVATE #x0222) (define WM_MDIRESTORE #x0223) (define WM_MDINEXT #x0224) (define WM_MDIMAXIMIZE #x0225) (define WM_MDITILE #x0226) (define WM_MDICASCADE #x0227) (define WM_MDIICONARRANGE #x0228) (define WM_MDIGETACTIVE #x0229) (define WM_MDISETMENU #x0230) (define WM_ENTERSIZEMOVE #x0231) (define WM_EXITSIZEMOVE #x0232) (define WM_DROPFILES #x0233) (define WM_MDIREFRESHMENU #x0234) (define WM_MOUSEHOVER #x02A1) (define WM_MOUSELEAVE #x02A3) (define WM_CUT #x0300) (define WM_COPY #x0301) (define WM_PASTE #x0302) (define WM_CLEAR #x0303) (define WM_UNDO #x0304) (define WM_RENDERFORMAT #x0305) (define WM_RENDERALLFORMATS #x0306) (define WM_DESTROYCLIPBOARD #x0307) (define WM_DRAWCLIPBOARD #x0308) (define WM_PAINTCLIPBOARD #x0309) (define WM_VSCROLLCLIPBOARD #x030A) (define WM_SIZECLIPBOARD #x030B) (define WM_ASKCBFORMATNAME #x030C) (define WM_CHANGECBCHAIN #x030D) (define WM_HSCROLLCLIPBOARD #x030E) (define WM_QUERYNEWPALETTE #x030F) (define WM_PALETTEISCHANGING #x0310) (define WM_PALETTECHANGED #x0311) (define WM_HOTKEY #x0312) (define WM_PRINT #x0317) (define WM_PRINTCLIENT #x0318) (define WM_HANDHELDFIRST #x0358) (define WM_HANDHELDLAST #x035F) (define WM_AFXFIRST #x0360) (define WM_AFXLAST #x037F) (define WM_PENWINFIRST #x0380) (define WM_PENWINLAST #x038F) (define WM_NETCONNECT #x03FE) (define WM_HIBERNATE #x03FF) (define WM_USER #x0400) (define WM_APP #x8000) ;; The symbolic-case macro allows use of the preceding symbolic window message constants ;; within a wndproc's case form. ;; E.g. ;(lambda (hwnd msg wparam lparam) ; (symbolic-case msg ; ((WM_CREATE) (display "WM_CREATE") (newline) 0) ; ((WM_DESTROY) (display "WM_DESTROY") (newline) 0) ; (else (DefWindowProc hwnd msg wparam lparam)))) (define-macro (symbolic-case key . clauses) (define (process-clause clause) (if (not (pair? (car clause))) clause (cons (map (lambda (x) (if (symbol? x) (eval x) x)) (car clause)) (cdr clause)))) `(case ,key ,@(map process-clause clauses))) ;; Another way to do this is with a read evaluator macro ;(lambda (hwnd msg wparam lparam) ; (case msg ; ((#.WM_CREATE) (display "WM_CREATE") (newline) 0) ; ((#.WM_DESTROY) (display "WM_DESTROY") (newline) 0) ; (else (DefWindowProc hwnd msg wparam lparam))))