VERR_NO_MEMORY error while importing VirtualBox appliance in OVF format

Posted May 28, 2011 by toom
Categories: linux

Tags: , ,

While trying to import a VirtualBox appliance (~2.3G) in OVF format on my linux box with VirtualBox 4.0.8-71778 it ended up with the error:

Could not read OVF file ‘exported_ovf_file.ovf’ (VERR_NO_MEMORY)

To fix this, just unpack the odf file:

tar xvf exported_ovf_file.ovf

and import the unpacked ovf in VirtualBox.

Linda 20080203

Posted February 9, 2008 by toom
Categories: personal

Linda Toom 03.02.2008

One happy day

Posted January 21, 2008 by toom
Categories: personal

Well, if this isn’t one happy day, then what is?

Force TDateTimePicker to drop down

Posted August 30, 2007 by toom
Categories: datetimepicker, delphi

Unfortunately there’s no message to send to TDateTimePicker which would cause it to drop down the calendar. Since the picker is designed to drop down by pressing either F4 or Alt-Down arrow, one can mimic the keypress and get the desired result with the following code:

  ...
  DateTimePicker1.Perform(WM_KEYDOWN, VK_F4, 0);
  DateTimePicker1.Perform(WM_KEYUP, VK_F4, 0);
  ...

Change button texts on message dialog

Posted May 17, 2007 by toom
Categories: delphi, messagebox

Today customer wanted me to change the typical ‘OK’/’Cancel’ on one of the message dialogs in our app. While browsing through Delphi help and Windows SDK I came up with the idea to use CreateMessageDialog() function:

CreateMessageDialog returns a dialog of the type specified by the DlgType parameter and with the buttons indicated by the Buttons parameter.

Note the … returns a dialog … part here: I now have control over the TForm the function produces and all I have to do, is change captions on the TButton components on this form:

...
var
  i: integer;
begin

  with CreateMessageDialog(
    'Do You want to do something destructive today?',
    mtConfirmation,
    [mbYes, mbNo]) do try
    // go through all the components on the form
    for i := 0 to ComponentCount - 1 do
      // if we have a button ...
      if Components[i] is TButton then
        // it's the 'Yes' button
        if TButton(Components[i]).ModalResult = 
          mrYes then
          TButton(Components[i]).Caption := 'Yeah!'
        else // otherwise it's the 'No' button
          TButton(Components[i]).Caption := 'Nope';
    // CreateMessageDialog() onlt creates the form
    if ShowModal() = mrYes then
      DoSomeThingDestructive()
    else
      ForgetAboutIt();

  finally
    Free();
  end;

...

Of course, You can use other combination of buttons (eg. mbYesNoCancel) when creating the dialog and the appropriate modal results when changing captions before showing it to user.

Here’s the result of the code snippet above:

Messagebox with changed button texts

MessageDlg change default button

Posted February 14, 2007 by toom
Categories: delphi, messagebox

How about creating a message box with the typical Yes-No buttons, but we want to:

  1. keep the order of buttons as it’s done everywhere;
  2. do not want to change the question so Yes becomes No and vice versa;
  3. wanna make the No button as the default button for users who keep pressing Enter/Space for every question asked.

Even though Delphi 7’s helpfile shows that we can set a default button in a message dialog when using MessageDlg() function

function MessageDlg(const Msg: WideString; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; DefaultBtn: TMsgDlgBtn = mbNone; Bitmap: TBitmap = nil): Integer; overload;

and there’s even an example which uses it

if MessageDlg(‘Welcome to my Delphi application. Exit now?’,
mtConfirmation, [mbYes, mbNo], 0, mbYes) = mrYes then

but it turns out that these overloaded methods are implemented in QDialogs and not in Dialogs.

Easiest way to solve my problem was to use TApplication.MessageBox() method:

Use MessageBox to display a generic dialog box a message and one or more buttons.

And the code is something like:

if Application.MessageBox(
  PChar('Do You want to do something destructive today?'),
  PChar('Confirm'),
  MB_YESNO or MB_DEFBUTTON2 or MB_ICONQUESTION) = IDYES then
  DoSomethingDestructive()
else
  ForgetAboutIt();

Messagebox default button

Show hint on disabled control

Posted January 29, 2007 by toom
Categories: delphi

If a control is disabled (Enable = False) then the mouseover hint is not shown. If You need to show the hint then put the control on a TPanel and set TPanel’s Hint property. Or just put a TPanel behind the control (send to back) – this works also.

Showing hint on disabled control

Popup menu with MDI

Posted January 11, 2007 by toom
Categories: delphi, popup

Situation: we have a MDI application whose main form (FormStyle = fsMDIForm) has a TPopupMenu (MainForm.PopupMenu = PopupMenu1) for some shortcut functions when user clicks mouse on the main form.

Problem: this PopupMenu1 is popping up everywhere in all the MDI children windows, but we want to use for example the Windows default popup menu in edit boxes:

editbox_popupmenu.png

Solution: Remove the PopupMenu1 from main form’s properties and create an OnContextPopup event handler:

procedure TMainForm.FormContextPopup(Sender: TObject;
  MousePos: TPoint; var Handled: Boolean);
var
  ScreenPoint: TPoint;
begin
  // convert client area coordinates
  // to global screen coordinates
  ScreenPoint := ClientToScreen(MousePos);
  // see if the control under cursor in our main form
  if (FindDragTarget(ScreenPoint, True) is TMainForm)
  then begin
    // show our shortcut menu
    PopupMenu1.Popup(ScreenPoint.X, ScreenPoint.Y);
    // we handled the request for context menu
    Handled := True;
  end;
end;

Testing Estonian National identification number (isikukood)

Posted January 7, 2007 by toom
Categories: delphi

As a followup to the SOTU checking function, here’s a function that checks the validity of Estonian National identification number.

 Read the rest of this post »

Testing Finnish National identification number (SOTU)

Posted January 5, 2007 by toom
Categories: delphi, string

Here’s a sample function to test the validity of Finnish National identification number (henkilötunnus (HETU)), formerly known as sosiaaliturvatunnus (SOTU)).

 Read the rest of this post »