Showing posts with label Delphi Advanced. Show all posts
Showing posts with label Delphi Advanced. Show all posts

Thursday, March 1, 2012

How to transfer a Delphi Profile from One PC to another

Assuming that Delphi and the other VCLs are is installed in the same folder at the new PC, then the migration is fairly easy if you are comfortable working with regedit.

The information is stored in the Registry under  a key called HKEY_CURRENT_USER\Software\Borland\Delphi\5.0 or something like that. You'll find all the registration information under that key, including a list of installed packages.

Just export the keys to a registry file, copy it to the new computer and install it by double-clicking on it

Sunday, October 18, 2009

Place a Progress Bar Inside a Standard MessageBox in Delphi Apps by Delphi.About.Con

Friday October 16, 2009
in Delphi TIPS :: Let's say you have a standard Windows dialog box displaying a question to the user with "Yes" and "No" (confirm) buttons. Wouldn't it be great if a progress bar could be displayed within a dialog box "counting" seconds until the dialog box automatically closes itself?
Read the full article to learn how to Place a Progress Bar Inside a Standard MessageBox in Delphi Apps



Let's say you have a standard Windows dialog box displaying a question to the user with "Yes" and "No" buttons. Wouldn't it be great if a progress bar could be displayed within a dialog box "counting" seconds until the dialog box automatically closes itself?

  1. We first create a dialog using CreateMessageDialog
  2. This function will return a form object with dialog
  3. In this object we can add a ProgressBar
  4. We also add a Timer object for dynamic progress bar position update
  5. Show dialog using ShowModal
  6. Handle the OnTimer event of the TTimer component to see if the elapsed number of seconds has passed - if so, we close the dialog by setting the ModalResult property, from code, to mrCancel.
  7. If not, we use StepIt to update the progressbar.
Drop a TButton (Button1) on a form (Form1), and try the next code:
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.Button1Click(Sender: TObject) ;
var
   AMsgDialog : TForm;
   AProgressBar : TProgressBar;
   ATimer : TTimer;
begin
   AMsgDialog := CreateMessageDialog('Quickly! Answer Yes or No!', mtWarning, [mbYes, mbNo]) ;
   AProgressBar := TProgressBar.Create(AMsgDialog) ;
   ATimer := TTimer.Create(AMsgDialog) ;
   with AMsgDialog do
   try
    Tag := 10; //seconds!

    Caption := 'You have 10 seconds';
    Height := 150;

    with AProgressBar do begin
     Name := 'Progress';
     Parent := AMsgDialog;
     Max := AMsgDialog.Tag; //seconds
     Step := 1;
     Top := 100;
     Left := 8;
     Width := AMsgDialog.ClientWidth - 16;
    end;

    with ATimer do
    begin
     Interval := 1000;
     OnTimer:=DialogTimer;
    end;

    case ShowModal of
     ID_YES: ShowMessage('Answered "Yes".') ;
     ID_NO: ShowMessage('Answered "No".') ;
     ID_CANCEL: ShowMessage('Time up!')
    end;//case
   finally
    ATimer.OnTimer := nil;
    Free;
   end;
end;


//make sure you add this function's header in the private part of the TForm1 type declaration.
procedure TForm1.DialogTimer(Sender: TObject) ;
var
   aPB : TProgressBar;
begin
   if NOT (Sender is TTimer) then Exit;

   if ((Sender as TTimer).Owner) is TForm then
   with ((Sender as TTimer).Owner) as TForm do
   begin
     aPB := TProgressBar(FindComponent('Progress')) ;

     if aPB.Position >= aPB.Max then
       ModalResult := mrCancel
     else
       aPB.StepIt;
   end;
end;

Monday, October 5, 2009

New MDI Child Forms By Zarko Gajic, About.com

If you are creating MDI applications using Delphi, you must have noticed some "quirks" or issues that you cannot simply handle / fix from your code.
MDI interface was designed in the days of Windows 3 (some 10+ years ago) and it was designed with a single type of application in mind: a parent window that hosts multiple instances of the same class of "document" window (just think of you first MS Word).

 

Nasty MDI Child Resizing Animation

When creating (to show) an MDI child an animation of resizing will take place. This animation might look ugly if the code executed during the creation of your MDI child takes some time to process. Even if WindowState property was set to wsMaximized when an MDI child is created it will be created using Default Pos at X, Y coordinates where you left your form at design time.
Windows simply insists on creating MDI children visible and at a default position.
After creation, the MDI child will get maximized but an ugly animation will take place.

 

Quickly Create MDI Children - Eliminate "Create & Resize" Animation

To eliminate the MDI child creation and resizing animation you can send a special message to the MDI parent form, WM_SETREDRAW. The WM_SETREDRAW can be sent to a window to enable changes in that window to be redrawn or to prevent changes in that window from being redrawn. To prevent the animation flicker, have the next code in your MDI Parent form's unit:
TMDIMainForm = class(TForm)
private
  fLockClientWindowUpdateCount: Integer;
public
  constructor Create(aOwner: TComponent) ; override;
  procedure LockClientWindowUpdate;
  procedure UnlockClientWindowUpdate;
end;

...

constructor TMDIMainForm.Create(aOwner: TComponent) ;
begin
  inherited Create(aOwner) ;
  fLockClientWindowUpdateCount := 0;
end;

procedure TMDIMainForm.LockClientWindowUpdate;
begin
  if fLockClientWindowUpdateCount = 0 then SendMessage(ClientHandle, WM_SETREDRAW, 0, 0) ;
  Inc(fLockClientWindowUpdateCount) ;
end;

procedure TMDIMainForm.UnlockClientWindowUpdate;
begin
  Dec(fLockClientWindowUpdateCount) ;
  if fLockClientWindowUpdateCount = 0 then
  begin
    SendMessage(ClientHandle, WM_SETREDRAW, 1, 0) ;
    RedrawWindow(ClientHandle, nil, 0, RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_NOINTERNALPAINT)
  end
end;
Now, when you need to create (and show) an MDI client form(s), just call LockClientWindowUpdate and UnlockClientWindowUpdate. If a client window takes some time to create, you can change the cursor to let the user something (form creation) is going on:
LockClientWindowUpdate;
Screen.Cursor := crHourGlass;
try
  Application.CreateForm(MDIChildForm) ;
finally
  Screen.Cursor := crDefault;
  UnlockClientWindowUpdate;
end;
That's it. Now your MDI child forms will load faster and without the confusing animation.

Welcome to Delphi... Delphi... Delphi

I have been a Delphi Developer since Delphi 3 when I finally decided on Delphi in 1996 as my programming language of choice for the Windows 32 environment. So what have I created with Delphi ?

Would you believe that I had single-handedly created a full ERP2 system comprising ERP+CRM where ERP=Sales Distribution+MRP+ Procurement Management+Planning & Production +Finacial Management + Human Resources Management System.

Since 15th February 2009, we have visitors from more than 60 countries including Malaysia, United States, Brazil, Italy, Australia, India, Turkey, Russian Federation, Spain, Indonesia, Hungary, South Africa, Germany, Mexico, Argentina, Singapore, Saudi Arabia, Colombia, Czech Republic, Canada, France, Croatia,Thailand, Bulgaria, Slovenia, Hong Kong, Poland, Sri Lanka, Chile, Japan, Austria, Ukraine, Azerbaijan, Ireland, Tunisia, Greece, Taiwan, Egypt, Bolivia, Paraguay, Iran, Islamic Republic , Morocco, Angola, Belgium, Portugal, Norway, Venezuela, United Arab Emirates, Algeria, Korea, Republic Of, Slovakia, Georgia, Lebanon, Macedonia, Sweden, Philippines, Vietnam, Dominican Republic