borland 5.02 - api/gui

This is a discussion on borland 5.02 - api/gui within the C++ Programming forums, part of the General Programming Boards category; how can I get the below to compile in Borland 5.02 [code] #include <windows.h> int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) ...

  1. #1
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167

    borland 5.02 - api/gui

    how can I get the below to compile in Borland 5.02

    [code]
    #include <windows.h>

    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    MessageBox(NULL, "Hello world!", "Sample", MB_OK);
    return 0;
    }
    [/code
    AIM: MarderIII

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    You need to add parameter names to your function!

    Code:
    // function prototype (which you're not doing, you're adding code)
    // both these lines are the same
    void blah(int,int);
    void blah(int a, int b);
    
    // correct with code
    void blah(int a, int b) { /*...*/ }

  3. #3
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    I dont understand what you are trying to tell me.
    AIM: MarderIII

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    What error message do you get when you compile?

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    I dont understand what you are trying to tell me.
    Speedy5 is trying to tell you that HINSTANCE, LPSTR, and int are DATA TYPES, not variable values! I don't have my windows programming book with me, and I don't remember how to get these values. But, they are supposed to come from an existing window. HINSTANCE = handle to window instance, LPSTR = long pointer to string,, you know what an int is.. (I think the 2nd HINSTANCE can be NULL?)

    You have to pass values (or pointers, or references) to a function.

    Windows programming is NOT EASY! But I think there are some short-cuts if you just want a message box.

    BTW - The datatypes are the just the "normal" types renamed with "typedef" in windows.h

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    This works with Microsoft Visual C++ :

    Code:
    #include <windows.h>   
    
    int main()
    {
         char Message[] = "Here's the message!!!";
         char Title[] = "My Message Box";
         int Button = MB_OK;    // Defined in windows.h
    
         MessageBox(NULL, Message, Title, Button);
    
    return 0;  
    }
    From Microsoft Visual C++ documentation:

    int MessageBox(
    HWND hWnd, // handle of owner window
    LPCTSTR lpText, // address of text in message box
    LPCTSTR lpCaption, // address of title of message box
    UINT uType // style of message box

    );

    I assume that the borland compiler is similar.
    Last edited by DougDbug; 02-10-2003 at 09:31 PM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21