月份:二月 2008

MAC MessageBox-1 StandardAlert

Posted on Updated on

AlertStdAlertParamRec SARecord;

SARecord.filterProc = nil;
SARecord.movable = false;
SARecord.helpButton = false;
SARecord.defaultText = “pYes";; // right most button text
SARecord.otherText = “pNo";; // center button text
SARecord.cancelText = “pCancel";; // left mose button text
SARecord.defaultButton = kAlertStdAlertOKButton;
SARecord.cancelButton = kAlertStdAlertCancelButton;
SARecord.position = kWindowDefaultPosition;

ConstStr255Param chTitle = “pWarning";
ConstStr255Param chMessage = “pNo Device Found.";
SInt16 sBottonPressed = 0;
StandardAlert(kAlertStopAlert,chTitle,chMessage,&SARecord,&sBottonPressed);

if SARecord.otherText is set to NULL, the button wouldn’t appear, so does cancelText

kAlertStopAlert:
picture-2.png

kAlertNoteAlert:
picture-3.png

kAlertCautionAlert:
picture-4.png

kAlertPlainAlert:
picture-5.png

Notice:
the primary and secondary messages are sent as Pascal strings.
http://forums.macosxhints.com/showthread.php?t=85925

Pascal strings are unsigned. They can be 256 characters in length (0-255), and this length is stored in the first (zeroth) byte of the string. Adding \p to the beginning of the string handles this, but you still need to declare it as the correct type, which you didn’t do, either. (So really, you get 255 characters, since the zero byte is reserved for the string length.)

廣告

MessasgeBox

Posted on Updated on

Reference:

  1. http://developer.apple.com/documentation/Carbon/Reference/Dialog_Manager/Reference/reference.html#//apple_ref/c/func/GetNewDialog
  2. For Cocoa, take a look at NSRunAlertPanel and friends.
    For Carbon, try CFUserNotificationDisplayNotice and friends.

AEProcessAppleEvent

Posted on

Processing Apple Events With the Carbon Event Model
An application that uses the Carbon event model receives each Apple event as a Carbon event of type {kEventClassAppleEvent, kEventAppleEvent}. For applications that call the RunApplicationEventLoop function to process Carbon events, the AEProcessAppleEvent function is called automatically.

Search kAEOpenApplication keyword in Xcode Documents.

Boost on Mac OSX 10.4 with XCode 2.1

Posted on Updated on

Mac OSX 10.4
GCC 4.0.1
Xcode 2.1

  1. download boost lib
  2. build boost lib
    1. build bjam
    2. download bjam
      %build.sh darwin
      refreence
      the target output file is located on \bin.macosxx86\bjam

  3. if you want to build universal version, edit boost_1_34_1/tools/build/v2/user-config.jam, add

    using darwin : : : < compileflags>"-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386″ < linkflags>"-arch ppc -arch i386″ ;

  4. to build
  5. % bjam –toolset=darwin –with-filesystem –with-iostreams –with-signals –with-thread –with-wave –with-date_time –with-serialization –with-program_options –build-dir=/tmp/boost stage -d2
    -d2: for log message as building
    -a : rebuild all target

  6. share library environment path parameter DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<boost-lib’s path>

Reference:

  1. http://www.boost.org/more/getting_started/unix-variants.html
  2. universal build: http://lists.boost.org/boost-users/2007/08/30500.php
  3. boost-mailing list:http://www.boost.org/community/groups.html

TCP_NODELAY motiple defined

Posted on

Root cause:
in OpenTransportProviders.h
enum …
{
TCP_NODELAY= ….

};

and in tcp.h
#define TCP_NODELAY …

Solution:
in OpenTransportProviders.h
before
enum ..
{
TCP_NODELAY=…

insert
#undef TCP_NODELAY
#undef TCP_MAXSEG
#undef TCP_KEEPALIVE

warning: control may reach end of non-void function

Posted on

because the called function declared as the non-void (ex: int add(int a,int b) ) but in the called function it has no “return" value.