PureBasic Forum

 It is currently Fri Feb 23, 2018 3:12 pm

 All times are UTC + 1 hour

 Page 1 of 1 [ 12 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 1:31 am
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5713
Location: Wales, UK
So, found some code on the forum ( Drop Height ) that does have an effect on the combo drop-down height, but it is not accurate. Also, it does not work at all if the combo item height is set:
Code:
Enumeration
#Win
#Panel
#Scroll
#Container
#Container2
#Combo
EndEnumeration

SetWindowColor(#Win, RGB(255,200,255))

ScrollAreaGadget(#Scroll, 5, 5, 470, 360, 600, 500, 20, #PB_ScrollArea_BorderLess)

ComboBoxGadget(#Combo, 10, 10, 260, 50) ;, #CBS_NOINTEGRALHEIGHT)

;Max Combo drop-down height measured from Combo Y          ;w   ;h
MoveWindow_(GetWindow_(GadgetID(#Combo), #GW_CHILD), 0, 0, 250, 250, #True)

For a = 0 To 50

Next

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Using MoveWindow_ is of course a work-around. Perhaps it worked better on XP than it does on Win7.

Any ideas? I think I may need to go back to PlanB and use a toolwindow-button-ListIcon combination........

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Last edited by IdeasVacuum on Fri Jul 14, 2017 1:57 pm, edited 1 time in total.

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 12:50 pm

Joined: Fri Jul 21, 2006 4:41 am
Posts: 2336
Location: Berlin, Germany
You forgot to set the style flag:
Code:
#CBS_NOINTEGRALHEIGHT

_________________
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 1:38 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5713
Location: Wales, UK
I had already tried that flag - the result is a 1-row drop down, I want to have a drop down where the height max does not take it outside of the parent window, but not unnecessarily short.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 2:07 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5713
Location: Wales, UK
Another issue is that when the height of the combo button is increased, the text is not centered vertically:
Code:

Too ugly!

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 2:33 pm

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2911
Hi
Code:
Enumeration
#Win
#Panel
#Scroll
#Container
#Container2
#Combo
EndEnumeration

Global Text$,Brush,Brush_2 Text$ = Space(#MAX_PATH)

Brush = CreateSolidBrush_($FADC72) Brush_2 = CreateSolidBrush_($99FEFA)

Procedure WndProc(hWnd, uMsg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_DRAWITEM
*DRAWITEM.DRAWITEMSTRUCT = lParam
If *DRAWITEM\CtlType = #ODT_COMBOBOX
SetBkMode_(*DRAWITEM\hDC, #TRANSPARENT)
If *DRAWITEM\ItemState & #ODS_FOCUS
FillRect_(*DRAWITEM\hDC,*DRAWITEM\rcItem,Brush)
Else
FillRect_(*DRAWITEM\hDC,*DRAWITEM\rcItem,Brush_2)
EndIf
SendMessage_(*DRAWITEM\hwndItem,#CB_GETLBTEXT,*DRAWITEM\itemID, @Text$) SetTextColor_(*DRAWITEM\hDC,$0)
*DRAWITEM\rcItem\left = 8
DrawText_(*DRAWITEM\hDC,@Text$,Len(Text$),*DRAWITEM\rcItem,  #DT_SINGLELINE | #DT_VCENTER )
EndIf
EndSelect
ProcedureReturn Result
EndProcedure

SetWindowCallback(@WndProc())
SetWindowColor(#Win, RGB(255,200,255))

ScrollAreaGadget(#Scroll, 5, 5, 480, 390, 600, 500, 20, #PB_ScrollArea_BorderLess)

dLh = FindWindow_("ComboLBox",0)
MoveWindow_(dlh , 0, 0, 250, 250, #True)

For a = 0 To 50
Next

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

_________________
Egypt my love

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 2:35 pm

Joined: Fri Jul 21, 2006 4:41 am
Posts: 2336
Location: Berlin, Germany
IdeasVacuum wrote:
I had already tried that flag - the result is a 1-row drop down

Which is correct since this returns zero:

Code:

_________________
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 7:14 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5713
Location: Wales, UK
It seems the need for containers within containers can potentially have an adverse affect on standard controls, but this is only witnessed when there are a lot of controls.

Rashad, what you have beautifully coded there is exactly how I want the combos to work and how I have defined a 'hand made' effort. My alternative design is a bit heavy, it needs 4 gadgets and a border-less window, but does not need Win API. I'm trying to keep the use of API to a minimum so that producing code for Android, via Spider Basic, is easier. So, decisions decisions.........

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 8:57 pm

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2911
Hi IdeasVacuum
Next is a hand made combo
Good luck

Code:

SetGadgetColor(0,#PB_Gadget_BackColor,$BEFEBC) TextGadget(1,5,3,200,20,"ComboBox Item " + Str(1)) SetGadgetColor(1,#PB_Gadget_BackColor,$BEFEBC)
StartDrawing(CanvasOutput(6))
Box(0,0,250,500,$BBF0FE) DrawingFont(FontID(0)) DrawingMode(#PB_2DDrawing_Transparent ) DrawText(2,2,"ComboBox Item " + Str(1),$FE2D30)
DrawText(2,28,"ComboBox Item " + Str(2),$FE2D30) StopDrawing() HideGadget(5,1) Repeat Select WaitWindowEvent() Case #PB_Event_CloseWindow Quit = 1 Case #PB_Event_Gadget Select EventGadget() Case 2 Run ! 1 If Run = 1 HideGadget(5,0) Else HideGadget(5,1) EndIf Case 6 Select EventType() Case #PB_EventType_MouseMove my = GetGadgetAttribute(6, #PB_Canvas_MouseY) If my > 24 And my < 44 And over = 0 StartDrawing(CanvasOutput(6)) Box(0,24,250,30,$BBF0FE)
DrawingMode(#PB_2DDrawing_Transparent )
DrawingFont(FontID(0))
DrawText(2,28,"ComboBox Item " + Str(2),$FE2D30) DrawingMode(#PB_2DDrawing_AlphaBlend ) Box(0,24,250,30,$60FF0000)
StopDrawing()
Else
StartDrawing(CanvasOutput(6))
Box(0,24,250,30,$BBF0FE) DrawingMode(#PB_2DDrawing_Transparent ) DrawingFont(FontID(0)) DrawText(2,28,"ComboBox Item " + Str(2),$FE2D30)
StopDrawing()
EndIf
;You can know exactly the what item under the cursor even with the scroll bar moved
EndSelect
EndSelect
EndSelect
Until Quit = 1
EndIf

Edit : Step forward

_________________
Egypt my love

Last edited by RASHAD on Fri Jul 14, 2017 11:20 pm, edited 1 time in total.

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 9:54 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5713
Location: Wales, UK

That's interesting code but if using a ScrollAreaGadget works, there is no need to use a Canvas, it can host a ListIcon. The reason I use a Window is that you can guarantee it will always be topmost Z level (StickyWindow), whereas I have found using a Container sometimes works, sometimes doesn't when it has to be on top of other gadgets -so to guarantee it is always on top the other gadgets need to be temporarily hidden. If the solution is for just one hand-made combo, either method is good, but for several combos on several tabs, the Window drop-down has an advantage in that it can be recycled.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 10:18 pm

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2911
It will be more code to use
But
- You can use more than one font per list
- You can justify the text left-center-right
- you can design the height of any row as you like
- And more and more without any Windows API
Just tuck up your sleeve and dive in

_________________
Egypt my love

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 10:22 pm

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1516
Location: Uttoxeter, UK
Very nice example, as usual.
I'll have to take a close look at it.
Thank you for sharing.

_________________
DE AA EB

Top

 Post subject: Re: ComboBox Drop-down HeightPosted: Fri Jul 14, 2017 10:28 pm

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2911
Hi davido
You just trapped in mate
You have to roll up your sleeve and finish the exam.

Previous post updated

_________________
Egypt my love

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 12 posts ]

 All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite