Saludos.
![Image](http://img444.imageshack.us/img444/2594/screencaptureof.png)
Code: Select all | Expand
#import <Cocoa/Cocoa.h>
#define HB_DONT_DEFINE_BOOL
#include <hbapi.h>
@interface WindowController : NSWindowController
{
}
- ( void ) windowDidLoad;
@end
@implementation WindowController
- ( void ) windowDidLoad
{
NSArray * controls = [ [ [ self window ] contentView ] subviews ];
int i;
NSRunAlertPanel( @"windowDidLoad", @"", @"OK", NULL, NULL );
if( [ controls count ] == 0 )
NSRunAlertPanel( @"no hay controles", @"", @"OK", NULL, NULL );
for( i = 0; i < [ controls count ]; i++ )
NSRunAlertPanel( @"control", @"", @"OK", NULL, NULL );
}
@end
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
WindowController * wndController = [ [ WindowController alloc ] initWithWindowNibName : string ];
[ wndController showWindow : nil ];
hb_retnl( ( LONG ) wndController );
}
Did you remember to hook up the window in the nib to File's Owner's
window outlet? Did you remember to change the class identity of File's
Owner to your NSWindowController subclass?
Code: Select all | Expand
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
NSWindowController * wndController = [ [ NSWindowController alloc ] initWithWindowNibName : string ];
if( [ wndController window ] != nil )
NSRunAlertPanel( @"ventana accesible", @"", @"OK", NULL, NULL );
hb_retnl( ( LONG ) wndController );
}
Code: Select all | Expand
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
NSWindowController * wndController = [ [ NSWindowController alloc ] initWithWindowNibName : string ];
NSArray * controls = [ [ [ wndController window ] contentView ] subviews ];
int i;
for( i = 0; i < [ controls count ]; i++ )
NSRunAlertPanel( [ [ controls objectAtIndex : i ] className ], @"", @"OK", NULL, NULL );
hb_retnl( ( LONG ) wndController );
}
Code: Select all | Expand
NSWindowController * mynibWindow = [[NSWindowController alloc] initWithWindowNibName:@"MainMenu"];
[mynibWindow showWindow: nil];
NSWindow * ventana = [mynibWindow window] ;
[ ventana setTitle: @"Hola" ] ;
Code: Select all | Expand
#import <Cocoa/Cocoa.h>
#define HB_DONT_DEFINE_BOOL
#include <hbapi.h>
// NSView * GetView( NSWindow * window );
@interface WindowController : NSWindowController
{
}
- ( void ) BtnClick : ( id ) sender;
@end
@implementation WindowController
- ( void ) BtnClick : ( id ) sender;
{
NSRunAlertPanel( @"click", @"", @"OK", NULL, NULL );
}
@end
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
WindowController * wndController = [ [ WindowController alloc ] initWithWindowNibName : string ];
NSArray * controls = [ [ [ wndController window ] contentView ] subviews ];
int i;
for( i = 0; i < [ controls count ]; i++ )
{
NSControl * control = [ controls objectAtIndex : i ];
NSString * className = [ control className ];
if( [ className isEqual : @"NSButton" ] )
{
NSButton * button = ( NSButton * ) control;
[ button setAction : @selector( BtnClick: ) ];
}
}
hb_retnl( ( LONG ) wndController );
}
Code: Select all | Expand
NSView * myview = [ventana contentView ] ;
[[myview viewWithTag :255 ] setTitle: @"Hola" ] ;
Code: Select all | Expand
NSView * myview = [ventana contentView ] ;
[[myview viewWithTag :255 ] setTitle: @"Hola" ] ;
NSButton * boton = ( NSButton * ) [myview viewWithTag :255 ];
[ boton setAction : @selector( BtnClick: ) ];