Delphi65
-
Content Count
10 -
Joined
-
Last visited
Posts posted by Delphi65
-
-
8 minutes ago, Lars Fosdal said:Which version of Delphi?
I am being very terse, since doing is learning.
- Checkbox.Checked gives you the boolean state of the checkbox
- MemoField.Text returns the text where you have the day
- See https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Date_and_Time_Support for how to compare timestamps
Thank you!
I am using Delphi Berlin.
Yes, my memo gives me the day, and my checkbox tell me if the event is set or not. I have my time edit also which gives me the current time.
I am planning to use a timer to do the checks. If the event is enabled, it will check the day and time and if the enabled day and time matches with the current day and time, it will run the event. I have all the required data, i just need to figure out how to run the event because i need to make sure the current day and time matches with the day and time behind that checkbox which is enabled.
Or if you have any suggestions of how to do this schedule daily at selected time, please shoot me.
-
Dear all,
I am trying to run a schedule as following where i have:
Checkbox (if the schedule is enabled for the day or not, every day has it's own checkbox such as: checkboxMonday, checkboxTuesday etc.)
Time field (edit showing now)
Day field (memo showing the today)
Time field (showing at what time to run the schedule)
Now,
any ideas of how to combine all this inside one procedure?
What i am chasing is something like this:
Procedure Tform1.CollectData; begin if checkboxMonday is checked and memofield is showing "Monday" and TimeNow is equal to TimeMonday then begin CollectData; end else ShowMessage('Event is not scheduled'); end;
Is this possible?
If not, what do i need?
Thanks for all the answers.
-
Thank you to all!
I have done the following and both Turn On/TurnOff works.
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; type TfrmPowerControl = class(TForm) btnOFF: TButton; btnExit: TButton; Label1: TLabel; btnON: TButton; timerTurnOffDisplay: TTimer; procedure btnOFFClick(Sender: TObject); procedure btnONClick(Sender: TObject); procedure btnExitClick(Sender: TObject); procedure timerTurnOffDisplayTimer(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmPowerControl: TfrmPowerControl; implementation {$R *.dfm} const MONITOR_ON = -1; MONITOR_OFF = 2; MONITOR_STANDBY = 1; procedure TfrmPowerControl.btnOFFClick(Sender: TObject); begin PostMessage(HWND_BROADCAST , WM_SYSCOMMAND, SC_MONITORPOWER, 2); end; procedure TfrmPowerControl.btnExitClick(Sender: TObject); begin Close; Application.Terminate; end; procedure TfrmPowerControl.btnONClick(Sender: TObject); begin PostMessage(HWND_BROADCAST , WM_SYSCOMMAND, SC_MONITORPOWER, -1); end; procedure TfrmPowerControl.timerTurnOffDisplayTimer(Sender: TObject); begin //PostMessage(HWND_BROADCAST , WM_SYSCOMMAND, SC_MONITORPOWER, 2); end; end.
-
1 hour ago, DelphiUdIT said:To turn monitor on simply simulate a keypressed:
//Simulate the pression of SHIFT key ... keybd_event(VK_SHIFT, 0, 0, 0); keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
Bye
My problem is that i cannot turn the display off.
Yes, you are correct, it can be turned on by using a key press.
-
1 hour ago, programmerdelphi2k said:my user in Windows is "Local / Adminstrator" by default Win installation!
I have the same, user is the administrator.
-
1 hour ago, PeterBelow said:Have you tried running the code under an admin account? This may be a rights issue, since you are changing a setting that effects all users.
I have tested with two different PC where both were pretty same and both with administrator account.
-
1 hour ago, programmerdelphi2k said:SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
It doesn't work for me. Not with timer nor a button. I also have Windows 10 22H2 64bit
-
30 minutes ago, Uwe Raabe said:Try HWND_BROADCAST instead of Application.Handle
Thanks Uwe!
I have tried it, it has no impact, it doesn't turn the display off.
-
Hi guys,
I have been using the following for earlier version of windows.
Quoteconst MONITOR_ON = -1; MONITOR_OFF = 2; MONITOR_STANDBY = 1;
To turn off the monitor:
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
To turn on the monitor:
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
But this unfortunately no longer works for Windows 10, any idea of how to achieve the same goal on Windows PC?
Many thanks in advance!
How to check and set
in VCL
Posted
Thanks Lars!
Yes, correct, my timer will look up for "Now" and compare.
The events will happen only once a day that could be for example today Wednesday at 20:15. I could however make my timer to check once every 10 minutes. My event time slots are also specific, they will be different for each day.