Problem with custom widget creation

My custom widget can easily be created by draging and droping from the widget box but only while creating and realizing it through PtCreateWidget & PtReallizeWidget there appears a white dot at the top left corner of the window

i have tried setting the width and height. I set the width and height of the widget which is being passed as an argument to PtSuperclassDraw in the widgets draw function. All the widget resources values are printed same as what is set with PtSetArg and PtSetResource with printf statement from the widgets draw function. Still the out come is same

Hello cyvinay4,

I have written a lot of widgets and I can’t remember any Photon specific problem causing your issue. So I guess there is a bug in your code and I think you will not get an answer here if you don’t ask more specific.

Please do not open multiple threads for the same problem in this forum!


The widget i have created is a class and not a structure as given in the help. Can this aspect ceate a problem with PtCreateWidget and PtRealizeWidget function

I suspect one of the problems is that PtCreateWidget doesn’t call the class constructor of your custom widget “class”.
I know there are solutions using photon with classes - but I think it’s not as easy as simply replace the widget struct by a class.


Following is the code to create a custom widget on button click i have used

Basicwidgets’s position and its width and height i have set in my widget’s draw function.Is it O.K?

Is there any problem with the code?
/* Standard headers */

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>

/* Local headers */

#include “ablibs.h”

#include “abimport.h”

#include “proto.h”


ShowMsg( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )


PtArg_t argt[1];

PtWidget_t *window;

int ret;

        /* eliminate 'unreferenced' warnings */

        widget = widget, apinfo = apinfo, cbinfo = cbinfo;


window=PtCreateWidget(MyBox,(PtWidget_t *)ABW_base1,1,argt);


//window=PtCreateWidget(PtButton,(PtWidget_t *)ABW_base1,1,argt);



        return( Pt_CONTINUE );


No, it is not ok to change the size of the widget in it’s draw function!

Please have a look at “Anatomy of a Widget” in the online help. Look for Pt_SET_EXTENT_F.

The code above seems ok - the typecast to (PtWidget_t*) for ABW_base1 is not necessary.