So that is my problem I have no idea how to deal with a thread. I just started programming, with not a whole lot of experience time under my belt, and the examples that I have found with Google do not help me as they are written for someone that knows how to deal with threads or has more knowledge of an OS and how they work then I do.
what I have tried when dealing with a thread just crashed it and such.
I changed the files to txt extension
MOD: ADDED:
I am researching this fork thing and threads. is that a good idea?
It seems like you are beating your head against the wall.
If you just started programming, why are you trying to deal with advanced subjects, such as threads and processes? I've been programming for my own purposes on and off since the late 1970's. I have never had to concern myself with threads or processes, beyond knowing what they are through osmosis, so to speak. The Lazarus IDE handles all that stuff for you, for all but the most sophisticated applications.
Why not give the folks here the big picture first? Tell them what you want to accomplish, starting with the intended purpose of the application itself, and let them suggest a good approach for a beginning programmer. It will be whole lot less painful than what you are doing now.
I keep beating my head on the wall over threads because everyone keeps telling me that if I put this code which works with no problems other then it locks up the GUI had or should be put into a thread in order for it to stop locking up the GUI (form).
Why not give the folks here the big picture first?
I forked a program called hsetroot added more features to it like being able to tell the program what size you want the image and how to set it on the desktop, then renamed it mhsetroot put it in sourceforge. It is a Linux command line program that sets the background image and colors to your desktop.
I wrote a script for it with a loop in it that changes the images and colors on the desktop at a given time, and adding in the script the ability to be able to change the time that you wanted the image and colors to change just by using the command line.
then came the GUI so I could learn how to do that now.
I chose Lazarus because it had drop the stuff you need on a form easyness, and I found that they have the TProcess to use command line programs in Linux trough Lazarus therefore I need to use the TProcess. therefore it met my needs to be able to write a GUI that can use my command line program I wrote/added to.
I already wrote the program in Lazarus to do everything you can do with mhsetroot, but the changing the image and colors on the background at a given time, called it gmhsetroot, then I put that up in sourcefouge.
then comes my next challenge, making it do what I did with the script. What I am now trying to do now by adding the ability to be able to have the image and colors change on the desktop at a given time that the user sets.
I did it with the images so far, I can watch it change the image on the background at the given time it is suppose to, but giving me this problem of the button I clicked to make it do that freezing up then I got it to not do that then found that the form freezes up too. It works no problem, as it changes the image at the given time, but leaving the form froze and not refreshing. in other words it is when you run out of memory and that window just goes blank not seeing any buttons just the gray colored from. you can still move it all around the screen just no longer see any buttons and such.
that is one problem I have yet to tackle and writing the code to change the colors, and the other is killing everything when I close the form to free up the TProcess so the form closes properly. as I keep getting some errors when I close it, that I have not paid much mind to as I am dealing with this one first, and that is about all I have left to do off the top of my head to get this "upgrade' done.
in my first post it was suggested that I just put that into a thread and then it would just work. As I have no idea how to deal with threads, but if that is all I can do to get this to work then I have to use a thread, but TProcess is a Thread or has Thread Properties as it has suspend and resume. therefore a thread.
it seems that I have to deal with a Thread due to the nature of my program needing to use a loop so that it can cycle through the images and pick a different one (and colors too) then call the external program mhsetroot and have it set / change the image and colors on the desktop.
Because from what I understand that putting things in loops when using a GUI just eats up resources that is why it is locking up even though within the loop I put it to sleep.
Here is all of my CODE that has to do with this, as this form only allows so much to be written within a post I give it to all to read in a file to download, everything I have written thus far pertaining to my program mhsetroot, gmhsetroot. ie. the Big Picture.
I hope that is enough information. they are in "txt"
mod:
actually I need to not really close the program but be "hidden" so that the program if it is set to change the image and color to stay running in order to keep the TProcess running to change the image and colors(in random order). I just haven't gotten that far yet.