Best place to see examples on how to use Win32 API function in delphi

Discussion in 'Programming General' started by Kar Na Vor, May 28, 2013.

Best place to see examples on how to use Win32 API function in delphi
  1. Unread #1 - May 28, 2013 at 12:12 PM
  2. Kar Na Vor
    Joined:
    May 25, 2013
    Posts:
    26
    Referrals:
    0
    Sythe Gold:
    0

    Kar Na Vor Member

    Best place to see examples on how to use Win32 API function in delphi

    well i have been experimenting with the Win32 API in Delphi and I'm unsure on where to look on examples to use them..seeing how the MSDN only show's C++ examples.

    I have dug through Delphi 7's help file and well... im a little confused so i will just paste my working code i found and the code the help files shows me, i dont understand how it translates into my working code...unless the code im using is some how butchered up.

    so here is the code im experimenting with now using the SetConsoleTextAttribute function

    ----My code that i know works and changes color----

    Code:
    begin
       SetConsoleTextAttribute(GetStdHandle(
                              STD_OUTPUT_HANDLE),
                              FOREGROUND_RED OR
                              BACKGROUND_BLUE);
    
      Writeln('Red text on a blue background !');
      ReadLn;
    end.
    ----------End working code---------------------

    --------Now here is a snip from the official delphi documentation-----

    Code:
    BOOL SetConsoleTextAttribute(
    
        HANDLE hConsoleOutput,  // handle of console screen buffer  
        WORD wAttributes    // text and background colors 
       ); 
    Code:
    Parameters
    
    hConsoleOutput
    
    Identifies a console screen buffer. The handle must have GENERIC_READ access.
    
    wAttributes
    
    Specifies the foreground and background color attributes. Any combination of the following values can be specified: FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the following combination of values produces white text on a black background:
    
    FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
    ------End Delphi help------

    Can someone please tell me what cylinder in my head is not firing on this?
     
  3. Unread #2 - Jun 10, 2013 at 10:56 AM
  4. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    Best place to see examples on how to use Win32 API function in delphi

    There are two arguments for the console text function you have there, one is the window handle and one is the color. The window handle is basically just a window ID, so that we can find and manipulate the console window. The colors are, well, colors, and by introducing OR, you can put two arguments in one (setting the foreground color and background color at once).


    For experimenting with the API, your function calls will be the same in C++ as they are in Delphi. Most Win32 calls use constants which are really just numbers, so you won't often have to worry about type conversions.
     
< Pluralsight? | C# Request. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site