Page 1 of 1

ownderdraw in 7.5

Posted: 27 Dec 2014 3:12
by David Snook
Hi,

I've been away from this for several months and find that ownerdraw does not seem to be supported in VP 7.5. I use ownerdraw listbuttons and listboxes a fair bit and all those that were working in 7.4 no longer are. I noticed the ownerdraw flag is ignored on controls in form or dialog creation.

Is there a work-a-round or alternative to ownerdraw?

Cheers,

David Snook

Posted: 28 Dec 2014 0:39
by Thomas Linder Puls
That is unintended, can you illustrate how your code looks (i.e. the code that works in Vip 7.4).

Posted: 28 Dec 2014 18:42
by David Snook
Hi Thomas,

I can send a small sample project if it helps? The following is the basic code setup:

Code: Select all

   new(Parent) :-         dialog::new(Parent),         generatedInitialize(),         %         State1 = [vpiDomains::wsf_OwnerDraw | titleColor_ctl:getState()],         titleColor_ctl:setState(State1),         titleColor_ctl:setSubClassHandler(listboxHandler, false).   predicates   listboxHandler : ehandler.   clauses    listboxHandler(Win,e_OwnerMeasureItem(_CtrlType,CtlId,_ItemId,_Data)) = gui_api::mkR(SIZE) :-        CW = vpi::winGetCtlHandle(Win,CtlId),        RCT = vpi::winGetOuterRect(CW),                 RCT = rct(L,_T,R,_B),                 W = R-L,                 WL = tryConvert(unsigned,W), HL = 16,                 SIZE = WL + (0x10000 * HL),!.      listboxHandler(_Win,e_OwnerDraw(CtrlType,CtlId,ITEM,ACTIONLIST,STATELIST,CW,RECT,_Data))  =   gui_api::rNull:-  dlgOwnerDrawColor(CtlId,ITEM,ACTIONLIST,STATELIST,CW,RECT),!.
Thanks much,

David

Posted: 28 Dec 2014 18:58
by Thomas Linder Puls
It would be nice if you send a little project.

Posted: 29 Dec 2014 8:44
by David Snook
Hi Thomas,

Small ownerdraw project file attached (in VP 7.4).

Regards,

David

Posted: 29 Dec 2014 11:25
by Thomas Linder Puls
Excellent, thank you.

We are gradually "liberating" pfc\gui from the vpi library; this problem is caused by us not being sufficiently careful in that process. I am not yet completely sure how the final solution to this problem will be, but there is a quite simple workaround for you.

Unfortunately, it requires a little update in pfc. (It can be a bit problematic to update files in "Program Files").

The change is quite simple though, move the support of styleFlagsEx from listButton:

Code: Select all

interface listButton     supports listControl     open core   predicates from editControl     setAlignBaseline, getAlignBaseline   end interface listButton
to listControl:

Code: Select all

interface listControl     supports control, styleFlagsEx     open core   predicates from editControl     setVScroll, getVScroll   constants     standardWidth = 48.     standardHeight = 50.
And then change your own code to use gui_native::lbs_ownerdrawfixed like this:

Code: Select all

clauses     new(Parent) :-         dialog::new(Parent),         generatedInitialize(),         %         listButton_ctl:setStyle(gui_native::lbs_ownerdrawfixed),         listButton_ctl:addList(["Cloudy","Partly Cloudy"]),         listButton_ctl:selectAt(0,true),         % the ownerdraw subclass must be declared twice as indicated below. Once for the control (dropdown) and once for the dialog to draw the selected item         listButton_ctl:setSubClassHandler(listboxHandler, false), %this subclass must be declared to draw the dropdown list         setSubClassHandler(listboxHandler,false). %this subclass must be declared so the e_OwnerMeasureItem is activated and draws the selected item

Posted: 29 Dec 2014 18:51
by David Snook
Perfect!

Thank you Thomas.