Jump to content
  • Advertisement
Sign in to follow this  
ms75214

MessageBox

This topic is 2834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anything similar to this on Mac?

MessageBox(NULL, "You win!", "Congratulations", MB_OK);

Share this post


Link to post
Share on other sites
Advertisement

Is there anything similar to this on Mac?

MessageBox(NULL, "You win!", "Congratulations", MB_OK);


I don't know anything about Macs but this says that you use CreateStandardAlert and RunStandardAlert (Found in Carbon.h).

Share this post


Link to post
Share on other sites

If you use the apple documentation that comes with XCode, apples online reference library, or even google/yahoo/bing whatever a lot of your questions can be easily answered. It took me a few seconds to search for dialog in the reference library and I found this. It should get you going.

http://developer.app...log/Dialog.html



i tried this code


//
// main.m
// audio
//
// Created by administrator a on 3/4/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
//#import <AVFoundation/AVFoundation.h>
//#import <AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>

//#import <AVAudioPlayer.h>


int main(int argc, char *argv[])
{

// NSSound *mySound = [NSSound soundNamed:@"Sosumi"];
// [mySound play];

// mySound->p
//avaudiop
//avaudi
// AVAudioPlayer *audioPlayer;

NSAlert *alert = [[NSAlert alloc] init];

[alert addButtonWithTitle:@"OK"];

[alert addButtonWithTitle:@"Cancel"];

[alert setMessageText:@"Delete the record?"];

[alert setInformativeText:@"Deleted records cannot be restored."];

[alert setAlertStyle:NSWarningAlertStyle];


[alert runModal];



return NSApplicationMain(argc, (const char **)argv);
}


however, no alert shows up.

Share this post


Link to post
Share on other sites

[quote name='blewisjr' timestamp='1299599911' post='4783150']
If you use the apple documentation that comes with XCode, apples online reference library, or even google/yahoo/bing whatever a lot of your questions can be easily answered. It took me a few seconds to search for dialog in the reference library and I found this. It should get you going.

http://developer.app...log/Dialog.html



i tried this code


//
// main.m
// audio
//
// Created by administrator a on 3/4/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
//#import <AVFoundation/AVFoundation.h>
//#import <AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>

//#import <AVAudioPlayer.h>


int main(int argc, char *argv[])
{

// NSSound *mySound = [NSSound soundNamed:@"Sosumi"];
// [mySound play];

// mySound->p
//avaudiop
//avaudi
// AVAudioPlayer *audioPlayer;

NSAlert *alert = [[NSAlert alloc] init];

[alert addButtonWithTitle:@"OK"];

[alert addButtonWithTitle:@"Cancel"];

[alert setMessageText:@"Delete the record?"];

[alert setInformativeText:@"Deleted records cannot be restored."];

[alert setAlertStyle:NSWarningAlertStyle];


[alert runModal];



return NSApplicationMain(argc, (const char **)argv);
}


however, no alert shows up.
[/quote]

I have done some testing and it appears as if code in main.m that is before the return does not get run basically all main does in objective-c cocoa apps is get the nib files loaded up. You are going to want to put your code in an application controller class of some sort. Open up your AppDelegate.m file that xcode creates this is the applications controller class and put your message box in this method like so and you should see it pop up as soon as the application starts up...






- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Message Test"];
[alert setInformativeText:@"More Detail Here"];
[alert runModal];
[alert release];
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!