Discussions related to Visual Prolog
David Snook
Active Member
Posts: 36
Joined: 6 Feb 2003 0:01

ownderdraw in 7.5

Unread post 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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1194
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

That is unintended, can you illustrate how your code looks (i.e. the code that works in Vip 7.4).
Regards Thomas Linder Puls
PDC
David Snook
Active Member
Posts: 36
Joined: 6 Feb 2003 0:01

Unread post 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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1194
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

It would be nice if you send a little project.
Regards Thomas Linder Puls
PDC
David Snook
Active Member
Posts: 36
Joined: 6 Feb 2003 0:01

Unread post by David Snook »

Hi Thomas,

Small ownerdraw project file attached (in VP 7.4).

Regards,

David
Attachments
ownerdraw_test.zip
(31.56 KiB) Downloaded 258 times
User avatar
Thomas Linder Puls
VIP Member
Posts: 1194
Joined: 28 Feb 2000 0:01

Unread post 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
Regards Thomas Linder Puls
PDC
David Snook
Active Member
Posts: 36
Joined: 6 Feb 2003 0:01

Unread post by David Snook »

Perfect!

Thank you Thomas.
Post Reply