Title: Monitor Power, Disabling Close/X, Flash Window, Always on Top, Caption Drag/Resize
Question: How can I?:
Turn the Monitor Power on or off
Disable the X and Close in the sysmenu
Flash Window's titlebar
change Always on Top status
Drag windows around like the titlebar
Resize windows like grabbing the edge
Send an Email
Answer:
// Turn the power to the monitor off and on:
// Power Off Monitor(s)
Sendmessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
// Power On Monitor(s)
Sendmessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
// Toggle the ability to close the form through Windows GUI:
// Disable the X and Sysmenu | Close
EnableMenuItem(GetSystemMenu(Handle, False), SC_CLOSE, MF_BYCOMMAND + MF_GRAYED);
// Enable the X and Sysmenu | Close
EnableMenuItem(GetSystemMenu(Handle, False), SC_CLOSE, MF_BYCOMMAND + MF_NORMAL);
Changing this makes the window active. If anyone knows a way to check this status please email me.
// Delphi flashes the window to change Always on Top, I don't:
// Enable Always On Top
SetWindowPos(Handle, HWND_TopMost, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
// Disable Always On Top
SetWindowPos(Handle, HWND_NoTopMost, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
// Moving/Resizing a Window:
on MouseDown of any control
if Button mbLeft then Exit
ReleaseCapture; //restore mouse input so Windows can have it.
SendMessage(Form.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0) // Move
SendMessage(Form.Handle, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, 0) // Resize
// TopRight, BottomRight, TopLeft, BottomLeft
// Send and Email
ShellExecute(0, 'open', 'mailto:me@my.com?subject=put in a subject here', nil, nil, SW_SHOWNORMAL);