If you have the window handle for a control, then the IsWindowEnabled function will tell you whether it is enabled. Keep in mind that that is acting on the window at the API level, not the Delphi VCL level. In Delphi, there can be controls that do not have window...
It sounds like this is what you have done - let me guess at the steps to reproduce this problem: Created a base regular form - Let's call it TForm1 Added a number of controls to TForm1 Created a second regular form - Let's call it TForm2 You then edited...
You could write Node.States := [vsDisabled];, to make your code compilable. But this is not what you are supposed to do. There are node states that you must keep untouched and by the mentioned statement you would throw them away and set only the vsDisabled one. You wanted to write...
delphi,com,delphi-2007,variant
The code is missing a unit from the uses clause. That unit is named Variants and contains all the symbols that the compiler cannot find. Add that unit and the code will compile.
Looks like some another unit declares TSite type that is used instead; Try declare the var awith the fully qualified name unit main; uses .. lc, ...; var Site: lc.TSite; Also it would make sense to reference the var via FQ-name too, just I ncase some other unit or procedure...
You should go to router admin console, find something like "port forwarding" and route the port (8081) to your computer IP - you have to say the router that traffic on this port should go to your computer
string,delphi,optimization,pchar
Let's consider the corner cases. I think they are: AInput invalid. AStart < 1. AStart > FLength. ASubstringLength < 0. ASubstringLength + (AStart-1) > FLength. We can ignore case 1 in my opinion. The onus should be on the caller to provide a valid PChar. Indeed your check that AInput...
First, never have a control handle its own event properties. Event properties are for the consumer of the component, not for the developer. The component developer's hook to the OnResize event is the protected Resize method. Override that if you want to know about OnResize-related events. What I suspect is...
delphi,listbox,duplicate-removal
Try NoDuplicate.CaseSensitive := True; ...
delphi,asynchronous,delphi-xe4,delphi-xe8,tadoquery
In my experience the easier way is to use either: Synchronize or TThread.Queue This is not a bug or at least not a VCL bug. This behavior is handled by the provider and we cannot say it is not following the specification because there is no specification about how to...
You need to set the stored property of your sub components to false. paLaterale := TPanel.Create(Self); paLaterale.Stored := false; etc ...
I want to suspend some updates of the control when his form is not active and resume the updates when the form is activated. If those updates are done continuously, or are being triggered by a timer or actions, then you could be done with: type TMyControl = class(TControl)...
No. When LoadFromResourceName executes, it clears any memory and resources used by the previous image, and loads the new one. Your code is fine, modulo the missing try/finally. It should be: Bitmap := TBitmap.Create; try .... finally Bitmap.Free; end; Without that, should an exception be raised in between assigning to...
procedure TFrameManagement.CreateGenericFrame(ParentPanel: TPanel; FrameName: TFrame); begin genericFrame := FrameName.Create(ParentPanel); genericFrame.Parent := ParentPanel; end; Here FrameName is an instance and you are calling the constructor of that instance. You are not creating a new instance as you intend to do. You need to use meta classes. type TFrameClass = class of...
Thanks to the answer of @arnt, I figured out a solution that works for me. Yes, for every Message that corresponds to the search criteria, the event OnMessageInfo is fired. Since I need to go through all messages in a loop, I ended up doing this: procedure TReadIMapObjectsFavFktProperty.MessageInfo(Sender: TObject; const...
When you open an ini file, store the filename in a variable as explained in many comments. Example, (FCurrentIniFilename: String; is a private variable in TForm1): In the FormCreate event: FCurrentIniFilename := ExtractFilePath(Application.EXEName)+ 'A.ini'; Read := TINIFile.Create(FCurrentIniFilename); ... In the OpenFile event: if OpenDialog.Execute then begin FCurrentIniFilename := OpenDialog.Filename; Open...
MCrypt expects the key to be a binary string, but you pass a hex encoded string into it. Use $key = hex2bin($key); or $key = pack('H*', $key); depending on PHP support. This must be done before calling mcrypt_encrypt(). Security: Don't ever use ECB mode. It's not semantically secure. There is...
Please read the documentation, it tells you exactly how to define a FireDAC connection for MySQL: Working with Connections (FireDAC) Connect to MySQL Server (FireDAC) You would specify the DB server as part of a Connection Definition: Defining Connection (FireDAC) Connection Definitions can be defined in an external .ini file,...
These options control the subsystem of the output file. They only have meaning on Windows. They are equivalent to the $APPTYPE directive. The $APPTYPE directive controls whether to generate a Win32 console or graphical user interface application. In the {$APPTYPE GUI} state, the compiler generates a graphical user interface application....
When creating the preview FastReport does something like this code: while not MasterBand.DataSet.Eof do begin ...Do special FastReport's work :) while not DetailBand.DataSet.eof do begin ...Do special FastReport's work :) DetailBand.DataSet.Next; end; MasterBand.DataSet.Next; end; In your code: while not opr_operatorcount_ods.Eof do begin frxReport1.PrepareReport(false); opr_operatorcount_ods.Next; <-- here opr_operatorcount_ods is in the...
After talking to somebody formerly on the development team of MS Document Explorer and now r2reg, this is not possible. And since MS moved on from MS Help 2 and now uses MS Help Viewer, there will not be any further development to allow for this.
delphi,microsoft-ui-automation
Your GetSelection() implementation is expected to return a SAFEARRAY of IRawElementProviderSimple interface pointers. However, you are creating a SAFEARRAY of VARIANT elements instead, but then populating the elements with TAutomationStringGridItem object pointers. SafeArrayPutElement() requires you to pass it a value that matches the type of the array (which in your...
delphi,button,access-violation
I am executing the procedure with CreateThread(). That is your problem. VCL code must only be called from the main UI thread. Use TThread.Synchronize to invoke the VCL code on the main thread. That said, a timer might be a more appropriate solution to you problem than a thread....
multithreading,delphi,delphi-xe7,omnithreadlibrary
You should call FPipeline.input.CompleteAdding from TEmailQueue.Destroy. Otherwise, SendEmailStage will never stop.
What you are asking for can be done by either: deriving the various Form classes from a common base class that exposes the field you want to access: procedure A(aForm : TBaseForm); begin ShowMessage(aForm.edtUser.Text); end; type TBaseForm = class(TForm) edtUser: TEdit; ... end; TDerivedForm = class(TBaseForm) ... end; ... frm...
I think that the only way to achieve this with pure Pascal code is to call Sort from a scope in which your class helper is not active. The point being that if your class helper is active, then Sort refers to the method in the helper. For instance like...
You can use JFileDialog Check the below link http://bluexmas.tistory.com/427...
delphi,ios-simulator,delphi-xe7,paserver
After a few days, I found out what the problem was, so I'll post the solution here to help others who might have the same problem. Go to Project --> Project Options --> Version Info Under de iOS Simulator configuration, Delphi IDE (XE7) automatically inserted the following key and value:...
The events that you are searching for are OnDownloadBegin and OnDownloadComplete. OnDownloadBegin fires just before the document starts to being downloaded and is therefore the best event for starting of some loading animation. http://docwiki.embarcadero.com/Libraries/XE8/en/SHDocVw.TWebBrowser.OnDownloadBegin OnDownloadComplete fires after the document was downloaded and even if the downloading of the document fails...
You can use a virtual method interceptor to intercept the DoAfterOpen virtual call FVirtualIncerceptor := TVirtualMethodInterceptor.Create(TDataSet); FVirtualIncerceptor.OnBefore := procedure(Instance: TObject; Method: TRttiMethod; const Args: TArray<TValue>; out DoInvoke: Boolean; out Result: TValue) begin if Method.Name = 'DoAfterOpen' then ToBeExecutedOnAfterOpen(TDataset(Instance)); end; FVirtualIncerceptor.Proxify(Self.DataSource.DataSet); See this for more info...
This defect is present in all versions of the compiler. Since Real48 was deprecated more than a decade ago I would expect that Embarcadero would not change the behaviour, even if you submitted a bug report. Of course, you should still submit a bug report, but I would not hold...
unit-testing,delphi,generics,dunitx
Try to make your test class generic and register your test class with every single concrete type you want to test. [TestFixture] TMyTestObject<T> = class(TObject) public // Sample Methods // Simple single Test [Test] procedure Test1; // Test with TestCase Atribute to supply parameters. [Test] [TestCase('TestA','1,2')] [TestCase('TestB','3,4')] procedure Test2(const AValue1...
Just a simple way to improve the code: var ix: Integer; ... ix := StrToInt(valmes.Text); WebTesta.OleObject.Document.all.Item('expmonth', 0).value := IntToStr(ix-1); You can add some sanity checks using if TryStrToInt(valmes.Text,ix) then .......
delphi,checkbox,event-handling,delphi-xe3,data-aware
A couple of problems with using the DataChange event to do things like this are that It's called a lot more frequently than you actually need, to react to your DBCheckBox being clicked and Doing a .Post to the dataset is going to change its state, which is generally a...
First off, WinExec() has been deprecated since 32bit Windows was first introduced. Use ShellExecuteEx() or CreateProcess() instead. This also provides you with a process handle that you can use to detect when the spawned process terminates, and you can also use it to kill the process if your timeout elapses....
delphi,pipe,console-application,createprocess,waitforsingleobject
To summarize: @David Heffernan's code in Execute DOS program and get output dynamically works. The problem is that the console application emits UTF-16.
Change BMP to BITMAP in your RC file, and change HInstance to FindClassHInstance() in your code: FIXED BITMAP "fixed.bmp" Glyph.LoadFromResourceName(FindClassHInstance(MyComponent), 'FIXED'); ...
delphi,delphi-2009,windows-messages
The OS sends wm_DeviceChange messages to all top-level windows. The application's main form is a top-level window, but your control is not, which is why the form receives the messages and your control does not. For arbitrary device types, you have two alternatives: Use AllocateHWnd to create a message-only top-level...
This is very platform-specific, and as such there is nothing in FireMonkey or VCL to help you with it. You have to use platform APIs directly. For instance, on Windows you can use CreateToolhelp32Snapshot(), Process32First() and Process32Next(): Taking a Snapshot and Viewing Processes Or you can use EnumProcesses(): Enumerating All...
The documentation tells you to pass high(SIZE_T). You do this when compiling for 32 bit, but not for 64 bit. This is what you mean to write: SetProcessWorkingSetSize(MainHandle, high(SIZE_T), high(SIZE_T)); Do note though that this code won't help performance on your machine. In fact, the only thing it can do...
It is possible to transfer an image from a PNG to a GIF. However, I don't recommend that you do so. The GIF format is substantially less capable than PNG. PNG supports RGBA color channels and partial transparency. GIF uses a 256 color palette and no support for partial transparency....
multithreading,delphi,delphi-xe7,omnithreadlibrary
I suggest you to set up OTL. You would most probably have the only SMTP server, so the only mail-sending thread, in case you would later add more notification sending servers ( like sending SMSes to different phone operators ) - you would add more outgoing "sink" threads. Personally I...
windows,delphi,drop-down-menu,menuitem
Create a new menu item and set its caption to '-'. var MenuItem: TMenuItem; .... MenuItem := TMenuItem.Create(Menu); // Menu is the menu into which you are adding MenuItem.Caption := '-'; Menu.Items.Add(MenuItem); Instead of Add, which adds to the end of the menu, you can use Insert to insert the...
delphi,handle,createprocess,waitforsingleobject,shellexecuteex
Your code is not working because the handle table is per process, which means that the second process could have the same handle pointing to another kernel object. Below, there is one of many possible solutions: When creating the process 2, pass the PID of the process 1 as parameter:...
Internally Delphi uses class TPerlRegEx and it has such description for GroupCount property: Number of matched groups stored in the Groups array. This number is the number of the highest-numbered capturing group in your regular expression that actually participated in the last match. It may be less than the number...
The function behaves correctly because a \ is not a valid character for a file name. It is the path separator. The distinction here is between file names and paths. Using your example, \\ETA-PC\tests\test.ini is a path, but the file name is test.ini. I suspect that you are looking for...
delphi,encryption,cryptography,aes
AES is a block cipher algorithm. It means that it works by blocks that are 16 bytes in size for AES. So you need to use padding if your data does not fit in 16 bytes blocks (which is the case for your text). Instead of trying to re-invent the...
performance,mongodb,delphi,mapreduce
Phew what a question! First up: I'm not an expert at MongoDB. I wrote TMongoWire as a way to get to know MongoDB a little. Also I really (really) dislike when wrappers have a plethora of overloads to do the same thing but for all kinds of specific types. A...
As noted in comments, you must use SendMessage with WM_COPYDATA. The primary reason for this is that the message sender is responsible for cleaning up the resources used for the transfer. As noted in the documentation : The receiving application should consider the data read-only. The lParam parameter is valid...
value = '散汤湡獤杀潯汧浥楡潣m䌴䅓㜭䙇ⵊ䵙㑗㈭呖ⵆ䥉儵䈭呎́'#4 This is indicative of you interpreting 8 bit text, presumably UTF-8 encoded, as if it were UTF-16 encoded. As a broad rule, when you see a UTF-16 string with Chinese characters, either it is a correctly interpreted Chinese text, or it is mis-interpreted 8 bit text....
If you include components in the designer, then they will be created when the form is created. Nothing you can do to stop that. The logical conclusion is that you need to create the components at run time. One obvious way to make that easier is to put the components...
This is certainly a bug. It occurs in all the IDE versions that I tested, XE3, XE7 and XE8. I honestly don't think there's a lot you can do. For me the IDE terminates on compilation every time. I think you'll just have to write the code in a way...
delphi,exception-handling,delphi-xe2,delphi-7
The only rational explanation is the FormCreate is not executing. You need to assign it to the form's OnCreate event handler. Use the object inspector to do so.
I'm not sure I have understood your question, but try taking a look at using a region, with all members of the group in it, including the lines/shape used, you can then group the items together.
The IDE places the file in the root directory of the project. You cannot influence it to do otherwise.
Is it possible to use a variable in the AssignFile command? Yes. The second parameter of AssignFile has type string. The expression cFileDir + '\' + sFile has type string. FWIW, AssignFile is known as a function rather than a command. Getting on top of terminology like this will...
Probably, it is a boundary check error. Quote from MSDN (CreateFile, note on opening physical drives and volumes, which you call logical drives): To read or write to the last few sectors of the volume, you must call DeviceIoControl and specify FSCTL_ALLOW_EXTENDED_DASD_IO ...
You cannot use compiler intrinsics because they are processed by the Delphi compiler rather than the assembler. Intrinsics are resolved by the Pascal compiler processing and parsing Pascal expressions, and then emitting code. That's the job of a compiler rather than an assembler. At least, that's my mental model. In...
Your version of SynGdiPlus is clearly deprecated. The current revision has a NOTSYNPICTUREREGISTER condition, which is enabled by default: initialization {$ifndef NOTSYNPICTUREREGISTER} Gdip.RegisterPictures; // will initialize the Gdip library if necessary {$endif} Ensure you got the latest revision of the source code tree....
In VCL, TPaintBox is a TGraphicControl descendant that draws onto the HDC of its Parent control's HWND. When the Parent control receives a WM_PAINT message, it draws itself onto the provided HDC as needed, and then temporarily gives that same HDC to each child TGraphicControl when drawing them, clipping the...
h2 is a window handle, for a window in another process. You can cast it to a TListBox as you did, but that does not make h2 actually be a list box. Hence the runtime error. Essentially you lied to the compiler by claiming that h2 was something that it...
There's nothing to keep the string alive. When you write: s := PChar(sl.Values[sl.Names[c]]); an implicit local variable of type string is created to hold whatever sl.Values[sl.Names[c]] evaluates to. That local variable goes out of scope, as far as the compiler is aware, nothing references it, and the string object is...
COM interfaces are reference counted, and the Delphi compiler generates code to automatically manage the reference counting for you. Each time an interface variable is assigned, Release is called if the variable is not nil, and AddRef is called if the new value is not nil. When the variable goes...
You can use the IXMLNodeList.Delete() or IXMLNodeList.Remove() method to remove nodes: var Root: IXMLNode; begin Root := XMLDocument1.DocumentElement; Root.ChildNodes.Delete('ElementData'); for I := 0 to Root.ChildNodes.Count-1 do Root.ChildNodes[I].ChildNodes.Delete('ElementData'); end; var Root, Child, Node: IXMLNode; begin Root := XMLDocument1.DocumentElement; Node := Root.ChildNodes.FindNode('ElementData'); if Node <> nil then Root.ChildNodes.Remove(Node); for I := 0...
BadImageFormatException typically indicates a bitness mismatch. Your Delphi module is 64 bit and the C# module is 32 bit, or vice versa. You have other problems. At least the following: You cast a UTF-16 UnicodeString string to PAnsiChar. That cast is not correct. You return a the address of a...
delphi,winapi,shellexecute,file-association
Call ShellExecuteEx and specify the lpClass member of the SHELLEXECUTEINFO struct. Note that you must include SEE_MASK_CLASSNAME in the fMask member. For instance, set lpClass to '.txt' to request that the file be opened with the program associated with the .txt extension. ...
My pshychic debugging tells me that you are looking at the string in the debugger. The single quote is the string delimiter. So it needs to be escaped. It is escaped by doubling it. So when the debugger shows a string like this: 'a''b' that is actually three characters long,...
What "Enable runtime themes" actually does is telling Windows to Enable Visual Styling of the applications via following manifest entry <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> You could also have runtime themes enabled in older Delphi versions using different methods. Delphi 7 included TXPManifest component that...
There is no built-in function for this. But what I think you are trying to do is this: Given a polygon (aka TPath) made up for distinct points connected by lines. Return all points in ShapeA that lay inside ShapeB. Point intersection This can be done using PointInObjectLocal. Run a...
windows,delphi,windows-7,delphi-xe6,windows-95
It seems to me that the fundamental problem is that your main form is, in the eyes of the VCL, not your main form. Once you fix that, all the problems go away. You should: Call Application.CreateForm exactly once, for the real main form. That is a good rule to...
delphi,freepascal,lazarus,netcat,synapse
Well... Hex 00 00 B5 6C (your extra bytes in reverse) is equal to 46444. So my guess is that TFileStream or SendStream sends the number of bytes it wants to send before the actual data. Looking at the code of Synapse there is the function: procedure TBlockSocket.InternalSendStream(const Stream: TStream;...
This is not a bug in TIdFTP. It is more an omission in the Indy documentation. EIdReplyRFCError means the FTP server itself is reporting an error in response to the command that TIdFTP.List() is sending. Depending on the values of the ADetails parameter and TIdFTP's UseMLIS+CanUseMLS properties, List() can send...
Function sExtractBetweenTagsB(Const s, LastTag, FirstTag: string): string; var pLast,pFirst,pNextFirst : Integer; begin pFirst := Pos(FirstTag,s); pLast := Pos(LastTag,s); while (pLast > 0) and (pFirst > 0) do begin if (pFirst > pLast) then // Find next LastTag pLast := PosEx(LastTag,s,pLast+Length(LastTag)) else begin pNextFirst := PosEx(FirstTag,s,pFirst+Length(FirstTag)); if (pNextFirst = 0) or...
First, declare a method in your form that retrieves the text. This method can be called both from the main thread and a worker thread: Type TMyGetTextProc = procedure(var s: String) of object; procedure TForm1.GetMyText(var myText: String); begin TThread.Synchronize(nil, procedure begin myText := ATedit.Text; end ); end; Secondly, when you...
What your updated q is asking for is straightforward and as usual with Devex stuff, it's all in the OLH as long as you can find your way into it. A way to find which rows currently match the filter is to use the cxGrid1DBTableView1.DataController.FilteredRecordIndex[] property. You can then find...
can you try Project -> Options -> Provisioning -> New Keystore http://docwiki.embarcadero.com/RADStudio/XE8/en/Creating_a_Keystore_File http://docwiki.embarcadero.com/RADStudio/XE8/en/Create_a_new_Keystore/Alias...
delphi,network-programming,ip-address,windows-10
It sounds as though the library that you use requires elevated rights. Nothing significant has changed in Windows 10 regarding UAC. If your program is running elevated it will succeed. It fails when it is not elevated. So your problem would appear to be that you are failing to execute...
Delphi's operator precedence rules mean that your expression is evaluated like this: if (qryGeneral.fieldbyname('B_PRIJS').IsNull or qryGeneral.fieldbyname('B_PRIJS').Value) = 0 then Put parentheses around your = expression just like you have around you <> expressions, and you should get closer to the results you expect. However, the Value property is a Variant....
This is the declaration of the InsertRecord method: procedure InsertRecord(const Values: array of const); The parameter is a variant open array. Variant open array parameters are implemented internally by being passed as TVarRec instances. And TVarRec cannot contain records. Since TGUID is a record, it cannot be passed in a...
delphi,listbox,indexoutofboundsexception,lazarus,tstringlist
The error is telling you that the list box selectedbox is empty. I would expect that the error is more like this: List index out of bounds (0) That tells you that index 0 is invalid which can only mean that there are no items in the list box. Presumably...
I don´t think that converting to PDF would be a normal SaveAs. You should try exporting it, as said here
The RTL has no function for flushing a file without closing it. You have to use platform-specific functions instead. On Windows, TFileStream uses the Win32 CreateFile() function to open/create a file, so you can use FlushFileBuffers() to flush it. On other platforms, TFileStream uses the POSIX open() function to open/create...
Label6.Caption('rok') Caption is a property which behaves as a variable does. You treat it as though it is a procedure (which it is not) and hence the compilation error. The parser knows that the only thing that can follow a property name is a semicolon, bracket (if the property is...
Make sure the MaxLength of edtZaklad is 0. var Form21: TForm21; Check:string; //to break the loop. function GetCurrency(Num: String):string; var i: Integer ; Str:String; zaklad: Currency; begin Result := ''; for i := 1 to length(Num) do begin if (Num[i] in ['0'..'9']) then Begin Str := Str + Num[i] ;...
The VCL memo control is a loose wrapper around the Win32 multiline edit. The password character functionality of the edit control is only available for single line edits. The behaviour is controlled by the ES_PASSWORD style for which the documentation says: Displays an asterisk (*) for each character typed into...
The difference is explained in the documentation: When TXMLDocument is created without an Owner, it behaves like an interfaced object. That is, when all references to its interface are released, the TXMLDocument instance is automatically freed. When TXMLDocument is created with an Owner, however, it behaves like any other component,...
While the real fix is in Embarcadero's ball court, this seems to be the only work-around: procedure ReindexListView(AListView: TListView); var X: Integer; begin for X := 0 to AListView.Items.Count-1 do AListView.Items[X].Index; end; Behind the scenes, there is a known bug in the generic TList implementation, specifically a mis-hap with the...
You are not telling us what data access component you are using. The recommended way to do this is using a Query component (TSQLQuery, TADOQuery, TIBQuery,...) , then have the SQL for that query retrieve all necessary information. All the fields that you want access to in you OnCalcFields() should...
Do not try to include namespaces in your XPath query. If all you want is the text of the SomeResult node, then you can use '//SomeResult' as query. For some reason the default xml implementation (msxml) barfs on the default namespace xmlns="http://someurl" on the SomeResponse parentnode. However, using OmniXML as...
delphi,pointer-arithmetic,delphi-xe8
Your loop runs forever because P will never be nil to begin with, not because of an issue with your pointer math (although I will get to that further below). PChar() will always return a non-nil pointer. If S is not empty, PChar() returns a pointer to the first Char,...