toolbox-programming with oslib

Tony van der Hoff OSLib at mk-net.demon.co.uk
Thu Oct 12 10:44:39 BST 2000


On Wed, 11 Oct 2000, at 22:55:35, Uwe Kall <uk586013 at rwth-aachen.de>
wrote on the subject "toolbox-programming with oslib":

>In message <XxWc0EA+ED55EwlI at mk-net.demon.co.uk> you wrote:
>
>bad news...
>
>i tried this:
>//////////////////////////////////////
>    os_error* error=NULL;
>    flags=toolbox_CREATE_GIVEN_OBJECT;
>    
>    char* title=new char[12];
>    strcpy(title,"anytitle");
>    char* message=new char[12];
>    strcpy(message,"anymessage");
>    char* name=new char[12];
>    strcpy(name,"anyname");
>
>    dcs_object tmpl;
>    tmpl.flags = 0;
>    tmpl.title = title;
>    tmpl.title_limit = 12;
>    tmpl.message= message;
>    tmpl.message_limit = 12;
>    tmpl.alternative_window_name = name;
>    error = xtoolbox_create_object(flags, (toolbox_id)&tmpl, &mObjectId);
>
>    #ifdef RiToolboxEventHandler_debug
>        if (error)
>        gpLibLog<<"RiToolboxEventHandler: error ("<<error->errnum
>            <<") :"<<error->errmess<<endl;
>    #endif //RiToolboxEventHandler_debug
>
>/////////////////////////////////////
>...and it tells me the following:
>  error (461425421) : Object has reserved bits set in its flags word (flags 
>0x3f238).
>-which is the same answer i received with the colourdbox- object. I will
>dig further and see where the 0x3f238 can be found... 
>
>Note that i had to change to the call to (toolbox_id) instead of
>(toolbox_id*) in the call in order to compile correctly maybe there
>is some error...?? 
>
Yes, I mislead you. The problem is that the dcs_obj and colourdbox_obj
structures are not the entire template, but only the object-specific
part. The toolbox requires a standard header to be prepended to make a
complete template. Unfortunately, oslib currently does not appear to
define such structures pre-built, so you have to fiddle around with your
own. I'm surprised that no-one has complained before; I suspect that
everyone is quite happy using the res file.

I shall try to include the full template structure for each object in
the next release.

Anyway, this works (tried and tested this time :-)

void ColourDbox()
{
  struct
  {
    toolbox_RESOURCE_FILE_OBJECT_MEMBERS
    colourdbox_object obj;
  } template;

  toolbox_o o = 0;
  toolbox_info info = 0;
  char* name = "ColourDBox";
  toolbox_position pos;

  template.class_no = class_COLOUR_DBOX;
  template.flags = 0;
  template.version = toolbox_RESOURCE_FILE_VERSION;
  strcpy( template.name, "ColourDBox" );
  template.size = sizeof( template );
  template.header_size = sizeof( toolbox_resource_file_object );
  template.obj.flags = 0;
  template.obj.title = 0;
  template.obj.title_limit = 0;
  template.obj.colour = os_COLOUR_BLACK;

  pos.top_left.x = 0;
  pos.top_left.y = 0;

  o = toolbox_create_object( toolbox_CREATE_GIVEN_OBJECT, 
                             (toolbox_id)&template 
                           );
//  o = toolbox_create_object( 0, (toolbox_id)name );
  Err_ReportError( !Err_FATAL, "Object Created: %i", (int)o );
  toolbox_show_object(0,
                      o,
                      toolbox_POSITION_TOP_LEFT,
                      &pos,
                      toolbox_NULL_OBJECT,
                      toolbox_NULL_COMPONENT
                    );
  info = toolbox_get_object_info( 0, o );
  Err_ReportError( !Err_FATAL, "Object info: %u", (unsigned int)info );
}


HTH (Hope That Helps :-) Tony.

-- 
Tony van der Hoff         |  mailto:OSLib at mk-net.demon.co.uk
Buckinghamshire, England  |  http://www.mk-net.demon.co.uk/oslib/
----------------------------------------------------------------



More information about the oslib-user mailing list