OS X Carbon GUI

This is a discussion on OS X Carbon GUI within the C Programming forums, part of the General Programming Boards category; Positng this question here for lack of a better place to put it. Here is the code I'm messing with: ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    77

    OS X Carbon GUI

    Positng this question here for lack of a better place to put it.

    Here is the code I'm messing with:
    Code:
    #include<Carbon/Carbon.h>
    
    int main(int ArgC, char **ArgV)
    {
        Rect rPos;
        WindowRef Handle;
        EventTypeSpec etsEventTypes[2];
        
        rPos.top = 200;
        rPos.left = 300;
        rPos.bottom = 400;
        rPos.right = 500;
    
        //Create the window
        CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | 
            kWindowStandardHandlerAttribute, &rPos, &Handle);
        
        //Show the window
        ShowWindow(Handle);
        
        RunApplicationEventLoop();
        //Remove the winow
        DisposeWindow(Handle);
        
        return 0;
    }
    And I compile it with:
    Code:
    gcc OSXGUI.c -framework Carbon
    The code does create a window. Te problem is the window won't respond to anything.

    According to the API docs, the call to RunApplicationEventLoop() is supposed to install the default event handler to the window. That default handler is supposed to handle the basic requests; maximize, minimize, resize, and move. Except its not doing that. The window will maximize and minimize, but not move or resize.

    Am I compiling it wrong (It seems to want to be a console app as opposed to a GUI app)? Or is there some other issue with my code?

    My guess is the event loop that is created is for the thread rather than the application, since if I install my own event handler it never recieves anything. But I just don't know, and the documentation Apple has doesn't cover windows that aren't made from NIB's very well.

    [EDIT]
    Well even if its creating an event loop for the thread that shouldn't matter. I replaced the call to RunApplicationEventLoop() with my own event loop:
    Code:
    eventRecord Event;
    while(1)
    {
        WaitNextEvent(everyEvent, &Event, (unsigned int)-1, NULL);
        printf("Got an event!\n");
    }
    and the loop was given events for the window. I didn't see any events for move or size requests though.
    [/EDIT]
    Last edited by Exile; 02-06-2005 at 06:27 AM.
    So, do you understand everything you know about this yet?

    "Begin at the beginning," the King said, very gravely, "and go on till you come to the end; then stop."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a simple OS
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 06-06-2004, 10:47 PM
  2. .NET And GUI Programming :: C++
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 01-27-2002, 03:22 PM
  3. GUI Programming :: C++ Exclusive
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 01-25-2002, 02:22 PM
  4. C++: Reference Book, GUI, Networking & Beyond
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 11-10-2001, 07:03 PM
  5. GUI (Graphical User Interface) Help Needed
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-11-2001, 10:35 AM

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