Author Topic: pointers  (Read 1239 times)

thrushitha

  • Full Member
  • ***
  • Posts: 26
pointers
« on: July 13, 2011, 01:40:45 am »
what does  this line mean??

eventarea->drawdesc.drawfunc( eventarea );
and
typedef void (*PCONTENT_FUNC)(void *);



where:
eventarea is of type PGTE and PGTE  is as follows


typedef struct
   {
   GXT xb;           
   GYT yb;
   GXT xe;
   GYT ye;
   SGUCHAR flags;                 
   SGUCHAR tickcnt;               
   SGINT state;                 
   GCOLOR color_close;         
   PGTR_DRAWFUNC draweventfunc; 
   GTE_DRAWDESC  drawdesc;       
   } GTE, *PGTE;




typedef struct
   {
   GOBJTYPE type;     
   PCONTENT_FUNC drawfunc;
   GCOLOR colorf;     
   GCOLOR colorb;     
   GTE_DRAWDATA d;
   } GTE_DRAWDESC, *PGTE_DRAWDESC;



awaiting ur reply :)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Re: pointers
« Reply #1 on: July 13, 2011, 04:38:04 pm »
what does  this line mean??

eventarea->drawdesc.drawfunc( eventarea );
and
typedef void (*PCONTENT_FUNC)(void *);

where:
eventarea is of type PGTE and PGTE  is as follows


typedef struct
   {
   GXT xb;           
   GYT yb;
   GXT xe;
   GYT ye;
   SGUCHAR flags;                 
   SGUCHAR tickcnt;               
   SGINT state;                 
   GCOLOR color_close;         
   PGTR_DRAWFUNC draweventfunc; 
   GTE_DRAWDESC  drawdesc;       
   } GTE, *PGTE;




typedef struct
   {
   GOBJTYPE type;     
   PCONTENT_FUNC drawfunc;
   GCOLOR colorf;     
   GCOLOR colorb;     
   GTE_DRAWDATA d;
   } GTE_DRAWDESC, *PGTE_DRAWDESC;



awaiting ur reply :)

eventarea->drawdesc.drawfunc( eventarea );

1. drawdesc is of type GTE_DRAWDESC and is a member with in GTE.
2. PCONTENT_FUNC in GTE_DRAWDESC is a function pointer and it must be pointing to a function. You have not given the initialization code for this.  Lets assume it is being assigned with the function "void MyDrawingFunction(void *)".
3. The code given by you will invoke the function "MyDrawingFunction" and will pass the pointer GTE* to it.
4. Now "MyDrawingFunction" will need to typecast from void* to GTE* and can implement the necessary drawing code.

Hope this helps you!

thrushitha

  • Full Member
  • ***
  • Posts: 26
Re: pointers
« Reply #2 on: July 13, 2011, 11:38:36 pm »
i know dat, "drawdesc is of type GTE_DRAWDESC and is a member with in GTE."

eventarea->drawdesc.drawfunc( eventarea );
so will dis code mean , drawfunc is pointing to eventarea ?






awaiting ur reply :)

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 69
Re: pointers
« Reply #3 on: July 14, 2011, 11:47:24 pm »
i know dat, "drawdesc is of type GTE_DRAWDESC and is a member with in GTE."

eventarea->drawdesc.drawfunc( eventarea );
so will dis code mean , drawfunc is pointing to eventarea ?

awaiting ur reply :)

drawfunc is function that will accept eventarea as an argument (as void*)

thrushitha

  • Full Member
  • ***
  • Posts: 26
Re: pointers
« Reply #4 on: July 19, 2011, 05:21:56 am »
thank u :)

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1