Author |
Topic: Adding Combo Box (Read 870 times) |
|
CharlesB
New Member
member is offline


Gender: 
Posts: 46
|
 |
Adding Combo Box
« Thread started on: May 3rd, 2015, 8:24pm » |
|
I apologize for this, for as I read the other threads they are so advanced compared to my questions.
But, I am just stumped here. I thought that I had the basic dialogue box down, but I have hit a brick wall here. The dialogue box below works just fine, but when I added the combo box, I cannot populate it.
I just get an empty drop-down list. It seems to me that everything is in place, but I just cannot get this to work.
I'm sure that the problem is obvious, but not to me. Thanks for any help, Charles Code:
install @lib$+"WINLIB2"
BS_DEFPUSHBUTTON = &1
CB_ADDSTRING = &143
CB_SETCURSEL = &14E
CBS_DROPDOWNLIST = &3
ES_AUTOHSCROLL = &80
ES_NUMBER = &2000
LB_ADDSTRING = &180
LB_GETCURSEL = &188
UDM_SETRANGE = &465
UDS_ALIGNRIGHT = &4
UDS_AUTOBUDDY = &10
UDS_SETBUDDYINT = &2
WS_CHILD = &40000000
WS_GROUP = &20000
WS_VISIBLE = &10000000
rem dlg%=fn_newdialog("NonStock", 40, 40, 270, 135, 10, 650)
rem proc_groupbox(dlg%, "Cutting Modes", 0, 4, 4, 152, 96, WS_GROUP)
dlg%=fn_newdialog("NonStock Tubing", 20, 20, 170, 128, 9, 600)
proc_groupbox(dlg%, "Group box", 0, 4, 4, 152, 120, WS_GROUP)
proc_editbox(dlg%, "Enter OD", 101, 12, 20, 64, 12, ES_AUTOHSCROLL)
proc_editbox(dlg%, "Enter ID", 102, 82, 20, 64, 12, ES_AUTOHSCROLL)
proc_editbox(dlg%, "Enter Wall", 103, 12, 40, 64, 12, ES_AUTOHSCROLL)
rem proc_listbox(dlg%, "Select", 104, 82, 40, 64, 48, 0)
rem proc_listbox(dlg%, "Info", 104, 2, 2, 220, 110, 0)
proc_combobox(dlg%, "", 104, 82, 40, 64, 48, CBS_DROPDOWNLIST)
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Butyrate 560"
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Butyrate FDA"
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Provista"
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Provista UVA"
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Butyrate Colored"
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Provista Colored"
sys "SendDlgItemMessage", !dlg%, 104, CB_ADDSTRING, 0, "Polycarbonate"
proc_radiobutton(dlg%, "Del quoteFile", 105, 12, 64, 64, 10, 0)
proc_radiobutton(dlg%, "Keep quoteFile", 106, 12, 82, 64, 10, 0)
proc_pushbutton(dlg%, "OK", 1, 12, 108, 56, 14, WS_GROUP or BS_DEFPUSHBUTTON)
proc_pushbutton(dlg%, "Cancel", 2, 92, 108, 56, 14, 0)
proc_showdialog(dlg%)
on close proc_closedialog(dlg%):quit
on error proc_closedialog(dlg%):print'report$:end
Click%=0
on sys Click% = @wparam% : return
repeat
wait 1
click%=0
swap Click%, click%
until click%=1 or click%=2 or !dlg%=0
if click%=1 then
print "OK pressed, settings were:"'
dim text% 255
sys "GetDlgItemText", !dlg%, 101, text%, 255
print " OD Text box contained """$$text%""""
od=val($$text%)
rem SYS "GetDlgItemInt", !dlg%, 102, 0 ,FALSE TO id%
sys "GetDlgItemText", !dlg%, 102, text%,255
print " ID is """$$text%""""
rem Text box contained """$$text2%""""
id = val($$text%)
rem print "Number box contained ";Val%
sys "GetDlgItemText", !dlg%, 103, text%, 255
print "Combobox selection was """$$text%""""
print " WALL Text box contained """$$text%""""
wall=val($$text%)
sys "SendDlgItemMessage", !dlg%, 104, LB_GETCURSEL, 0, 0 to sel%
print "Listbox selection index was ";sel%
sys "IsDlgButtonChecked", !dlg%, 105 to rb1%
if rb1% then
R%=fn_delfile("busadafiles\Quotation.dat")
rem OSCLI "del busadafiles\quotation.dat"; PRINT "Quotation file deleted."
else print "Keep Quotation File"
endif
sys "IsDlgButtonChecked", !dlg%, 107 to cb%
if cb% print "Checkbox was checked" else print "Checkbox was not checked"
else
print "Cancel pressed"
endif
proc_closedialog(dlg%)
|
« Last Edit: May 3rd, 2015, 8:25pm by CharlesB » |
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Adding Combo Box
« Reply #1 on: May 3rd, 2015, 10:10pm » |
|
on May 3rd, 2015, 8:24pm, CharlesB wrote:I thought that I had the basic dialogue box down, but I have hit a brick wall here. |
|
I fear you have a basic misunderstanding about how dialogue boxes work in Windows. Here are the essentials:
Build a template in memory representing the dialogue box and its contents (PROC_newdialog, PROC_pushbutton etc.). This must be done only once during the initialisation phase of your program.
Create and display the dialogue box itself using the stored memory template (PROC_showdialog).
Initialise the contents of the dialogue box, as necessary.
Allow the user to interact with the dialogue box.
When the user clicks on OK (for example) read back the contents of the dialogue box.
Close the dialogue box (PROC_closedialog).
Repeat steps 2 to 6 as required; you must not repeat step 1. It is important to realise that you can only initialise the contents of the dialogue box (step 3) when it exists, which means after the call to PROC_showdialog (step 2).
In the code you listed you attempt to populate the combobox before the call to PROC_showdialog, when the dialogue box itself does not yet exist (it is just a template in memory).
This is emphasised in the BB4W help documentation where, in the Initialising the contents of a dialogue box section, it says "Note that this initialisation must take place after the call to PROC_showdialog":
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#initdialog
Richard.
|
|
Logged
|
|
|
|
hellomike
New Member
member is offline


Gender: 
Posts: 46
|
 |
Re: Adding Combo Box
« Reply #2 on: May 4th, 2015, 2:12pm » |
|
Maybe the confusion is dlg%....
So effectively: 'dlg%' is a pointer to a template determined by calling FN_newdialog() and '!dlg%' is a pointer to a dialog box which is determined by calling PROC_showdialog()
Is this a correct assumption?
Thanks
Mike
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Adding Combo Box
« Reply #3 on: May 4th, 2015, 3:27pm » |
|
on May 4th, 2015, 2:12pm, hellomike wrote:'!dlg%' is a pointer to a dialog box which is determined by calling PROC_showdialog() Is this a correct assumption? |
|
It's not a pointer. When the dialogue box is open (i.e. after you call PROC_showdialog() but before you call PROC_closedialog()) !dlg% contains its window handle. When the dialogue box is not open (i.e. before the call to PROC_showdialog() or after the dialogue box has been closed) !dlg% contains zero. So by examining !dlg% you can tell whether the dialogue box is open or not.
But I don't think it's terribly helpful to think in terms of dlg% and !dlg%, because they are implementation details specific to the BB4W libraries. Rather it's better to consider whether the dialogue box is closed (i.e. exists only as a template in memory) or open (i.e. has a window handle), because that's fundamental to Windows and would be useful knowledge if you were to move to another programming language.
Richard.
|
|
Logged
|
|
|
|
CharlesB
New Member
member is offline


Gender: 
Posts: 46
|
 |
Re: Adding Combo Box
« Reply #4 on: May 4th, 2015, 4:22pm » |
|
Thank you Richard, it is clear that I do not have an understanding of dialogue boxes. I was successful in composing some boxes, and was aware that the order of the code is important. But this is a handful to digest, and I thank you again for your consistent help.
In the meantime, the problem was "obvious" and you caught it immediately. It took a second to fix once I saw your point. Charles
|
« Last Edit: May 4th, 2015, 5:15pm by CharlesB » |
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Adding Combo Box
« Reply #5 on: May 4th, 2015, 5:23pm » |
|
on May 4th, 2015, 4:22pm, CharlesB wrote:But this is a handful to digest |
|
To rattle on again about a subject which has been discussed ad-nauseam here, this all relates to the absence of the GUILIB library.
When I originally wrote WINLIB2 (etc.) I made no concessions to the beginner. Because it was clear to me how dialogue boxes worked in Windows I assumed it would be clear to everybody else. So the library was written not with user-friendliness in mind, but as the most straightforward interface between BBC BASIC and the Windows API that I could think of.
This is the way I always approach things. I don't want BB4W to limit what you can do, so I prefer to implement relatively low-level interfaces to Windows. They may not be terribly easy to use, but they are flexible.
However it has become evident subsequently that not everybody 'gets' the Windows API, and what they would prefer to have is a simple, user-friendly way of creating dialogue boxes (etc.), even if as a result there are certain things that are difficult - or even impossible - to achieve. This is very much the approach taken by Liberty BASIC and LBB.
As a result I proposed a GUILIB library for BB4W which would provide such a user-friendly interface. I won't go over old ground again and bemoan the fact that this library never came to fruition, especially as it was the cause of much upset and complaint at the time (the old threads are still there for people to read).
So we are where we are. The only available method of creating dialogue boxes and other controls in BB4W requires a reasonable understanding of the way Windows works. Sorry.
Richard.
|
|
Logged
|
|
|
|
|