|
Post by mknarr on Jan 13, 2023 8:56:10 GMT -5
I'm working on a Recipe Tracker that has a listbox with all the recipes listed in it. You will be able to click a recipe, view and print the instructions. But I thought it would be neat to have a nice border around the list box but I believe that would require a graphic box to display the border and the listbox inside the graphic box. So before I waste a lot of time, am I correct that that won't work because I seem to remember controls don't work inside a graphic box.
I have an alternate method however tedious, that I could break the border into four pieces and have four graphic boxes outside the list box and fit the four BMP inside the graphic boxes.
Any other ideas?
Jim
|
|
|
Post by Walt Decker on Jan 13, 2023 9:15:11 GMT -5
You could do like others do and leverage a graphic box. Or you could use Color Control DLL to display a bit map as the background of your window.
|
|
|
Post by mknarr on Jan 13, 2023 11:09:45 GMT -5
Sorry, although I've been programing for over 40 years, my grasp of graphic programming is a bit limited. What does leverage a graphic box mean?
|
|
|
Post by Walt Decker on Jan 13, 2023 11:58:46 GMT -5
Make the graphic box look and act like a list box. You would have to manage all the display, scrolling, selection, editing yourself. Pretty big task.
On the other hand, if you use 4 graphic controls as a border, you would have to manage their size as the user resizes the graphic window; less control intensive.
If you use the color control dll, just set it and forget it. The dll does the rest.
|
|
|
Post by mknarr on Jan 13, 2023 12:47:35 GMT -5
Believe it or not, I made a quick BMP just colored red and loaded it before the listbox and it works . I don't have the details worked out but when I do I'll post a finished picture.  pic.
|
|
|
Post by Walt Decker on Jan 13, 2023 14:57:41 GMT -5
Good for you, but don't click on the graphic control by mistake. It will come to the foreground and obscure your list box. However, to prevent that, you might try setting the extended style of your list box using STYLEBITS #1.LBX, 0, 0, WM_EX_TOPMOST, 0. That may prevent the graphic box from taking the foreground.
|
|
|
Post by mknarr on Jan 13, 2023 15:39:29 GMT -5
Here is a picture of the dialog modal editing window with the border behind it. But selecting an item from the list box as you can see in the 1st text window did not make the border take over, but I'll use your suggestion anyway.  Just for safeties sake I added the Stylebit.
|
|
|
Post by Walt Decker on Jan 13, 2023 17:28:39 GMT -5
Nice graphic. I know not whether setting WS_EX_TOPMOST will do the trick. Creating the graphic first followed by the list box sets the graphic at a lower Z-order than the list box. However, if both have the WS_EX_TOPMOST style it may not work.
In LB the actual style would be _WS_EX_TOPMOST, if LB recognizes it. If not you can use this:
WS.EX.TOPMOST = HEXDEC("&H00000008")
and plug WS.EX.TOPMOST in the third position of STYLEBITS.
If that fails you can always try the dll.
|
|
|
Post by Walt Decker on Jan 13, 2023 18:33:40 GMT -5
There is another possibility. You could use a static control (static text) and change its style to SS_OWNERDRAW (the graphic box is a custom static control). However, you would have to use several API calls to manage the graphic display.
|
|
|
Post by mknarr on Jan 13, 2023 18:42:55 GMT -5
I did add the stylebit for the listbox and it still works as I would like, After many runs, the listbox stays on top. In retrospect, this is not in the graphic box but in the same space. This is the actual code in it's order. Maybe that is why it works. In my case, the graphic box does nothing but hold the border.
loadbmp "frame", DefaultDir$+"\bmp\frame.bmp" WindowWidth = 700 WindowHeight = 710 BackgroundColor$ = "buttonface" ForegroundColor$ = "black" graphicbox #edit.gfb1, 15, 0,370,520 listbox #edit.lb1, ListBox$(), [lbselect], 60, 45, 280, 435 stylebits #lb1,0,0, WM-EX-topmost,0 stylebits #edit.lb1,_WS_HSCROLL,_ES_AUTOHSCROLL,0,0
The border bmp is placed in the graphic box after the window is opened with.
#edit.gfb1 "drawbmp frame 0 0; flush"
|
|
|
Post by Walt Decker on Jan 13, 2023 19:01:10 GMT -5
That is correct. To be IN the graphic it has to be a CHILD of the control. When one control occupies all or part of another control Z-order takes precidence unless one is designated topmost while the other is not.
I do not see how your code can work.
stylebits #lb1,0,0, WM-EX-topmost,0 '<--- I see nowhere you defined WM-EX-Topmost nor where you defined #lb1
|
|
|
Post by Rod on Jan 14, 2023 4:40:19 GMT -5
The help file warns that controls may not work on top of a graphicbox. The only control I have found that is impacted is static text. So provided the z order (control creation) is correct you should be good to go without any api or stylebits help.
|
|
|
Post by mknarr on Jan 14, 2023 11:38:26 GMT -5
Walt, look at my code again
graphicbox #edit.gfb1, 15, 0,370,520 listbox #edit.lb1, ListBox$(), [lbselect], 60, 45, 280, 435 stylebits #lb1,0,0, WM-EX-topmost,0 stylebits #edit.lb1,_WS_HSCROLL,_ES_AUTOHSCROLL,0,0
|
|
|
Post by Walt Decker on Jan 14, 2023 13:03:52 GMT -5
listbox #edit.lb1, ListBox$(), [lbselect], 60, 45, 280, 435 stylebits #lb1,0,0, WM-EX-topmost,0 stylebits #edit.lb1,_WS_HSCROLL,_ES_AUTOHSCROLL,0,0 Is #lb1 shorthand for #edit.lb1? #lb1 indicates a form window style, not a control style. WM-EX-topmost does nothing. WM-EX-topmost = zero because you are doing a subtraction of WM - EX - topmost. In the second STYLEBITS you are removing _ES_AUTOHSCROLL. ES_AUTOHSCROLL is an edit control style. The list box does not have that style so you are accomplishing nothing. This STYLEBITS should look like this: STYLEBITS #edit.lb1, _WS_HSCROLL, 0, _WS_EX_TOPMOST, 0 With the above you are adding a horizontal scrollbar to the list box and specifying that the list box should have the topmost style.
EDIT: Be aware that a horizontal scroll bar will not appear in your list box without using a little API magic:
This goes AFTER executing the OPEN window statement.
LB.SETHORIZONTALEXTENT = HEXDEC("&H0194") Winhndl = HWND(#edit.lb1) CALLDLL #user32, "SendeMessageA", WinHndl AS ULONG, LB.SETHORIZONTALEXTENT AS ULONG, 600 AS LONG, 0 AS LONG, RetVal AS VOID
It should appear when the text in the list box is greater than can be displayed in the list box.
|
|
|
Post by mknarr on Jan 14, 2023 17:34:03 GMT -5
You're right. that was a mistake. the code looks like this now:
graphicbox #edit.gfb1, 15, 0,370,520 listbox #edit.lb1, ListBox$(), [lbselect], 60, 45, 280, 435 stylebits #edit.lb1,0,0, WM-EX-topmost,0 stylebits #edit.lb1,_WS_HSCROLL,_ES_AUTOHSCROLL,0,0
I think what you are saying is the second stylebit negates the first. I fixed my mistake and even created an exe and the listbox still works correctly over the graphic box and has a horizontal scroll. But to be safe, I now changed to your line anyway.
|
|