Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with Controls Manager



I started a few days ago development for my first Carbon project.
Everything was going ahead very smoothly until I came across the
Controls
Manager. My problem is that I create a control root and embedded a
control
to it, but when I use IsValidControlHandler() on the handlers of the
new
controls I get that they are invalid.

/* We create our root control */
CreateRootControl(ptrWindowRef,

&(gwndEditorWindow[gushtEditorWindowsCount].ptrRootControlRef));

Be aware that on OS X you do not have to do this, all windows always
have a root control automatically created for you.


Ah, ok that's useful information for a Mac OS X compile. Currently I'm
working on Mac OS 9.2.2.


/* And we load our data displaying control from the resources */
gwndEditorWindow[gushtEditorWindowsCount].ptrDataControlRef =
GetNewControl(128, ptrWindowRef);

/* The next thing to do would be to set it's size according to the
window */
SizeControl(gwndEditorWindow[gushtEditorWindowsCount].ptrDataControlR ef
,
intRight - intLeft,
intBottom - intTop - 15);

ActivateControl(
gwndEditorWindow[gushtEditorWindowsCount].ptrRootControlRef);

if(IsValidControlHandle(
gwndEditorWindow[gushtEditorWindowsCount].ptrDataControlRef))
{
TerminateApplication; /* <--- THIS NEVER HAPPENS, WHY?!? */
}

Some obvious questions...

1. Are you checking for errors? Your sample doesn't show that to be the
case. Remember check_noerr and its ilk from Debugging.h are your
friends.


I've been looking for information on how to debbug a Mac application. My
problem is that I've just switched from Windows development so I am kind of
new to it. To be honest I'm having a really bad time trying to understand
how the documentation works with the apple developer's site, so if you know
a good tutorial on Carbon debugging please, let me know about it.

A great guide/book/tutorial for learning Carbon, especially Mac OS 9 compatible Carbon, is the "Macintosh C Carbon" tutorial at http://www.mactech.com/macintosh-c/ . I highly recommend it to all beginners and frequently use it myself.

2. Is the control actually getting created? Is it visible when the
window is shown?


Yes, the control is there. I created a scrolling textbox and it shows up as
if disabled for some reason. I can actually resize the control and work on
it by using the exactly same ptr I used with the IsValidControlHandle()
function.

3. are you sure nothing is changing "gushtEditorWindowsCount" by the
time it is getting called (i.e are you looking at the same
ptrDataControlRef field?

Yes, I am sure about this as I went step by step in the debug window to see
how values changed. I thought the same thing at first too.

4. The call to ActivateControl is not needed, new controls are active
by default

Thanks for that, I was really wondering about it. The real problem is I
haven't been able to find a good guide regarding the Control Manager use. I
love Apple and all but I find their Control Manager guide to be quite poor
(almost incomplete).

The Window Manager and Event Manager guides were much more complete IMHO.

5. Prove to yourself that IsValidControlHandle works. Pass it something
you KNOW is not a control. A windowref, or 0xDEADBEEF or whatever.

Yes, I tried this and I get false as well. I was trying to figure out if
there's something I need to add to my source (like a header or something)
that I didn't put into it. But my code compiles without errors at all = (

Bryan



Thanks a lot for the quick reply,
Diego Rey
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Problems with Controls Manager (From: Diego Rey <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.