Professional Web Applications Themes

Modal dialog Filters under X? - Mac Programming

I've been trying to write a ModalDialog filter under OSX. The reason is that I need to create an external code for InstallerVISE that will operate under Carbon. I tried copying the code I had used under Classic, and I got it to compile, but it just crashes when I do anything with filters. I went to the Carbon doentation, and it defines a ModalFilter as being: Boolean MyModalFilterProc ( DialogRef theDialog, EventRecord * theEvent, DialogItemIndex * itemHit ); However, I had it defined as: pascal Boolean MyModalFilterProc (DialogPtr theDialog, EventRecord *theEvent, short * itemHit) If I try compiling without ...

  1. #1

    Default Modal dialog Filters under X?

    I've been trying to write a ModalDialog filter under OSX.

    The reason is that I need to create an external code for InstallerVISE that
    will operate under Carbon.

    I tried copying the code I had used under Classic, and I got it to compile,
    but it just crashes when I do anything with filters. I went to the Carbon
    doentation, and it defines a ModalFilter as being:

    Boolean MyModalFilterProc ( DialogRef theDialog, EventRecord * theEvent,
    DialogItemIndex * itemHit
    );

    However, I had it defined as:

    pascal Boolean MyModalFilterProc (DialogPtr theDialog, EventRecord
    *theEvent, short * itemHit)

    If I try compiling without the pascal definition, it doesn't work.

    Are the Apple docs wrong? This code is impossible to debug because it's
    being compiled as a code resource for InstallerVISE...any help would be
    greatly appreciated.

    My code crashes at the end of this section (I figured this out through
    System Beeps):

    ModalFilterUPP MyFilterUPP;

    SysBeep(88);

    MyFilterUPP = NewModalFilterUPP(MyFilter);

    Where MyFilter is defined as:
    pascal Boolean MyFilter(DialogPtr dlog, EventRecord *evt, short *itemHit)

    Thanks!

    Mike H.

    Mike H. Guest

  2. #2

    Default Re: Modal dialog Filters under X?

    In article <BB97C8E0.28727%nospamendspam.org>,
    "Mike H." <nospamendspam.org> wrote:
    > My code crashes at the end of this section (I figured this out through
    > System Beeps):
    >
    > ModalFilterUPP MyFilterUPP;
    >
    > SysBeep(88);
    >
    > MyFilterUPP = NewModalFilterUPP(MyFilter);
    I am skeptical that it is crashing in the call to NewModalFilterUPP
    unless your heap is already toast. If this is the case, something else
    in your application is corrupting memory.

    Far more likely you are crashing in your filter proc itself. Since you
    don't enclose that code, it's basically impossible to say what could be
    in error there.

    However, two pretty good guesses are:
    a) you are calling SetPort((GrafPtr)theDialog) instead of
    SetPortDialogPort(theDialog)
    b) in response to a window event (such as update or activate) you are
    calling SetPort((GrafPtr)theEvent->message) instead of
    SetPortWindowPort((WindowPtr)theEvent->message).

    You might also consider using gdb, which should allow you to attach to
    Vise. Run until the crash and get a backtrace. At the very least
    you'll know what Toolbox call you are making which is crashing.

    I know gdb isn't as y as Metrowerks, but it does have its place and
    it's worth learning to use it.
    Tom Dowdy Guest

  3. #3

    Default Re: Modal dialog Filters under X?

    You were right on the money---I removed those calls and I got it to not
    crash anymore. It still isn't exactly working correctly, though---do you
    know if there's any sample source for displaying a dialog (with a dialog
    filter) in Carbon?

    Thanks,

    Mike Hunson

    in article [email]dowdy-63A55F.06323625092003news.apple.com[/email], Tom Dowdy at
    [email]dowdyapple.com[/email] wrote on 9/25/03 9:32 AM:
    > In article <BB97C8E0.28727%nospamendspam.org>,
    > "Mike H." <nospamendspam.org> wrote:
    >> My code crashes at the end of this section (I figured this out through
    >> System Beeps):
    >>
    >> ModalFilterUPP MyFilterUPP;
    >>
    >> SysBeep(88);
    >>
    >> MyFilterUPP = NewModalFilterUPP(MyFilter);
    >
    > I am skeptical that it is crashing in the call to NewModalFilterUPP
    > unless your heap is already toast. If this is the case, something else
    > in your application is corrupting memory.
    >
    > Far more likely you are crashing in your filter proc itself. Since you
    > don't enclose that code, it's basically impossible to say what could be
    > in error there.
    >
    > However, two pretty good guesses are:
    > a) you are calling SetPort((GrafPtr)theDialog) instead of
    > SetPortDialogPort(theDialog)
    > b) in response to a window event (such as update or activate) you are
    > calling SetPort((GrafPtr)theEvent->message) instead of
    > SetPortWindowPort((WindowPtr)theEvent->message).
    >
    > You might also consider using gdb, which should allow you to attach to
    > Vise. Run until the crash and get a backtrace. At the very least
    > you'll know what Toolbox call you are making which is crashing.
    >
    > I know gdb isn't as y as Metrowerks, but it does have its place and
    > it's worth learning to use it.

    Mike H. Guest

  4. #4

    Default Re: Modal dialog Filters under X?

    In article <BB987BA0.28794%nospamendspam.org>,
    "Mike H." <nospamendspam.org> wrote:
    > You were right on the money---I removed those calls and I got it to not
    > crash anymore. It still isn't exactly working correctly, though---do you
    > know if there's any sample source for displaying a dialog (with a dialog
    > filter) in Carbon?
    Maybe because you removed things that were required for it to work...I
    did not recommend removing "those calls" I recommended changing them to
    the correct Carbon replacements.

    I recommend debugging your code. Move the code into a standalone
    application and debug it there if you are unwilling to learn gdb.
    Tom Dowdy Guest

Similar Threads

  1. Parent window for modal dialog
    By Mark_Cleveland@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 2
    Last Post: July 31st, 07:04 PM
  2. problem with non modal ADM dialog
    By SeanWang@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 1
    Last Post: April 9th, 09:43 AM
  3. Modal Dialog
    By Vidar Petursson in forum ASP.NET Building Controls
    Replies: 0
    Last Post: April 14th, 12:51 PM
  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
  5. Submit form from modal dialog
    By martin de vroom in forum ASP
    Replies: 2
    Last Post: July 16th, 10:20 PM

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