#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    2
    Rep Power
    0

    Delphi-code to Kylix conversion


    Let's see if this forum has advanced programmers enough.

    I've been looking for solutions to these things for several months now (using Kylix 3 Open Edition). I'll divide this question into 3 parts. If you know any answers at all, I appreciate it a lot. I know it's a long question, so I'm not expecting to get answered to everything.

    1. Graphics programming. What are the Kylix-equivalents for these objects and functions (or is there a library I can add to "uses"-section to use them as they are?):

    SRCCOPY
    HDC
    HBitmap
    CreateCompatibleDC
    CreateCompatibleBitmap
    SelectObject


    2. How can I copy files? Like the CopyFile-function in Delphi, cannot find similar in Kylix.


    3. How can I execute commands and files (like ShellExecute in Windows)? Like, say, to start "kwrite" from my program. The Libc-functions for this don't seem to work, or then I'm not using them right.


    Thank you in advance for any answers!
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4248
    1. Are you trying to port some Windows components to Linux? All those items in that list are Windows API types and are non-portable to linux.

    2. CopyFile is a Windows API function, not a Delphi or Kylix function. Your best bet is to write your own function. This isn't very hard to do -- All you need is to open the source file, read it in chunks and write out the data file. This can be done using Assign, Read and Write functions which are standard Pascal and should be portable across multiple platforms.

    3. Use libc.system()
    Code:
    uses Libc;
    
    procedure RunSomething(sProgram: string);
    begin
        if libc.system(sProgram) = -1 then
            ShowMessage('Cannot start the program.') ;
    end;
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    2
    Rep Power
    0
    Thank you so much!

    Yes, I can write my own file copying function, no problem. Just was wondering, if there was already such thing, like in Delphi.

    What would be the best way of replacing those graphic functions and objects? Yes, I'm trying to port LOTS of Delphi-code to Kylix. Managed to port huge amount of it already, but just as much still remains and needs more work.
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4248
    Unfortunately the X Windows API is way different from the MS Windows SDK and there isn't an easy way to port those API calls over.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    1
    Rep Power
    0

    Angry libc is not working on Kylix 3?


    uses Libc;

    procedure RunSomething(sProgram: string);
    begin
    if libc.system(sProgram) = -1 then
    ShowMessage('Cannot start the program.') ;
    end;
    [/code][/QUOTE]


    is this working on Kylix 3 ????

    my test code:

    procedure TForm1.Test1Click(Sender: TObject);
    begin

    if Libc.system('xmms') <> -1 then
    showmessage('library loaded successfully')
    else
    ShowMessage ('Cannot start the program');

    end;

    it doesn't execute xmms. I'm using Kylix 3 on Slackware 10.

IMN logo majestic logo threadwatch logo seochat tools logo