Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Context Devices in Delphi

Options
  • 14-01-2003 12:29pm
    #1
    Moderators, Arts Moderators Posts: 35,403 Mod ✭✭✭✭


    This should be a simple question, but I've had no luck with finding an answer in the last few days.

    I've created a class which is derived from an Extended Control
    (TShape). This class is called TSector, and is used to draw a portion of a circle given its radius, centre and the angle of the sector. The question is now how to use the damn thing, i.e. to give it some physical hook to the parent Form.
    I've got it to work by drawing a TShape control on the Form, then casting the TShape to a TSector, from whence I can manipulate the object based on the position and size of the TShape on the Form. I can expand the TShape to fill the canvas and make it invisible, so this method works as is, but I know there must be a better way of creating a device context for my own object, using handles, but I'll be damned if I can figure out how.
    Any ideas?


Comments

  • Registered Users Posts: 2,149 ✭✭✭dazberry


    Originally posted by pickarooney
    This should be a simple question, but I've had no luck with finding an answer in the last few days.

    I've created a class which is derived from an Extended Control
    (TShape). This class is called TSector, and is used to draw a portion of a circle given its radius, centre and the angle of the sector. The question is now how to use the damn thing, i.e. to give it some physical hook to the parent Form.

    If you are creating an instance dynamically make sure you are setting the parent property of the class to the form, i.e.

    Sector:=TSector.Create(Self);
    Sector.Parent:=Self; // <

    If you have registered the class as a (delphi) component and it still doesn't appear, or parent property doesn't work, mail me the code (daz at tinet dot ie) and I'll take a look.

    D.


  • Moderators, Arts Moderators Posts: 35,403 Mod ✭✭✭✭pickarooney


    Thanks Daz, my sectors are creating and destroying themselves like amoebae and lemmings now :)


Advertisement