-
Content Count
1406 -
Joined
-
Last visited
-
Days Won
22
Everything posted by programmerdelphi2k
-
Getting Windows Sleep message, works for some computers but doesn't work for others.
programmerdelphi2k replied to c0d3r's topic in Windows API
my tests if SHUTDOWN type TForm1 = class(TForm) Memo1: TMemo; BtnDisplayTurnOFF: TButton; procedure BtnDisplayTurnOFFClick(Sender: TObject); private { Private declarations } public // WM_QUERYENDSESSION when MSWindows start the "shutdown" or "restart"... procedure MyWMPowerBroadcastMessage(var AMessage: TMessage); message WM_POWERBROADCAST; end; var Form1: TForm1; implementation {$R *.dfm} const MY_MONITOR_OFF = 2; { TForm1 } procedure TForm1.BtnDisplayTurnOFFClick(Sender: TObject); begin SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, MY_MONITOR_OFF); end; procedure TForm1.MyWMPowerBroadcastMessage(var AMessage: TMessage); begin case AMessage.WParam of PBT_APMQUERYSUSPEND: Memo1.Lines.Add('pc was PBT_APMQUERYSUSPEND at ' + DateTimeToStr(now)); PBT_APMQUERYSTANDBY: Memo1.Lines.Add('pc was PBT_APMQUERYSTANDBY at ' + DateTimeToStr(now)); PBT_APMQUERYSUSPENDFAILED: Memo1.Lines.Add('pc was PBT_APMQUERYSUSPENDFAILED at ' + DateTimeToStr(now)); PBT_APMQUERYSTANDBYFAILED: Memo1.Lines.Add('pc was PBT_APMQUERYSTANDBYFAILED at ' + DateTimeToStr(now)); PBT_APMSUSPEND: Memo1.Lines.Add('pc was PBT_APMSUSPEND at ' + DateTimeToStr(now)); PBT_APMSTANDBY: Memo1.Lines.Add('pc was PBT_APMSTANDBY at ' + DateTimeToStr(now)); PBT_APMRESUMECRITICAL: Memo1.Lines.Add('pc was PBT_APMRESUMECRITICAL at ' + DateTimeToStr(now)); PBT_APMRESUMESUSPEND: Memo1.Lines.Add('pc was PBT_APMRESUMESUSPEND at ' + DateTimeToStr(now)); PBT_APMRESUMESTANDBY: Memo1.Lines.Add('pc was PBT_APMRESUMESTANDBY at ' + DateTimeToStr(now)); // PBTF_APMRESUMEFROMFAILURE: = PBT_APMQUERYSTANDBY // Memo1.Lines.Add('pc was PBTF_APMRESUMEFROMFAILURE at ' + DateTimeToStr(now)); PBT_APMBATTERYLOW: Memo1.Lines.Add('pc was PBT_APMBATTERYLOW at ' + DateTimeToStr(now)); PBT_APMPOWERSTATUSCHANGE: Memo1.Lines.Add('pc was PBT_APMPOWERSTATUSCHANGE at ' + DateTimeToStr(now)); PBT_APMOEMEVENT: Memo1.Lines.Add('pc was PBT_APMOEMEVENT at ' + DateTimeToStr(now)); PBT_APMRESUMEAUTOMATIC: Memo1.Lines.Add('pc was PBT_APMRESUMEAUTOMATIC at ' + DateTimeToStr(now)); PBT_POWERSETTINGCHANGE: Memo1.Lines.Add('pc was PBT_POWERSETTINGCHANGE at ' + DateTimeToStr(now)); else // you're going to want to handle PBT_APMRESUMECRITICAL (XP and older systems) and PBT_APMRESUMEAUTOMATIC differently // IIRC you did not get notification of the suspend in this case Memo1.Lines.Add('pc was <<OTHER NON-REPORTED>> at ' + DateTimeToStr(now)); end; end; end. -
Getting Windows Sleep message, works for some computers but doesn't work for others.
programmerdelphi2k replied to c0d3r's topic in Windows API
if many works, and 1 dont, my bet is: verify the setup BIOS, verify if same Windows edition or setup, etc... -
yes, you need use some type of strategy like: 3 layers (read about this) 1 server database (for example, Interbase, Firebird, MSSql, Oracle, etc.. any one other, in any PC (Windows/Linux/macOS) using TCPIP communication 1 app in Delphi or not (App2 VCL or FMX since that it stay on PC for example, +TCPIP communication), (in the middle of the way) app between server and app client, to access your database server 1 app client delphi (FMX to mobiles, using TCP/IP) or not to access, to access App2 so, all request will be done that way: App client -> App2 -> Server DB or using DataSnap, RAD Server, Mormot, Horse, or any other framework to JSON requests DataSnap and RAD Server cames with Delphi, DataSnap is free, RAD Server needs license and Interbase license! I think that no, needs contact Embarcadero and buy a new subscript to CBuilder Enterprise or RAD Studio Enterprise (+6000$) you target Database can be any one, since you can export old database to new database and fix your VCL app to use it! at general, changes to another system, it's complex and need many works, but it's possible for sure!
-
do it as I said above
-
New installation and old program
programmerdelphi2k replied to georges pletinckx's topic in Windows API
for sure, you "replaced" with your another files in some moment (by mistake, for example), ex. pas with jpeg etc.... -
@georges pletinckx when you send any "pas" from Forms, it's necesary the "DFM" file too!, ex.: Calcul.pas + Calcul.dfm you got it? and yes, you needs Rave Report installed or if you have it, just update your Library Path as above.
-
@alogrep I didn't understand much of your code, however, I see that you're mixing "thread" with "UI" to expect a response from the print processing of the received data and the user's response, right? I think you shouldn't mix these three tasks, for the simple fact that the thread is an autonomous entity (as if it were another application inside your application), so when you try to interrupt the execution to wait for the response from the print or the user, this can cause a major obstacle in your process. I think you should use the thread to receive the data, only, and, in the "OnTerminate" event, that is, after the task of the thread finished, you could process the other actions: sending the received data to the printer, and, or wait for the user to give some response. This way, your thread will do its job: receiving the data. And in the end, you decide what to do with that data. I think you should better partition your code, that is, better divide the tasks, and not try to do everything in the same procedure. Thus, it will be easier to understand and find a possible problem. I don't know about Synapse so I don't know how to help with it. With regards to choosing or checking which default printer to use, I think you should do it before any processing in the thread or after it, that way you will send extra work. You are creating a new form for the user to make some choices, etc... This should only be done at some point outside the thread, never inside it, because, again, the thread continues to run, however the user is responding to some action on the form. Thread + UI not combined, unless you can "stop/pause" thread processing and then "resume the process", however, you will have to adopt another usage strategy. Normally, you will have to use "TEvent" in your Thread, etc... something a little more complex and needs some more knowledge about this area.
-
this unit can be from RAVE REPORT ? if yes, you need: have it installed or inform the path of "source files .PAS or .DCU" in your Library Path in your Tools->Language-Delphi-Library -> Library Path (to PAS ou DCU files localization) and Browsing Path (to PAS files localization) Library Path used to compile your project (mandatory) Browsing Path used to Editor Code (for find all class/types and help you using Ctrl-Space for example)
-
Did you try delete the "event line in Form definition" like this:
-
sorry any thing.
-
I think that "madExcept" is showing that YOUR APP raised an exception in your thread XXXX. for more details, it's necessary see your code.
-
@Ian Branch have you try override "DoDestroy" on Form? like DoCreate you can use it to change your cursor automatically... https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Forms.TCustomForm.DoDestroy
-
I did some hour ago, not copy from you I swear!!! I just forgot put other events to test as above... 😏
-
ok! good luck
-
just not possible verify the date and convert to format expected in each Country-Format, or use a universal format like ISO, before any works?
-
this way can do it ... procedure TForm1.Button2Click(Sender: TObject); begin //try Form2 := TForm2.Create(nil); // form2 can be closed now... try Form2.ShowModal; finally Form2.Free; end; //except // ? avoid exception leaks to ancestral, if using "raise exception...in form2" //end; end; type TForm2 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormShow(Sender: TObject); procedure FormPaint(Sender: TObject); procedure FormResize(Sender: TObject); procedure FormDeactivate(Sender: TObject); procedure FormActivate(Sender: TObject); public constructor Create(AOwner: TComponent); override; procedure CloseMeForced; end; var Form2: TForm2; implementation {$R *.dfm} { TForm2 } procedure TForm2.CloseMeForced; var CloseMe: Boolean; begin CloseMe := Label1.Caption = ''; // some logic... // ShowMessage('hello'); // if CloseMe then Abort; // raise Exception.Create('hello'); // Label1.Caption := 'still have a dreams...'; end; constructor TForm2.Create(AOwner: TComponent); // called before "FormCreate()" begin inherited; // CloseMeForced; end; procedure TForm2.FormActivate(Sender: TObject); begin ShowMessage('FormActivate never called... if CloseMe=true'); end; procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin ShowMessage('FormClose never called... if CloseMe=true'); end; procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin ShowMessage('CloseQuery never called... if CloseMe=true'); end; procedure TForm2.FormCreate(Sender: TObject); begin ShowMessage('FormCreate never called... if CloseMe=true'); end; procedure TForm2.FormDeactivate(Sender: TObject); begin ShowMessage('FormDeactivate never called... if CloseMe=true'); end; procedure TForm2.FormDestroy(Sender: TObject); begin ShowMessage('FormDestroy never called... if CloseMe=true'); end; procedure TForm2.FormPaint(Sender: TObject); begin ShowMessage('FormPaint never called... if CloseMe=true'); end; procedure TForm2.FormResize(Sender: TObject); begin ShowMessage('FormResize never called... if CloseMe=true'); end; procedure TForm2.FormShow(Sender: TObject); begin ShowMessage('FormShow never called... if CloseMe=true'); end; .end
-
I dont know if help you, I did some test using "FormatSettings" creating and some countries. and was possible use anothers chars and get all milliseconds as expected procedure TForm1.Button1Click(Sender: TObject); var LocalName: string; FS : TFormatSettings; LChar : char; LDateStr : string; begin LocalName := ListBox1.Items[ListBox1.ItemIndex]; // FS := TFormatSettings.Create(LocalName); // Memo1.Text := 'Before: [' + FS.DecimalSeparator + ']'; Memo1.Lines.Add('Before: [' + FS.ShortDateFormat + ']'); Memo1.Lines.Add('Before: [' + FS.LongTimeFormat + ']'); // LChar := ListBox2.Items[ListBox2.ItemIndex][1]; // , . ! @ * $ & ... // FS.LongTimeFormat := format('hh:nn:ss%szzz', [LChar]); // Memo1.Lines.Add('After: [' + FS.DecimalSeparator + ']'); Memo1.Lines.Add('After: [' + FS.ShortDateFormat + ']'); Memo1.Lines.Add('After: [' + FS.LongTimeFormat + ']'); // if LocalName.Contains('de-DE') or LocalName.Contains('ru-RU') or LocalName.Contains('be-BE') then LDateStr := '19.04.2023' + ' 11:59:10,238' // '.' = 11:59:00!000 else if LocalName.Contains('zh-CN') then LDateStr := '2023/04/19' + ' 11:59:10.238' // comma = Error else if LocalName.Contains('fr-FR') or LocalName.Contains('pt-BR') then LDateStr := '19/04/2023' + ' 11:59:10,238' // "point" = FR 11:59:00.000 / BR "point" = Error else LDateStr := '04/19/2023' + ' 11:59:10.238'; // comma = Error // Memo1.Lines.Add(StrToDateTime(LDateStr, FS).ToString(FS)); end;
-
@AlanScottAgain you can test "how many time a "event" is called, then, you can know why this behaviour...
-
[Delphi CE 10.4 update 2] Cant debug 🤨
programmerdelphi2k replied to Massimo Potere's topic in Delphi IDE and APIs
try this: verify if FireWall (MSWin) is blocking your debugge exe! if necessary, delete old entry and add it again! ...Embarcadero\Studio\<< edition>> \bin\dbkw64_28_0.exe <--- debugger exe -
see in your disk by Embarcadero samples: c:\users\Public\...\Samples\Object Pascal\Mobile Snippets\InteractiveGestures\TapAndHold
-
@Ian Branch let's try this: a new IDE session using another name all will be fresh... no 3rd-cmps, no plugins close all run your BDS.EXE -R << a new name here>> a new key will be created in your EMB HCU registry keys... later, you can delete if desire
-
some plugin installed or suite problematic?
-
@Ian Branch well, if you can reproduce it, then I see that can be your IDE no?
-
is it possible up your forms (if inherited or not)?
-
in Form Text format, the button has all properties ok?