With the bare tips you give, I can only tell you: press the print key on your keyboard and wait!
...or programatically, you can do the same from the form code just using this:
Print;
With the bare tips you give, I can only tell you: press the print key on your keyboard and wait!
...or programatically, you can do the same from the form code just using this:
Print;
It depends on the database you are using: SQLServer, Access, etc., each one will have its own means to launch a backup proccess.
Once you know the database you are using, then you can search on google (or send a more concise question here), I can't help you on that as I don'0t use MS databaes at all (but kbow about others).
My advise in general (may be doesn't help here, but I'd try): Use a temporary var to store HardwarePressureModule.RegulatorSettings instead of "with", then manipulate this var:
ThisOne:= HardwarePressureModule.RegulatorSettings;
ThisOne.RegulatorOutputId := RegulatorOutputNumber;
I think I see your problem: RegulatroSetting is a property, so assigning a value to it will call the SetRegulatorSetting, but, in the Get function you add a equally named variable, RegulatorSetting, that can be -and is- confused with the property it self!
Avoid using the same name for 2 different things: Call this variable TmpRegulatorSetting, for instance!
Another tip: Avoid using "with" as much as possible (and you can avoid it always), may be it works ok now and saves a little typing, but if in a future you add a new property to the base class (form) with the same name as one property on the "with" object, this piece of code, without being modified at all, will change it behaviuor... and you will hardly notice it. Freaking!
function THardwarePressureModule.GetRegulatorSettings(RegulatorId : integer) : TRegulatorSettings;
var
RegulatorSettings : TRegulatorSettings;
begin
if((0 <= RegulatorId) and (RegulatorId < FRegulatorCount)) then
begin
RegulatorSettings := {Witch one are you referring here? The property or the local variable?}
Hi Khiro, you post a piece of code but don't ask anything at all... so?
Not so simple... a .DFM is mandatory in that case, so you better find a computer that works and make it run... or you plan to debug/adjust output it remotely?
And, btw, I think you will need a TImage on top of the form in order to paint something on its canvas.
You can't autofix a database, here or in the moon.
In SQl you can make a select to gather all the info you mention: Tablas, index on this tables... all depend on the database you use... for FireBird, i have some examples, but you can find them easily googling too.
Here i collect all of them:
Many, basically trying to do something not matematically possible: Divide by cero, log of a negative number, sqrt of a negative number... and also operations with a result out of the limits: a:= Power(999,999) for instance won't fit in your PC!
...and FireBird is real free and open software, multiuser, transactions... all you need is there for free.
FireBird is my clear choice: You have an "embeded" version that doesn't need to installl nothing, just copy a dll along with your exe and thats all (ofcourse no BDE install or anything, nothing).
Yo can even access a database in read-only mode from your app having all the file in a CD... like a CD catalog, or a product database rightout from the CD, no installation (we use USB disk to distribute our demos with zero installation, you can even copy the folder to your desktop and double click the exe and there you go).
And btw, Paradox is an unsecure as dbase for me.
May be the initial database is corrupt, and a cicle of backup-restore fix it, so the resulting database can access asll the records, while the first one can't.
Try deleting the indexes, then re-creating them again (or reconstruct it if such an option is on your database manager).
If form is modal, just make ModalResult:= mrOK (or place a button of kind=ok, it is allready made in the standard buton properties).
If the form is not modal, just make "close" and that is all.
HEY! I have it!
I checked Word does it in options, select default locations, just hide the file type and file name component and use the '*.' trick commented above, so it looks as you should expect!
It is a little tricky: On the dialog OnSohw you need to send some win32 messages to the dialog and voila! it is done... in the code I placed all the links to the places where I found all the info, so you can change it to your needs.
NOTE: I copy-pasted from within my code, it is not a uinit just for this, so the uses is commented. You need to copy it to a unit of you and make sure the Messages is in you uses clause.
//***********************
//** Chose a directory **
//** uses Messages **
//***********************
//General usage here:
// http://www.delphipages.com/forum/showthread.php?p=185734
//Need a class to hold a procedure to be called by Dialog.OnShow:
type TOpenDir = class(TObject)
public
Dialog: TOpenDialog;
procedure HideControls(Sender: TObject);
end;
//This procedure hides de combo box of file types...
procedure TOpenDir.HideControls(Sender: TObject);
const
//CDM_HIDECONTROL and CDM_SETCONTROLTEXT values from:
// doc.ddart.net/msdn/header/include/commdlg.h.html
// CMD_HIDECONTROL = CMD_FIRST + 5 = (WM_USER + 100) + 5;
//Usage of CDM_HIDECONTROL and CDM_SETCONTROLTEXT here:
// msdn.microsoft.com/en-us/library/ms646853%28VS.85%29.aspx
// msdn.microsoft.com/en-us/library/ms646855%28VS.85%29.aspx
CDM_HIDECONTROL = WM_USER + 100 + 5;
CDM_SETCONTROLTEXT = WM_USER + 100 + 4;
//Component IDs from:
// msdn.microsoft.com/en-us/library/ms646960%28VS.85%29.aspx#_win32_Open_and_Save_As_Dialog_Box_Customization
//Translation into exadecimal in dlgs.h:
// www.koders.com/c/fidCD2C946367FEE401460B8A91A3DB62F7D9CE3244.aspx
//
//File type filter...
cmb1: integer = $470; //Combo box with list …
It should be placed on the MyForm.FromClose event, so closing (not being show in the screen) equals freeing the object:
procedure TMyForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:= caFree;
end;
The idea is that Creating is the oposite to Freeing the form, but closing is not, closing is the opposite to Showing the form. When user close the form, it is not shown, but it is not freed: You could make it visible again if you had a pointer to the form stored.
If I am right, **ptr is a pointer to an array of pointers to short integers... in delphi it is not used like this (thanks, Lord!).
If you know the lengths of the arrays when coding:
var a: array[0..10, 0..20] of short;
Then you pass a as paramter, and use a[0] as the first pointer, a[1]... etc.
If the lengths are not know (as i suppose), you just make this:
a: array of array of short;
And in the code, to set the lengths:
SetLength(a, 10); //10 pointers to arrays of shorts;
for i:= Low(a) to High(a) do
SetLength(a[i], 20); //Each one with 20 elements (could be different for each array)
So you don't need to play with pointers of pointer to pointer that point to shorts or any other tipycal C puzzles, just pass an "a" and it is done.
As I understood: You have a form "A" with a button to open a form"B", and also form "A" must close itself automatically.
First, you need a Application.MainForm always present, it may be a menu, a wellcome splash (make it invisible, don't free it) but anyway you NEED a mainform.
Usually this is the only autocreate form in your app. preferences, no more autocreate forms are needed as you are going to create them by code (delphi tends to autocreate one form of each type, take them out of the autocreate list).
So, the unit "A" should be like this:
1) Add in the unit A uses the unit B.
2) On the buton click, you do like this (or similar):
with TMyFormB.create(Application.MainForm) do
Show;
3) Next you must close this form with a self.close;
4) Closing is not the same a freeing, so on MyFormA.OnClose you need to add a line with "Action:= caFree;". With that line, closing a form will really kill it from memory. Ah! Add thisa to all your forms if you what not to keep them on memory after closing them!
I think it is all... it also answer your second question about closing forms.
Easy: One of them uses the other in the interface (on top of the code), while in the other one, after the "implementation" clause, you add a new "uses" -if it is not there by now- and add the unit you need.
In that second unit, the classes defined in the 1st are not availabe on the interface part, because the uses is lower than this, so you can not define a function, for instance, as having a parameter of some of the clases defined in unit 2, so chosing witch one will have the other unit uses in the top is a matter of witch one uses the oither one classes in the interface.
Both unit CAN NOT use the other one clasess on the interface, this is not fixable as long as i know, but i never have had the need of it, and if you need it, then pass a TComponet and, in the implementation, cast it to the proper type and you get the same working.
Each TMonitor has its own left and top intial position: if your second monitor is on the left side and main monitor is 1600 width, its left property can be like 1601 (and top = 0 in that case), so on Form.FormCreate you can read this and make
Self.Left:= Screen.Monitors[1].Left;
(for instance), so placing your form depending on monitor top, left, height and width should make it appear on center of the secondary monitor (again, not tested!).
cao: Yes, your code solve the exact example showed, but you assume the - will always be on the same positions... it is not said anywhere, so if next string suplied is, for instance, 0-9-120-123456 Have you tested your code with that one? It will mesh up averything.
maracaibolago: Reading your question again, you don't give all the details to be able to know your problem:
All the string you are going to format are going to be in that EXACTLY format, or can they come with more/less '-' or bigger number in between?
Why you add zero in a particular '-' and not in the other one?
What if the string doesn't has any '-'? Where do you add zeros?
And more disgusting: Why the code you finaslly supplie DOESN'T format the example you gave like in your example? (the zeros are added in diferent positions) Why your example only has 12 chars? Why in your example you added a zero in exactly that position ?
Anyway, I think this question was imposible to solve with the info and example given, so all the code we have sent, is useless...
Ops! didn't see it, and i promise i really was looking -actively- for it!
Thanxs forp the info Tom!
Imagine I want to see all code snippet on delphi only... I can't!
From web development I can jump to delphi FORUMS, not to delphi SNIPPETS, and in the "Revamped code snippets" page, I can't filter on a languaje... Isn't it the most basic feature on a code repository mixing several languajes?
The only way I managed to get this is a pain: Go to code snippet, browse some pages until a delphi one comes, then click on the "DELPHI" title and there you are.
I suggest those 3 changes:
1) In the "Software development" page (http://www.daniweb.com/forums/forum2.html) it should be 2 links for each languaje: Forum, Code snippets.
2) Jumping to "Revamped code sniped" should give you a easy way to filter one languaje only.
3) Once in the delphi -any languaje- forum, a link to the delphi code snippets (along or replacing the general "Revamped code snippets").
..or may be I am missing some option, in witch case, it should be a lot more visible than it is... I couldn't find it ;-)
"Screen.Monitors" has a list of installed monitors, and Forms have the "monitor" property where you could try to fix where you want it to appear in the FormCreate event... have you tried this (i don't have 2 monitor here to give it a try)?
(All this info just typing "monitor" on the delphi help)
What a dificult way to do such a simple thing!
quaifp1:
You avoid using Pos('-', txt) and instead construct a whole piece of code to do it! And then repeat the same with StringReplace... all your code is done with my one-line-code!
cao:
Your code doesn't do anything, the string could be different each time, and changing the first '-' with a '0' is not the point anyway.
Well, you can format a number into string, or a date into string, but formating a string... it is just not the word, it is more a transformation... well, who minds about the name!
In your case, you just want to change all '-' with '', so you onlky need it:
MyText:= StringReplace(MyText, '-', '', [rfReplaceAll]);
So thew components you use to connect to SQL server are not purchased, are in test-mode, and you need to move to another components to connect to the database.
I can't help you in that, I don't connect to databases except FireBird, and, in that case, use my own components (based on the old FreeIB components).
No, I don0t use threads usually, but creating a new thread and playing the media player from it is like dividing your app. into 2 different tasks, one is the main one, and the other is the one that launch mediaplayer and has to wait until it finish.
Is like in firefox: While one tab is bussy, the others are not, and the main thread (the menus and so) are running even if all the tabs are bussy. FDirefox uses 1 thread per tab + a main thread.
Anyway, you should have to look for TThread help or use google, I always managed to live without it, but it is a good resource is you get used to this (and you can, for instance, use several CPU from your app using it!).
It seems like unless I set Wait := True there will be no sound. This however means the program can not do anything else while a sound is played. Is that realy the case??
Nop! If mediaplayer behaves like this, acept it an try it other way: Create a new thread that launch the sound with wait:= true, when THIS thread recover the control, it can set a global variable to signal it is finish to the main thread.
-Make another thread, and call the media player.
-This thread, on completion, call a procedure or set a variable to true.
-The thread suicide.
When this variable is set to true, internally it can be a proerty with a write method, so basically, the thread calls a method, then die.
You can play the next sound after this method is called, and, in the menawhile, your app is live and working as expected.
andrewgalpin: your code count SPACES, not words... try it out with this text "hello bye", you won't get a 2, instead you will get the spaces between words... is NOT the same, and if you try to detect "first space" from "subsecuent spaces", then you end up with the original code, but several times slower if don't use pointewrs.
If you have ONE table, you can't append two dataset... something is not right in your question... if you have 2 tables and want to mix them into a single query, you should try UNION, as far as you are accesing those record via SQL.
With the info you sent, that's all I can say!
If you have ONE table, you can't append two dataset... something is not right in your question... if you have " tables and want to mix them into a single query, you should try UNION, as far as you are accesing those record via SQL.
With the info you sent, that's all I can say!
Ops! midas.dll could be the problem, it comes with delphi as a try-out component, you should need to check it and, if neccesary, use another component for the stored procedure.
Anyhow, with a SQL comoponet, you can also execute your procedure, just make sql.text:= 'execute procedure MyProcedure' and execute your query as if it where another thing!
In the OnNotify event, do you set Notify:= true again? You should.
Read a little more about it here: http://www.delphipages.com/forum/showthread.php?t=78624
A link to a screenshoot would be of help, I don't know what kind of puzzle you are trying to achieve...
It sounds to me like a work for a TStringGrid better that any TRichEdit, as you can place text inside "excel like" grid and manage it very freely.
I have seen your example: You want the scroll bar to detect and display correctly when button.top=-55, but you simple can't, negative tops are objets OUT of the scrollbox, it can hold components with top as big as needed, and the scroll bar will reflect it, but negative tops or lefts are simple object clipped away, out of reach.
Just try to set top to -55 visually on the IDE, the component disapear, there is nothing above the top.
I would just avoid this situation: If the most upper componet you have on your scrollbox has a top of 35, for instance, get this value -in a for loop of all its components, for instance- and put on a variable. Each time you scroll, inc. or dec. this value, and don't let scroll up if this value is zero. This will make objets to stop on top of the panel.
Boy, I can't imagine why delphi is needed... some components only run when delphi is on until you register, but it doesn't sound like you are using them, but check this, may be some other components you are using are in "test mode" and need delphi IDE to be present.
It is usually checked (that delphi IDE is present) with
IF (FindWindow('TAppBuilder', nil)>0) THEN...
...try searching 'TAPPBUILDER' in your code, but also it can be in a .dcu of some component in "test-mode" as i told you.
There is a very good unit called Launch.pas out there in the net, i grabbed it time ago and have added more functions over the time (not in the authors initial text, sorry), like one to wait until some exe drop below 1%CPU usage.
I copy it here so you can add to your app if useful:
{************************************************************************}
{* *}
{* file : Launch.PAS *}
{* *}
{* type : unit *}
{* *}
{* location : \QUIRT\SRC\DELPHI *}
{* *}
{* purpose : Launch external programs *}
{* *}
{* author : Lennert Ploeger (NKI / AVL) *}
{* *}
{* date : 19980325 *}
{* *}
{* portability: 32 bit delphi only (V2.0 up) *}
{* *}
{* notes : None *}
{* *}
{************************************************************************}
{* Updates:
When Who What
19980325 lsp Created
19980331 lsp Search for programs in PATH using SearchPath()
19980609 lsp Allow white-spaces for the program to launch
19980709 lsp Allow 'prog' to be empty in StartProgram
19980731 lsp Enclose both file and directory names in double quotes
19980901 lsp Removed some obsolete functions
19981004 mvh Added RunProgram (waits until ready)
19981005 mvh Renamed to RunProgramBlocking (waits until ready)
19981020 lsp Program launched in RunProgramBlocking() is started
minimized and not given focus
19990110 mvh RunProgramBlocking returns value
19990111 lsp Fixed comment about CloseHandle()
19990112 mvh Added RunProgramWaiting, shortened code by reuse
19990425 lsp FileUtil -> QFileUtil
19990609 lsp Removed QFileUtil dependency
*}
unit Launch;
interface
//Para pasar de ProcId a THandle
type
TWindowRec = …
Why do you need to activate the hint (Application.ActivateHint(P)) by code?
If grid.showhint is true, just changing the hint text should be ok... have you tried it without this line?
Anyhow, the application.onhint event is tricky, for a component that can have several instances on one app, using this event is tricky, as only one event handler can exists, and you need one per grid and manage it when one is freed... dificult one!
Yuo can use a 0 to 4 counter from a intenger incremented one by using (iRTeller mod 4), and aduust visibility by using a Visible:= ((iRTeller mod 4)=1), so your big code get this small (also note my different indentation, far more legible for me):
procedure TfrmRobot.tmrRobotTimer(Sender: TObject);
begin
if iTeller < iSiklusse then begin
Inc(iRTeller, 1);
//Set visibility
shpGroen.Visible := ((iRTeller mod 4)=1);
shpOranje.Visible := ((iRTeller mod 4)=2);
shpRed.Visible := ((iRTeller mod 4)=3);
if ((iRTeller mod 4)=0) then Inc(iTeller);
end;
end;
You also need this to compile:
function FileTime2Milliseconds(FileTime: TFileTime): integer;
var ST: TSystemTime;
begin
FileTimeToSystemTime(FileTime, ST);
result:= ST.wMilliseconds + 1000 *
(ST.wSecond + 60 * (ST.wMinute + 60 * ST.wHour)) ;
end;
Ops, sorry the code comments are in spanish... they don't say nothing specially interesting anyhow!
Well, you ask for help, but please, don't demand it!
If 210 reads your question and don't understand it, or don't know any usefull answer, may be your question is too dificult, or too long (IT IS TOOOOO LONG in it's initial form) or described too poorly.
Anyway, I will make a little try... I never used IWebBrowser, but it is just a IExplorer showed in your form using something similar to a TOLEContainer, so you could know it by checking if iexplorer.exe is iddle (0% of CPU usage) looking at the procces explorer. Easy to say!
I came into a similar problem with Word, and solved it this way, it was not easy to find out all those internals, but here you have, hope it solves your problem (it detects 1%CPU, change it to 0% if you need it).
I copy it here in two flavours: Passing a thandle of the procces (dificult way) or passing a exe file name (easy way) that is internally converted to a thandle:
//Wait for a proccess to be below 1%CPU using its filename
function WaitExeIddle(ExeFileName: string; MinSeg: double = 0.1; MaxSeg: double = 10): double;
begin
result:= WaitProcIddle(GetProcHandle(ExeFileName), MinSeg, MaxSeg);
end;
//Convert 'WINWORD.EXE' to a valid proccess THandle
function GetProcHandle(ExeFileName: string): THandle;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result:= 0;
FSnapshotHandle:= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize:= Sizeof(FProcessEntry32);
ContinueLoop:= Process32First(FSnapshotHandle, FProcessEntry32);
while integer(ContinueLoop) <> 0 do begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName))
or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then begin
result:= OpenProcess(PROCESS_ALL_ACCESS, …
You can do it by using a TOleContainer component placed on your form, read the help on this componet, you have all you need in there, also you can "mix" word menus with yours if neccesary.
Just doing a "round(YourDate-now);" (both TDateTime or TDate) would do the work, but, you are supposing the user won't play with the system clock to fool your system!
Have you checked the rave help for a savetofile or savetocsv?
Do you need the raw data or the report as an image?
Do you need it to be automated from code, or just a way the user can do it for a given on-screen report?
Anyway, try using a PDF printer, for instance, PDFCreator can save in PDF, but also in JPEG if neccesary, so you can paste it into an email.
This printer can be commanded for your app via registry or via com object, so you can autosave to a folder with the names you need and in the format you need (not exactly easy, but possible and works ok).
Supposing the 30 TEdit are in a TPanel called Panel1, I would do it like this:
for i:= 0 to 29 do
TEdit(Panel1.FindChildControl('E'+IntToStr(i))).Text:= a[i];
This is the most similar to your example it can get, but, I would do it a little more robust:
for i:= 0 to 29 do begin
MyEdit:= TEdit(Panel1.FindChildControl('E'+IntToStr(i)));
if Assigned(MyEdit) then
MyEdit.Text:= a[i];
end;
About a free pascal IDE+compiler, you have FreePascal + Lazarus, very delphi like and do compile for mac, linux, windows... even iPhone I read today!
The only bad things compared to delphi is that it takes much more time to compile (delphi is king here) and the exe file size is also much bigger.
Click on fayyaz name on one of his post, on the profile page, go down and press "Send message", so a private message is sent to him, and delivered to his personal email... well, I will do it that way instead of using the forum ;-)
1) ScrollBox, as any other componet, use positive positions, having the origin (0,0) on top-left, so you can't place anything above the top, it would be a negative value on top property, so it will be clipped away.
The only work around -if you realy need to do this- is that, when a component is placed above top, let say you need a top=-10, then set top to 0 on this objet and, on ALL other objects in your scrollbox, add 10 to theirs top, so relative positions remain as desired (grafically no scroll bar, but the "backgroud" fall down with all your component on it).
2) Step by step:
-Place a TApplicationEvents on your form, i named it MouseWheelEvent.
-Define a event handler on it for the "OnMessage" event to handle it all, it should look like this:
procedure TGPagView.MouseWheelEventMessage(var Msg: tagMSG;
var Handled: Boolean);
var i: SmallInt;
begin
//Form is active?
if Active then begin
//Was it a wheel move?
if (Msg.message = WM_MOUSEWHEEL) then begin
//Extract mouse wheel movement (positive, negative, small, etc)
i:= HiWord(Msg.wParam);
//Cancel the message so it don't do anything more
Handled:= true;
//Do whatever you need using i as a wheel movement measure...
Form.Caption:= 'Wheel moved '+IntToStr(i)+' ticks.';
end;
end;
end;
Important notice: While the form is not totally freed, it will catch events and try to process them, so be …
You need a special component to do this for you, if you don't want to code each dot of the graph by yourself directly to a canvas...
My Delphi 7 has a built-in DBChart componet on the DB control palette, drop one on your form, select it, and press F1 to know how to fill it with your data... or download one of the many free tee chart components out there if this one doesn't match your needs.
Your grid is a TDBGrid or a TStringGrid?
Your problem is to calculate those totals or to add them to the Grid?
Anyhow, those kind of things will need you to code them, and, in a DBGrid you won't be able to "add a last line" as each line represent a record in your table.
How do you connect to the DB?
Where does those procedure live (trigger asociated to a table, on the DB itself, on the delphi code...)?
I would take a little more info to solve, but looks strange anyhow (MS Office component uses to behave strange some times BTW).