delphi,button,access-violation , Delphi Access Violation when moving button on form

Delphi Access Violation when moving button on form


Tag: delphi,button,access-violation

I am trying to move 2 buttons on the form using a while loop checking for the buttons left property, but I have an Access Violation. I am exeting the procedure with CreateThread()

The code:

procedure AnimButton1();
var ImageCount: integer;
var b1, b2: integer;


       while (b2 <> 187) do
           b2 := frmNotification.btnBuzina2.Left;
           frmNotification.btnBuzina2.Left := b2 - 1;


       while (b1 <> 256) do
           b1 := frmNotification.btnBuzina.Left;
           frmNotification.btnBuzina.Left := b1 - 1;




BUT, when I use a Sleep() with at least 5 miliseconds, I dont have an access violation, like this:

procedure AnimButton1();
var ImageCount: integer;
var b1, b2: integer;


       while (b2 <> 187) do
           b2 := frmNotification.btnBuzina2.Left;
           frmNotification.btnBuzina2.Left := b2 - 1;

       while (b1 <> 256) do
           b1 := frmNotification.btnBuzina.Left;
           frmNotification.btnBuzina.Left := b1 - 1;



Could someone help me to find out why without the sleep I get the access violation and with it I dont?

thx in advance!


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.


My button doesn't work

This is the main activity, where I click the button public class NewAddMarketingProg extends Activity implements OnClickListener { private StartAppAd startAppAd; String note_detail; ListView lvNote; String[] data; private int mIndex; private MarketingProgramsAdapter adapter; private Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* StartAppSDK.init(this, getString(R.string.account_id), getString(R.string.app_id), true);*/ setContentView(R.layout.newaddmarketingprog);...

How to Randomly Choose Button Text in Java?

Friends, I am a Civil Engineer. Now i am working now in Android Developing. I know Java and C# but i am mentally set my Programming knowledge is only editing like Reading and Understand. How to increase my skill like writing Programs Specially for C# and Java. Thank You. then...

Missing operator or semicolon in Delphi 7

I've got the error message "Missing operator or semicolon" on line 38 of this code: procedure TForm1.SpinEdit1Change(Sender: TObject); begin case SpinEdit1.Value of 1: Label6.Caption('rok'); // line 38 end; end; end. Does somebody know what I am missing? Thank you....

How do I get values dynamically from radio buttons?

This is an on change event for anything changed on the page. $(this).change(function(){ type = $('input[name='+$(this).name+'radioName]:checked', '#myForm').val(); alert(type); }); I want to get the radio button that is clicked. So I can show the hidden input box when Profit is clicked. <TD align=left> <input type=radio name="Red" value="l" checked>Loss <input type=radio...

How to call the original class's code when a class helper is in scope?

I'm doing some unit testing on an improved version of quicksort. The (hopefully) faster version is implemented using: TArrayHelper = class helper for System.Generics.Collections.TArray .... class procedure Sort<T>(var Values: array of T); overload; static; class procedure Sort<T>(var Values: array of T; Comparer: IComparer<T>); overload; static; .... I know for now...

do oncalculate fields in one table using values from another table

I am doing calculations in my KLOG table. However, my PRICES table has the data I need for the calculations in the KLOG table. Example : KLOG table has PRICE_ID field (integer). So does the PRICES table. So I am trying to do something like this (oncalculatefields of the KLOG...

See when Delphi Twebbrowser starts loading a page

I am using delphi's TWebbrowser to navigate to a php file I created. I have a loading screen I would like to show when the page is loading or processing commands. How can I detect when it is being refreshed or still loading. currently I am using the ondocumentcomplete to...

Component event detection in Delphi

I am developing a DataAware component and executing some code after the database is open. This is the code I have at the moment: TMyDataAwareComponent = class(TDataAwareComponent) private { Private declarations } procedure ToBeExecutedOnAfterOpen(DataSet: TDataSet); protected { Protected declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; end;...

Update label's text when pressing a button in Kivy for Python

Here is my code: I want to make a game where the main_label changes text when you press a button but I've looked everywhere for a week and still don't understand how to do it. I looked on Kivy's website but I don't understand. As you can see I'm new...

PasswordChar in Delphi XE8's TMemo

I spent a few hours searching Google to see if anyone had shared their articles, but came up empty-handed. If it's possible, I want to know how to enable/disable the passwordChar in Delphi XE8's TMemo to hide user input like in TEdit. ? Maybe via a checkbox! So when the...

How to change textView in separate ViewController from button in another ViewController?

I have a Collections View that includes various cells that are also buttons. Upon clicking one of those buttons, a separate ViewController is shown (I just connected the button to the ViewController and clicked "show"). I would like to know how to switch the textView in that separate ViewController for...

Multiple Alignments Inside Button,button
Can you make a single string, within the same button, have different alignments? For example: dim String1 = "A B C D E F" A - would be in the top left corner B-in the middle top..... ...

Asynchronous TADOQuery's OnFetchComplete not synchonized to main thread

When using TADOQuery with [eoAsyncFetchNonBlocking] and attaching to OnFetchComplete event I found that OnFetchComplete is not executing in the main thread (tested in XE4 and XE8). I assume this a bug*, since most of us will do work in the UI on these type of event. I believe this to...

Dynamically change a button-drop list in javascript?

Trying to create a changeable button-drop-down from Bootstrap HTML in conjunction with Javascript. The HTML looks as: <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Menu <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="#">Choice1</a></li> <li><a href="#">Choice2</a></li> <li><a href="#">Choice3</a></li> <li class="divider"></li> <li><a...

Issues with AES Encryption using SynCrypto

Am trying to encrypt a file using SynCrypto.pas with AES 256, but it fails if I try to encrypt a file whose size is not a multiple of 16 bytes. The decrypted data contains junk. Example: Original string in txt file we are testing the file Encrypted String [ù[„|wáî}f *!4ìÙw¬•ü¨s...

JButton listener not firing

I seperated my codes into MVC model and now my confirm button action listener is not printing the username and password even though I added a Actionlistener for it. please help thanks. Codes import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog;...

Delphi Bug in Indy FTP List method?

I'm trying to generate a list of files matching a certain file mask and Indy falls over with this error EidReplyRFCError with message '.': No such file or directory. I've tried several variations and this is the result: FTP.List( aFiles, '', true ); => this works FTP.List( aFiles, '*.*', false...

How do you create a button that will display a random result from an array in javascript?

I've been trying to create a button that will take a random name from an array, and display it on an html page. Been trying for a long while to get this to work, with no results. What gives? As well, if you know the answer, how could I create...

Delphi - Use a string variable's name in assignfile()

Is it possible to use a variable in the assignfile command? Eg. f : Textfile ; sFile : string ; {contains 'MyFile.txt' as content} ... cFileDir = 'C:\Users\User\Desktop\Data Engine\Data\Country' ; ... Assignfile(f, cFileDir + '\' + sFile) ; ... I appreciate your help very much. if it's unclear I'll edit...

How to remove button border style?

In autohotkey, how do you remove the black button border? I just want a button without any border on it. I've tried all these style modifiers to no avail. gui, add, button, hwndMyButton Control, Style, -0x0,, ahk_id %MyButton% ;remove BS_PUSHBUTTON Control, Style, -0x1,, ahk_id %MyButton% ;remove BS_DEFPUSHBUTTON Control, Style, +0x8000,,ahk_id...

Active Bootstrap Buttons

I have just been playing around with Bootstraps Button Group to show and hide div's on my webpage. Perhaps I am being dumb, but could anyone point me in the right direction for making the selected button active when clicked? HTML (Buttons): <div class="btn-group" role="group" aria-label="..."> <button id="1" type="button" class="btn...

WPF custom button

I start to learn WPF and there is something that is still unclear for me: i created new Style for button: <!-- no border button style --> <Style x:Key="NoBorderButton" TargetType="Button"> <Setter Property="Foreground" Value="White" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderThickness" Value="0" /> <Style.Triggers> <Trigger Property="Control.IsMouseOver" Value="true">...

I want my button to call a method in a fragment

So I have (WorkoutList Activity) -> (WorkoutList Fragment) -> (ExerciseList Fragment) -> (addExercise Fragment) Theres a button in AddExercise, and I want it to invoke a method in ExerciseList The problem is that with the current set-up I'm getting `Attempt to invoke virtual method void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object...

my done button somehow went to a blank page and delete won't work unless I refresh -ajax

I am playing around with a todo list I learned online. Trying to add ajax into it. Works well when I try to add an item. When an item is added there's a button says 'Mark as done' so I can click on it and then there will be a...

How to use TThread.Synchronize() to retrieve the text of a TEdit control?

How can I use TThread.Synchronize() to retrieve the text of a TEdit control. Should I assign the TEdit text to a global variable or something?

Does “enable runtime themes” affect performance?

I've recently changed "enable runtime themes" value in the project options and I'm wondering if it's value affects application's performances and, in case, in which manner? Hope someone can clarify me this point.

Is it possible to share multiple text by using share intent?

I intend to share 6 text information, however it always shows the last information only, i.e. share.putExtra(Intent.EXTRA_TEXT, Contact); I also tried to use a string array to store all 6 information, i.e: share.putExtra(Intent.EXTRA_TEXT, stringArray); However, it still doesn't work. Can anyone help ? Thank you. My code: public class SingleJobActivity...

SetProcessWorkingSetSize does not work in compiling 64bit

I use the following command to reduce the memory usage of my program, I'm actually testing it, only when I compile the program in 64bit this command does not work fot, no error occurs, only the memory in task managerIt does not decrease too, since in compiling 32bit works perfectly,...

Set node state in a virtual tree

I have created a virtual tree with multiple node and I want to disable some of them. I've seen there's a States property of a node. Which is a property of a type TVirtualNodeStates so I've check what kind of states I can set and apparently TVirtualNodeStates is a set...

Delphi generic frame

I'm still here with a questione about Delphi frames. I would like to create an application that use various type of frames in order to manage different database tables, so trying to understand how to do this kind of task I've create a simple Delphi Form: unit main; interface uses...

How to make my custom control be notified when his form or application receives and loses focus?

I want my control to receive distinct notifications only when it's parent form (not panel or something else, just the main form of this control) receives and loses focus. Doesn't matter if the focus is switched from another form of the application or between my application and other application, it...

Using CSS :after to shade a button:hover

I'm trying to add a bunch of different color classes to my buttons and allow additional classes to be added arbitrarily. All of these should darken on hover. It seems tedious to write button.(color):hover rules for every single color, so I've written this such that the :after section gets darker...

How can I keep a group of buttons centralized on the right side of the footer?

I've been trying to keep four buttons centralized on the right side of the footer, but it seems like the footer is set to percentage instead of pixels, I've tried to set it to percentage, but it ignores my "orders", how can I set the footer to 60px, and put...

How to get enabled property of a control?

In Delphi it is possible to get the process name and class name of any control which is clicked system wide via windows api. process name: GetWindowThreadProcessId(Hwnd, ProcessId) by process ID one can get to the process name class name: SetLength(ClassName, 255); SetLength(ClassName, GetClassName(Hwnd, pchar(ClassName), 255)); Is there an easy...

Function that returns intersection of two TShapes, including TPaths?

Anyone have any knowledge of a function that returns the intersection TPath for two TShapes? Especially one that returns the intersection TPath of two TPaths. For instance: pthIntersection := PathIntersection(Path1,Path2); ...

In WPF how can I control whether another button clicked

I want to determine another button is clicked in wpf. I wrote same code as below, when I clicked that button the animation works after that when I clicked same button the animation work like as else block. But I want to control if another button is clicked and than...

How to get an entry.bind and a button do the same thing?

I think the name of the topic is pretty clear, I haven't found any answer elsewhere so I came to ask for it. I have a tkinter GUI with an entry and a validation button. I'd like to call the same function when I press a key in the entry,...

C# Delete Row with Dynamic Textbox/Button/Grid

I've tested some thinks with Dynamic Textboxes and Buttons, Adding Items to my Grid works very well, but if I want to Delete it there are some Bugs, sometimes 1 Row is empty and my Add Button disappears or my Program crashs. What did I wrong or what did I...

How to access file from another function

I'm currently working on a C# WPF application which looks something like the following. What I am trying to do is this, the first button, when pressed, basically opens up a browse dialog box where you can select multiple files. I want access to those paths inside my other button...

How to handle event from multiple buttons of same name

I am working on a small practice program where I have 3 white boxes in a row. My goal is (using Javascript) for any of the boxes to change from white to red when the mouse is over the box, and then to turn yellow when the mouse comes off...

Having one button in ng-repeat change color when clicked, not all using Angularjs

Hi I'm trying to make my done button change green when clicked. The first time I attempted this, it changed all the buttons green. index.html <tbody> <tr ng-repeat="plan in scheduler.plans | orderBy:'standardTime'"> <td class="plan-time">{{plan.displayTime}}</td> <td class="plan-duration">{{plan.duration}} minutes</td> <td class="plan-task">{{plan.task}}</td> <td><button type="button" ng-class="{'btn-primary': !scheduler.clicked, 'btn-success': scheduler.clicked}"...

How to link code for button function to checkboxlist in C#?

I would like to link the function of my Chart Output Button to the items in my check box list such that when an item in the check box is selected or deselected, the page is reloaded again and my chart is refreshed. My codes to refresh the chart have...

Beginner:What do several parts of my code mean? [on hold]

Because I'm an absolute beginner I have a really simple question but I can't help myself.Maybe they are too simple because I can't find the answer in forums, books or other internet paged. I do not get the meaning of some parts of my java code because i just knew...

How to remove duplicates in ListBox?

I use this code to remove duplicates: procedure TForm1.RemoveDuplicates(StrList : TStringList); var NoDuplicate: TStringList; i: Integer; begin NoDuplicate := TStringList.Create; try NoDuplicate.Sorted := True; NoDuplicate.Duplicates := dupIgnore; /// for i := 0 to StrList.Count - 1 do NoDuplicate.Add(StrList[i]) ; /// NoDuplicate.Sorted:= False; StrList.Assign(NoDuplicate) ; finally NoDuplicate.Free; end; end; It works...

Multiple screen support Windows Phone 8

I used to develop for Android and iOS, and for multiple screen support we use to use mdpi, hdpi, xhdpi. Now I want to develop for Windows Phone, I want to set a background to a button and I don't know how to define image size to support all screen...

Java: Action Handler

I am working on a problem for school and I am having an issue with the CalculateButtonHandler. I am also using an ExitButtonHandler but that is not giving me any issues. I have tried re-reading my textbook and have searched the web. After racking my brain over this issue I...

Firemonkey ListView item indexes not updating

I'm using a TListView in Firemonkey. On startup, I create 3 list view headers and keep references to them for future use (specifically inserting items below each header). FItemHeader:= LV.Items.Add; FItemHeader.Purpose:= TListItemPurpose.Header; FItemHeader.Text:= 'Items'; FChargeHeader:= LV.Items.Add; FChargeHeader.Purpose:= TListItemPurpose.Header; FChargeHeader.Text:= 'Charges'; FPaymentHeader:= LV.Items.Add; FPaymentHeader.Purpose:= TListItemPurpose.Header; FPaymentHeader.Text:= 'Payments'; Then, I've added a...

Custom component controls keep re-creating

I'm a newbie in Firemonkey/custom controls so sorry if this is a banal question or a duplicate one but I'm stuck and can't figure it out. Here's the code of my custom control unit swScheduler; interface uses System.SysUtils, System.Classes, FMX.Types, FMX.Controls, FMX.StdCtrls, FMX.Calendar, FMX.Objects; type TswScheduler = class(TControl) private {...

HasValidFileNameChars fails for UNC files

For me HasValidFileNameChars function (in Delphi XE7) returns false for UNC files: B:= IOUtils.TPath.HasValidFileNameChars('\\ETA-PC\tests\test.ini', FALSE) B is false now This means that if you try to validate the filename that I show in my test (yes the file is real and as you can see its name is correct) HasValidFileNameChars...

AS3: Fast hovering doesn't execute rollOut

I'm having a serious problem that is getting me nervous: I've made a button _btn that includes ROLLOVER and ROLLOUT animations with coding (an nested movieclip instance called barra that increases to half alpha when you hover over and decreases when you hover out). [Here it should go a descriptive...