Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How can I open a Paint program in the Delphi?

aryan12aryan12 Member Posts: 8
Dear all

I Have a problem with Delphi programming.
I need to access the microsoft paint program in a Delphi project and
be able to adjust it's Image Attributes before open the paint.
for example I want to make a form that contain 2 edit box component that user can enter the Image width and Image Height . after click on
button ,microsoft paint will be open with the image that has same attributes(Image width and Image Height).
if it would be possible guide me with any useful code.

best regards.

Comments

  • zibadianzibadian Member Posts: 6,349
    : Dear all
    :
    : I Have a problem with Delphi programming.
    : I need to access the microsoft paint program in a Delphi project and
    : be able to adjust it's Image Attributes before open the paint.
    : for example I want to make a form that contain 2 edit box component that user can enter the Image width and Image Height . after click on
    : button ,microsoft paint will be open with the image that has same attributes(Image width and Image Height).
    : if it would be possible guide me with any useful code.
    :
    : best regards.
    :
    :
    I would use an temporary TBitmap to save a new image. And then open that image into the Paint program using ShellExecute() (ShellApi unit). I don't think Paint supports may command line options.
    Here is a small untested code:
    [code]
    TempBM := TBitmap.Create;
    TempBM.Height := StrToInt(edtHeight.Text);
    TempBM.Width := StrToInt(edtWidth.Text);
    TempBM.SaveToFile('SomeName.bmp');
    TempBM.Free;
    ShellExecute(0, nil, 'mspaint.exe', 'SomeName.bmp', nil, SW_SHOW);
    [/code]
    The help files contain more info on the objects and functions used.
  • aryan12aryan12 Member Posts: 8
    hi

    Thanks for your kind reply.
    after I open the paint , I want to save picture to specific folder(for example D:Testsomebmp.bmp).
    How can I do this?

    best regards.

    : : Dear all
    : :
    : : I Have a problem with Delphi programming.
    : : I need to access the microsoft paint program in a Delphi project and
    : : be able to adjust it's Image Attributes before open the paint.
    : : for example I want to make a form that contain 2 edit box component that user can enter the Image width and Image Height . after click on
    : : button ,microsoft paint will be open with the image that has same attributes(Image width and Image Height).
    : : if it would be possible guide me with any useful code.
    : :
    : : best regards.
    : :
    : :
    : I would use an temporary TBitmap to save a new image. And then open that image into the Paint program using ShellExecute() (ShellApi unit). I don't think Paint supports may command line options.
    : Here is a small untested code:
    : [code]
    : TempBM := TBitmap.Create;
    : TempBM.Height := StrToInt(edtHeight.Text);
    : TempBM.Width := StrToInt(edtWidth.Text);
    : TempBM.SaveToFile('SomeName.bmp');
    : TempBM.Free;
    : ShellExecute(0, nil, 'mspaint.exe', 'SomeName.bmp', nil, SW_SHOW);
    : [/code]
    : The help files contain more info on the objects and functions used.
    :

  • zibadianzibadian Member Posts: 6,349
    : hi
    :
    : Thanks for your kind reply.
    : after I open the paint , I want to save picture to specific folder(for example D:Testsomebmp.bmp).
    : How can I do this?
    :
    : best regards.
    :
    : : : Dear all
    : : :
    : : : I Have a problem with Delphi programming.
    : : : I need to access the microsoft paint program in a Delphi project and
    : : : be able to adjust it's Image Attributes before open the paint.
    : : : for example I want to make a form that contain 2 edit box component that user can enter the Image width and Image Height . after click on
    : : : button ,microsoft paint will be open with the image that has same attributes(Image width and Image Height).
    : : : if it would be possible guide me with any useful code.
    : : :
    : : : best regards.
    : : :
    : : :
    : : I would use an temporary TBitmap to save a new image. And then open that image into the Paint program using ShellExecute() (ShellApi unit). I don't think Paint supports may command line options.
    : : Here is a small untested code:
    : : [code]
    : : TempBM := TBitmap.Create;
    : : TempBM.Height := StrToInt(edtHeight.Text);
    : : TempBM.Width := StrToInt(edtWidth.Text);
    : : TempBM.SaveToFile('SomeName.bmp');
    : : TempBM.Free;
    : : ShellExecute(0, nil, 'mspaint.exe', 'SomeName.bmp', nil, SW_SHOW);
    : : [/code]
    : : The help files contain more info on the objects and functions used.
    : :
    :
    :
    What is it you want to accomplish? Perhaps there are easier ways to code this, because controlling Paint from another program is quite elaborate and difficult. The only way to perform this is to create a keyboard playback journal.
Sign In or Register to comment.