This page to be updated. Makes link I posted on PB Forum "live". (might be a while, this is an interuption from another project. Except for the screen captured images with brief comments, see the source code comments.
Screen capture of demo with no DIALOG DEFAULT FONT and with DIALOG NEW PIXELS.
Screen capture of demo with DIALOG DEFAULT FONT (12 points) and DIALOG NEW UNITS.
There are two differences between the TEXTBOX's border and the one I put around
the LISTBOX. First is that Windows uses 2 shades of gray, black and white. I
used CONTROL ADD LINE that only has 1 gray, black and white. The other is that
in DIALOG NEW UNITS, the lines of my border may be more than 1 pixel wide.
I still like it more the standard flat LISTBOX.
Full copyleft (ɔ), 2023 by Dale Yarker in source or compiled form. Complete license in new tab or window.
'I more often use COMBOBOX, but LISTBOX was better for my current project. In a 'test compile/execute, the LISTBOX looked terrible next to the standard TEXTBOXs 'because it was flat. So, project interruption (again) to add a sunken border. ' 'It took more effort than I would want to repeat in the future, so wrote it as 'an SLL. ' 'The source code must be changed to change the code to change what I consider as 'minimum default styles. They aren't replaced when using the optional style 'parameter. One style is I left out is %LBS_SORT. You may use it as an optional 'style, but I dislike it as a default style in PBWin. ' 'The optional Items() is a WSTRING array. It is 2023, IMO Unicode should be 'used for text. In any case you can let PB convert 8 bit strings to wide while 'building the array See demo for an example. ' 'The order of the parameters is changed from CONTROL ADD LISTBOX to make it 'easier (for me) to have the string array as optional, while keeping the other 'parameters as required. ' 'To make comments, or ask questions, please start a thread in "PowerBASIC for 'Windows. ' 'This code and explanation is (eventually will be) at: ' http://www.yarker-dsyc.info/D_Notebook/Programs/Misc/SunkenListbox.html '(any code updates will be there) ' 'Last thing, this code is copy left (ɔ), 9 Sept 2023 by Dale Yarker. 'Freedoms 0 to 3 apply. (see https://en.wikipedia.org/wiki/Copyleft ) '[code] 'file name Add_Sunken_ListboxSLL.bas #compile sll "./Add_Sunken_Listbox.sll" #dim all sub AddSunkenListbox (byval hDlg as dword, byval CID as long, _ byval PsX0 as long, byval PsY0 as long, _ byval SzX0 as long, byval SzY0 as long, _ opt byref Items() as wstring, _ opt byval Opt_Style as long) common 'export local SzX1, SzX2, SzX3, SzX4,SzY1, SzY2, SzY3, SzY4, LW as long 'sizes local PsX1, PsX2, PsX3, PsX4, PsY1, PsY2, PsY3, PsY4 as long 'positions local LB_Style as long ! push ebx 'probably not needed because the ASM is before any BASIC (not 'after). So, EBX not used by BASIC (yet), is a habit to have when 'mixing ASM with BASIC, and cheap to put here. '---------- Sizes ---------- 'Line Width, X or Y ! mov LW, 1 'Horz Sizes, largest to smallest ! mov ebx, SzX0 'SzX1 = SzX - 1 ! dec ebx ! mov SzX1, ebx 'SzX2 = SzX - 2 ! dec ebx ! mov SzX2, ebx 'SzX3 = SzX - 3 ! dec ebx ! mov SzX3, ebx 'SzX4 = SzX3 - 1 ! dec ebx ! mov SzX4, ebx 'Vert Sizes, largest to smallest ! mov ebx, SzY0 'SzY1 = SzY0 - 1 ! dec ebx ! mov SzY1, ebx 'SzY2 = SzY1 - 1 ! dec ebx ! mov SzY2, ebx 'SzY3 = SzY - 4 ! dec ebx ! mov SzY3, ebx 'SzY4 = SzY3 - 1 ! dec ebx ! mov SzY4, ebx '-------- Positions -------- 'Horz Positions, left side, left to right ! mov ebx, PsX0 'PsX1 = PsX + 1 ! inc ebx ! mov PsX1, ebx 'PsX2 = PsX1 + 1 , ! inc ebx ! mov PsX2, ebx 'Horz Positions, 'right side, right to left 'PsX3 = PsX + SzX2 ! mov ebx, PsX0 ! add ebx, SzX1 ! mov PsX3, ebx 'PsX4 = PsX3 + 1 ! dec ebx ! mov PsX4, ebx 'Vert Positions, top, top going down ! mov ebx, PsY0 'PsY1 = PsY0 + 1 ! inc ebx ! mov PsY1, ebx 'PsY2 = PsY1 + 1 ! inc ebx ! mov PsY2, ebx 'Vert Positions, bottom, bottom going up 'PsY3 = PsY0 + SzY0 ! mov ebx, PsY0 ! add ebx, SzY1 ! mov PsY3, ebx 'PsY4 = PsY3 + 1 ! dec ebx ! mov PsY4, ebx 'clean up ! pop ebx 'see PUSH above, and POP is mate to PUSH 'start DDT 'border for "sunken" appearance 'top control add line, hDlg, 65535&, "", PsX0, PsY0, SzX1, LW , %ss_grayrect, _ %ws_ex_left control add line, hDlg, 65535&, "", PsX1, PsY1, SzX3, LW , %ss_blackrect, _ %ws_ex_left 'left control add line, hDlg, 65535&, "", PsX0, PsY1, LW , SzY1, %ss_grayrect, _ %ws_ex_left control add line, hDlg, 65535&, "", PsX1, PsY2, LW , SzY3, %ss_blackrect, _ %ws_ex_left 'right control add line, hDlg, 65535&, "", PsX4, PsY1, LW , SzY2, %ss_grayrect, _ %ws_ex_left control add line, hDlg, 65535&, "", PsX3, PsY0, LW , SzY0 , %ss_whiterect, _ %ws_ex_left 'bottom control add line, hDlg, 65535&, "", PsX2, PsY4, SzX4, LW , %ss_grayrect, _ %ws_ex_left control add line, hDlg, 65535&, "", PsX0, PsY3, SzX0 , LW , %ss_whiterect, _ %ws_ex_left 'the listbox LB_Style = %lbs_disablenoscroll or %lbs_nointegralheight or %lbs_notify or _ %ws_tabstop or %ws_vscroll or Opt_Style if varptr(Items()) then control add listbox, hDlg, CID, Items(), PsX2, PsY2, SzX4, SzY4, LB_Style, _ %ws_ex_left else control add listbox, hDlg, CID, , PsX1, PsY2, SzX3, SzY3, LB_Style, _ %ws_ex_left end if end sub '[/code]
#compile exe #dim all %UNICODE = 1 #link "./Add_Sunken_Listbox.sll" %ID_ExitBtn = 1000& %ID_LBUT = 1001& 'ListBoxUnderTest %ID_CompTxtbx = 1002& %ID_FlatLB = 1003& callback function DlgCB() as long if cb.msg = %wm_command then if (cb.ctl = %ID_ExitBtn) and (cb.ctlmsg = %bn_clicked) then dialog end cb.hndl end if end if end function function pbmain () as long local hDlg as dword local Items() as wstring 'local x as long dialog default font "Microsoft Sans Serif", 12, 0, 1 dialog new 0, "Demo My LISTBOX"$$, , , 160, 112 to hDlg ' control add textbox, hDlg, %ID_CompTxtbx, _ "TEXTBOX for sunken border comparison.", 10, 5, 140, 12 ' dim Items(1 to 5) Items(1) = "1 - My sunken LISTBOX."$$ Items(2) = "2 - 8 bit string test."$ Items(3) = "Line 3"$$ Items(4) = "How now lazy dog?"$$ Items(5) = "Something to scroll to."$$ AddSunkenListbox (hDlg, %ID_LBUT, 10, 22, 140, 40, Items()) ' redim Items(1 to 2) Items(1) = "Flat LISTBOX."$$ Items(2) = "Another line."$$ control add listbox, hDlg, %ID_FlatLB, Items(), 10, 67, 140, 20, _ %lbs_disablenoscroll or %lbs_nointegralheight or %lbs_notify or _ %ws_tabstop or %ws_vscroll ' control add button, hDlg, %ID_ExitBtn, "Exit", 65, 92, 30, 15 control set focus hDlg, %ID_ExitBtn 'else text in TEXTBOX is selected ' dialog show modal hDlg call DlgCB end function
Now to the other project. ✌)
Created on 08 Sept 2023.
To
Domain Home. | To Dale's Notebook index. | To Programs index. |