Professional Web Applications Themes

Display Dialog in Carbon - What am I doing wrong? - Mac Programming

I'm porting my PPC application to OSX in Carbon. I'm trying to create a dialog from a DLOG reference, but no dialog is being displayed. the_dialog = GetNewDialog(INTRO_DLOG_ID, NIL, IN_FRONT); if (the_dialog == NIL) return; ShowWindow((WindowRef)the_dialog); DrawDialog(the_dialog); the_dialog comes back as non-null, but nothing is seen when I call ShowWindow(). Am I doing something wrong? CT...

  1. #1

    Default Display Dialog in Carbon - What am I doing wrong?

    I'm porting my PPC application to OSX in Carbon.

    I'm trying to create a dialog from a DLOG reference, but no dialog is
    being displayed.

    the_dialog = GetNewDialog(INTRO_DLOG_ID, NIL, IN_FRONT);
    if (the_dialog == NIL)
    return;

    ShowWindow((WindowRef)the_dialog);
    DrawDialog(the_dialog);

    the_dialog comes back as non-null, but nothing is seen when I call
    ShowWindow().

    Am I doing something wrong?

    CT
    Charles Guest

  2. #2

    Default Re: Display Dialog in Carbon - What am I doing wrong?

    On Wed, 12 Nov 2003, Charles Thomas wrote:
     
    Yes. Don't typecast a DialogRef to a WindowRef, they are no longer the
    same types. Use GetDialogWindow (and GetDialogFromWindow to go the other
    way IIRC)

    Fred

    Frederick Guest

  3. #3

    Default Re: Display Dialog in Carbon - What am I doing wrong?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     

    Do a google search on article by me about porting to Carbon. It has
    several recommended things do help you out.
     

    Needs to be ShowWindow(GetDialogWindow(the_dialog));

    You need to grep your source base for this type of casting. It is
    illegal on OS X.
    Tom Guest

  4. #4

    Default Pausing - Was: Display Dialog in Carbon

    In article <apple.com>,
    Tom Dowdy <com> wrote:
     
    >
    > Do a google search on article by me about porting to Carbon. It has
    > several recommended things do help you out.[/ref]

    If you're referring to the "Carbon Porting Guide", I have it bound and
    sitting right here open on my desk.
     

    Thanks very much for this!! I can see my dialog now.

    On to the next question. The old code used to animate a series of
    images to create a splash screen. Now the code doesn't work (only the
    last image is displayed.

    I'm guessing because I'm in a waiting loop, and now that things are
    multi-threaded it's starving the drawing thread so that it doesn't have
    a chance to draw the images.

    Any tips on how best to implement a pause in OSX? Something equivalent
    to Java's Thread.yeild(), or Thread.sleep()?

    //***** Code follows

    SetPort(GetDialogPort(the_dialog));
    ShowWindow(GetDialogWindow(the_dialog));
    DrawDialog(the_dialog);

    GetDialogItem(the_dialog, PICT_RECT_ITEM, &item_type, &item_handle,
    &item_rect);
    SetDialogDefaultItem(the_dialog, OK_BUTTON_DLOG_ITEM);

    for (i = 0; i <= 5; i++)
    {
    ticks_to_wait = TickCount() + 10;
    pic_hndl = GetPicture(INTRO_ANIMATION_PICT_1_ID + i);
    if (pic_hndl != NIL)
    {
    DrawPicture(pic_hndl, &item_rect);
    ReleaseResource((Handle)pic_hndl);
    }

    //***** Pause for a second between frames
    do
    {
    ;// do nothing
    }
    while (TickCount() < ticks_to_wait);

    }// for each picture
    Charles Guest

  5. #5

    Default Re: Pausing - Was: Display Dialog in Carbon

    On Wed, 12 Nov 2003, Charles Thomas wrote:
     
    > >
    > > Do a google search on article by me about porting to Carbon. It has
    > > several recommended things do help you out.[/ref]
    >
    > If you're referring to the "Carbon Porting Guide", I have it bound and
    > sitting right here open on my desk.

    >
    > Thanks very much for this!! I can see my dialog now.
    >
    > On to the next question. The old code used to animate a series of
    > images to create a splash screen. Now the code doesn't work (only the
    > last image is displayed.
    >
    > I'm guessing because I'm in a waiting loop, and now that things are
    > multi-threaded it's starving the drawing thread so that it doesn't have
    > a chance to draw the images.[/ref]

    More likely to be because in OS X windows are buffered, so the drawing you
    do, never actually makes it to the screen. QDFlushPortBuffer should allow
    you to force the window to update.

    Fred
     

    Frederick Guest

  6. #6

    Default Re: Pausing - Was: Display Dialog in Carbon

    In article
    <srcf.societies.cam.ac.uk>,
    Frederick Cheung <DUH.ucam.org> wrote:
     

    You are the MAN, Fred! Works like a charm now.

    Many thanks!

    CT
    Charles Guest

  7. #7

    Default Re: Pausing - Was: Display Dialog in Carbon

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote: 

    Nope, I'm refering to posts done in these newsgroups in the past.

    Here's the direct google link:
    <http://groups.google.com/groups?q=carbon+author:Tom+author:Dowdy&hl=en&l
    r=&ie=UTF-8&selm=dowdy-1EE85F.19223216012001%40news.apple.com&rnum=1>
     

    This tech note:
    <http://developer.apple.com/technotes/tn2002/tn2060.html>
    while specific to QuickTime image sequences does also show how to
    properly flush the frames of an animation to the screen.
    Tom Guest

  8. #8

    Default Re: Pausing - Was: Display Dialog in Carbon

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     
    >
    > You are the MAN, Fred! Works like a charm now.[/ref]

    About pausing, I don't know if there's a Carbon way, but if you're going
    Mac OS X only, you can #include <unistd.h> and then call sleep().
    Michael Guest

Similar Threads

  1. Dialog gives wrong century
    By Tom McIntosh in forum FileMaker
    Replies: 6
    Last Post: October 26th, 08:46 AM
  2. How to display large amount of text in a dialog box?
    By Ali Raza in forum Mac Programming
    Replies: 1
    Last Post: September 25th, 12:31 AM
  3. OSX Carbon Console???
    By Dr. Michael M. Cohen in forum Mac Programming
    Replies: 3
    Last Post: September 16th, 02:32 AM
  4. Modal Dialog Popup from WebControl - What is wrong with this...
    By Bob Lehmann in forum ASP.NET Data Grid Control
    Replies: 4
    Last Post: August 23rd, 03:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139