Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for July, 2010

NEEDS HELP WITH BASIC

I owned an apple IIc and could program basic on it… it there a way to do
that with a G3, without needing a compiler?  i just want to make simple
basic word games…

.
posted by admin in Uncategorized and have Comments (2)

Mac OS 7 Scrap/QDOffscreen

I have a program (written for OS 7) where lists of images are stored, each as a
pointer to a straight block of data (to the bitmap) AND as a GWorldPtr.  I want
the user to be able to copy an image out of the program, in ‘PICT’ format.  Can
someone tell me how I can do this?  I know I can use OpenCPicture, but I don’t
know how to draw into the Picture from the GWorld.

posted by admin in Uncategorized and have Comment (1)

What is the equivlant of Balloon Help on OSX?

Hello,

Does anyone know how can I create the yellow rectangular boxes(which are the
equivlant of balloon help in OS9) that are used in apple’s applications on
OSX? I can’t seem to find the proper APIs or manager.

Thanks,
Walid

posted by admin in Uncategorized and have Comments (8)

Q: Restrictions on useDistantHdwrMem GWorlds?

I have an application that allocates a large offscreen, and uses it to
draw various things in different windows. That works, save that its very
slow, especialy when drawing near-fullscreen stuff.
What the application draws are mainly text, and a few lines and stuff.
Nothing really fancy.

If I uses useDistantHdwrMem for my offscreen (in an attempt get it to he
hardware accelerated) and draws as usual, it not only freezes, but it
also kill the graphic card (in that case, the ATI in a 2*g4) in various
funny-looking ways.

Now, if I use TWO offscreens of the same size, one in main memory, the
other in VRAM, I can draw all my stuff in the main memory one and then
CopyBits() it to the VRAM one, then CopyBits() the VRAM one to the
screen. In that case it doesn’t crash, but I have wierd artifacts in
some of the smaller blits that aren’t drawn at 0,0 in the offscreen, and
the performance is better, but not that great (lots of memory movement!)

So, I’m trying to figure out what are the limitation of the VRAM
offscreen drawing. To me, there shouldn’t be any since I can definitly
draw on the SCREEN itself, but there are obviously issues with ATI
offscreen memory management.

And yeah, that application is stable, and works blisteringly fast on
Wintel machines. I’m really trying to make it work for the mac at at
least that speed!

Any pointers?

posted by admin in Uncategorized and have No Comments

Socket code problem

I’m trying to program a very simple socket client on OS 9 (using GUSI for
socket support), but am having a problem. Even though I seem to be able to
connect ok, I can’t read or write to the socket. (Error code -51). The
server is a Delphi written WinSock server, if that makes a difference.

Anyone have experience of sockets/GUSI?

// Create socket  
mySocket = socket (AF_INET, SOCK_STREAM, 0) ;
if (mySocket == -1)
        {
        cout << "Error" << errno << endl ;
        }
// errno actually gets set to -43 ("Protocol not supported" ?) Even
// though GUSI supposedly ignores that field. Socket seems to be created ok.

// Bind socket
myAddress.sin_addr.s_addr = inet_addr("10.10.10.2") ;   // Isolated net.
myAddress.sin_family = AF_INET ;
myAddress.sin_port = 1444 ;

if (bind (mySocket, (struct sockaddr *) &myAddress, sizeof(struct
sockaddr_in)))
    {
        cout << "Error" << errno << endl ;
    }

// Connect to the host
hostAddress.sin_addr.s_addr = inet_addr("10.10.10.1") ;
hostAddress.sin_port = 1444 ;
hostAddress.sin_family = AF_INET ;

err = connect(mySocket, (struct sockaddr *) &hostAddress, sizeof(struct
sockaddr_in)) ;
if (err)
{
        cout << "Error" << errno << endl ;
}

else
{
        cout << "Connected…" << endl ;

}

// Write to the socket
err = write (mySocket, buffer, 500) ;
if (err < 0)
    cout << "Error" << errno << endl ;

// Now, err is -1 and errno is -51 ("Network Unreachable" ?) even though
// connect appears to work correctly. Am I misinterpreting the error/return
// values?

I’d really appreciate any help,

Cheers,
Mike.

posted by admin in Uncategorized and have No Comments

Join file segments quickly??

I’m trying to join segments of a file into one complete file. My
technique now is pretty basic: I open the destination file along with
segment one. Read a block of date from segment 1, write it to the
destination file, and then repeat until I’ve written all of segment 1.
Then repeat with remaining segments. Here’s my code:

FYI: segStream and fileStream are instances my personal file stream
wrapper class. This code works fine…but I’d rather it work amazingly,
ya know? I’d like to speed up the process if possible…

————-

long  ptrSize = 65536; int i;
Ptr p = nil; bool havePtr = false;
long toRead, blockSize, actualSize;

myFileSize = transData->fileSize;
done = true;

while (ptrSize>1023)
{
   p = NewPtr(ptrSize);
   if (p==nil)
      ptrSize /= 2;
   else
      break;

}

if (p && fileStream.OpenFile(‘pFTP’))
{
   for (j=1;j<=file->numConns;j++)
   {
      transData->GetSegSpec(j-1,&segSpec);

      if (!segStream.OpenFile(segSpec) ||
GetEOF(segStream.mFileNum,&toRead)!=noErr)
         break;

      i = 0;
      while (toRead>0)
      {
         if (i==30)
         {
            YieldToAnyThread();
            i=0;
         }

         if (toRead<ptrSize)
            actualSize = blockSize = toRead;
         else
            actualSize = blockSize = ptrSize;

         toRead -= blockSize;

         if (FSRead(segStream.mFileNum,&actualSize,p)!=noErr ||
actualSize!=blockSize)
            break;

         if (FSWrite(fileStream.mFileNum,&actualSize,p)!=noErr ||
actualSize!=blockSize)
            break;

         i++;
      }
      segStream.CloseFile();
      FSpDelete(&segSpec);
   }
   fileStream.CloseFile();
   FSpDelete(&transData->folderSpec);
   DisposePtr(p);

- Hide quoted text — Show quoted text -

}

posted by admin in Uncategorized and have Comment (1)

Help on turning mouse acceleration off

I am a C++ novice, and I was wondering what routines I would have to
implement to make a program which changes the mouse acceleration to 0.

Could anyone give me any advice on this please? Please e-mail me a copy of
the reply, as my news server is lousy.

Thank you very much!

posted by admin in Uncategorized and have No Comments

NewGWorldFromPtr?

I’m looking for the non-QT version of NewGWorldFromPtr, to use on
machines without QT. My program works with QTNGWFP, but won’t link with
NewGWorldFromPtr. I can’t find this in the Find Library (although it
exists in the headers). What library is it in?

Thanks.


| John Aldis                        http://i.am/john.aldis
  …a sort of urgent, hungry enthusiasm, the kind you get
  when someone has just read a really interesting book and
  is determined to tell someone all about it.              |
     – Count Magpyr, /Carpe Jugulum/, by Terry Pratchett —

posted by admin in Uncategorized and have Comments (6)

NavEventProc Problem

Does somebody know why this simple application (code below) crash unter
MacOS X within the NavEventProc "NavSaveDlg_EventProc". When I erase the
line which gets the WindowPtr from the callBackParms it doesn’t crash.

pascal void NavSaveDlg_EventProc (NavEventCallbackMessage, NavCBRecPtr,
NavCallBackUserData);

void  main (void)
{
    NavReplyRecord      navReply;
    NavDialogOptions    dialogOptions;
    NavEventUPP         eventProcUPP = NewNavEventUPP (NavSaveDlg_EventProc);
    OSStatus            err = NavGetDefaultDialogOptions (&dialogOptions);

    err = NavPutFile (NULL, &navReply, &dialogOptions, eventProcUPP,
‘TEXT’, ‘ttxt’, NULL);

}

pascal void NavSaveDlg_EventProc (NavEventCallbackMessage, NavCBRecPtr
callBackParms, NavCallBackUserData)
{
    WindowPtr    theWindow = (WindowPtr)
callBackParms->eventData.eventDataParms.event->message;

- Hide quoted text — Show quoted text -

}

posted by admin in Uncategorized and have Comments (2)

serial input and termios – simple Q

I’m currently working on a serial communications wrapper
that will be used for both Linux and MacOS X.
I’m new to serial io using termios and have a question
that I could not find answered in the man page…

On legacy MacOS as well as Windows there are API’s to
install or resize an input buffer for a serial port.
This system buffer catches the input asyncrhonously,
even if your read/write mode is not explicitly asynchronous.

In addition, both OS’s allow you to query the system for
the "available" bytes (bytes that have accumulated in
the input buffer) before you do a read.

I could not find any comparable method in the termios/read()
model.  Is this always done from scratch in termios programming
(allocate your own intermediate buffer and track byte-counts
for reads yourself), or is there some associated library or
function that I’m overlooking?

Thanks in advance,
Christopher

posted by admin in Uncategorized and have Comments (2)