Author |
Topic: Progressbar problem. (Read 1218 times) |
|
81RED
Guest
|
 |
Progressbar problem.
« Thread started on: Jun 24th, 2009, 11:39am » |
|
Am having a minor problem getting a progressbar to display consistently when using the "'Docking' a dialogue box" procedure described in the manual.
This snippet:
INSTALL @lib$+"WINLIB2B" INSTALL @lib$+"WINLIB3" dlg%=FN_newdialog("",0,0,180,70,8,560) dlg%!16 = (dlg%!16 OR &40000000) AND NOT &80400000 PROC_dlgitem(dlg%,"OK",1,20,49,56,14,&50030001,&80) PROC_dlgitem(dlg%,"Cancel",2,102,49,56,14,&50010000,&80) PROC_dlgitem(dlg%,"Select File",100,55,22,64,16,&50010000,&80) progress%=FN_createprogressbar(@hwnd%,20,15,230,8,1) PROC_showprogressbar(progress%,100) PROC_showdialog(dlg%) DIM rc{l%,t%,r%,b%} SYS "GetWindowRect", !dlg%, rc{} SYS "GetWindowLong", @hwnd%, -16 TO style% SYS "SetWindowLong", @hwnd%, -16, style% AND NOT &50000 SYS "AdjustWindowRect", rc{}, style% AND NOT &50000, 0 SYS "SetWindowPos", @hwnd%, 0, 0, 0, rc.r%-rc.l%, rc.b%-rc.t%, 102
Results in the progressbar being shown randomly in Vista, and "garbled" in XP. I am assuming that the problem has to do with FN_createprogressbar pointing to @hwnd instead of the "child" window, but how on earth do I convince it otherwise?
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #1 on: Jun 24th, 2009, 10:05pm » |
|
Quote:I am assuming that the problem has to do with FN_createprogressbar pointing to @hwnd instead of the "child" window, but how on earth do I convince it otherwise? |
|
You should create your progress bar using PROC_dlgctrl(). Although the main Help documentation doesn't give an example of a progress bar in a dialogue box, you can adapt the trackbar example (progress bars and trackbars are very similar in operation):
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#trackbar
The class name for a progress bar is "msctls_progress32".
Richard.
|
|
Logged
|
|
|
|
81RED
Guest
|
 |
Re: Progressbar problem.
« Reply #2 on: Jun 25th, 2009, 07:57am » |
|
Thank you very much, that at least solved the problem of the progressbar rarely showing.
I can't seem to get the darn thing to update though, have followed the example you linked to, but "SYS "SendDlgItemMessage", !dlg%, id%, 1029, 1, progress%" has no effect whatsoever. Either I'm being daft (most probably), or there's more to the exercise..
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #3 on: Jun 25th, 2009, 08:57am » |
|
Quote:'SYS "SendDlgItemMessage", !dlg%, id%, 1029, 1, progress%' has no effect whatsoever. |
|
The PBM_STEPIT message (1029) takes no parameters (wParam = 0, lParam = 0) so your 'progress%' value will be ignored, but apart from that the code works fine for me here.
If you're trying to set the progress bar to a specific position, rather than stepping it, you should be using PBM_SETPOS not PBM_STEPIT (and the parameter format is different from what you used):
http://msdn.microsoft.com/en-us/library/bb760844.aspx
Quote:Either I'm being daft (most probably), or there's more to the exercise.. |
|
It looks as though you were perhaps trying to send trackbar messages (e.g. TBM_SETPOS) to a progress bar, which does count as perhaps a little daft!
Incidentally, with the Windows Constants utility now available there's no excuse for using numeric values any more:
http://bb4w.wikispaces.com/Tools+and+Utilities
Richard.
|
|
Logged
|
|
|
|
81RED
Guest
|
 |
Re: Progressbar problem.
« Reply #4 on: Jun 25th, 2009, 09:20am » |
|
on Jun 25th, 2009, 08:57am, Richard Russell wrote:It looks as though you were perhaps trying to send trackbar messages (e.g. TBM_SETPOS) to a progress bar, which does count as perhaps a little daft! |
|
No sir, not guilty. (of that, at least) 
So far, my unsuccessful attempts have resulted in the following:
PROC_dlgctrl(dlg%,"",id%,10,7,156,7,&50000000,"msctls_progress32") SYS "SendDlgItemMessage", !dlg%, id%, 1030, 1,somenumber% SYS "SendDlgItemMessage", !dlg%, id%, 1029, 1
Which, needless to say, does not work.
Have not looked at the Constants utility, but looks like I ought to ASAP..
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #5 on: Jun 25th, 2009, 11:34am » |
|
Quote:PROC_dlgctrl(dlg%,"",id%,10,7,156,7,&50000000,"msctls_progress32") SYS "SendDlgItemMessage", !dlg%, id%, 1030, 1,somenumber% SYS "SendDlgItemMessage", !dlg%, id%, 1029, 1 |
|
This code looks quite wrong to me:
1. I cannot find any progress bar message with the value 1030; the highest I can find is PBM_STEPIT (1029). There is a trackbar message with that value (TBM_SETRANGE) but as you plead "not guilty" to mistakenly using trackbar messages, that can't be the explanation 
2. The message 1029 (PBM_STEPIT) is missing the last parameter (SendDlgItemMessage always takes five parameters, and you only have four).
3. You've set the wParam value in your PBM_STEPIT message to '1'. Microsoft says you should set both wParam and lParam to '0'.
4. id% is a rather 'generic' variable name to use, which risks accidentally using the same ID for two or more controls. I would prefer that you use (e.g.) ID_PB or a constant value, to reduce the chance of such duplication.
5. Your code as listed implies that you've put the SendDlgItemMessage calls immediately after the PROC_dlgctrl(), which of course cannot work (hopefully that was just shorthand on your part, and there is code in between you've omitted).
Putting a progress bar in a dialogue box works fine for me, and I am confident that if you fix these problems it will work for you.
Richard.
|
|
Logged
|
|
|
|
81RED
Guest
|
 |
Re: Progressbar problem.
« Reply #6 on: Jun 25th, 2009, 12:09pm » |
|
Ahem, it would seem I declared my innocence too soon. Will investigate further when I have more time, so far I have also managed not getting it to work with the aid of the constants-utility.
|
|
Logged
|
|
|
|
81RED
Guest
|
 |
Re: Progressbar problem.
« Reply #7 on: Jun 25th, 2009, 1:50pm » |
|
Modified code:
PROC_dlgctrl(dlg%,"",666,10,7,156,7,&50000000,"msctls_progress32") (PROC_showdialog etc. in here..) SYS "SendDlgItemMessage", !dlg%, 666, 1025, 0,whatever% SYS "SendDlgItemMessage", !dlg%, 666, 1029, 0, 0
I even threw in a SYS "SendDlgItemMessage", !dlg%, 666, 1028, 1,0 to see if that made any difference.
One thing that I would very much like to know: Where does one find documentation on the various 4-digit codes, and what they refer to? (Apart from the Constants util)
Oh, and of course it still does not work.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #8 on: Jun 25th, 2009, 5:02pm » |
|
Quote:Oh, and of course it still does not work. |
|
The reason is not difficult to discover. Look at the definition of the PBM_SETRANGE message:
http://msdn.microsoft.com/en-us/library/bb760846.aspx
You will see that nMinRange is in the least-significant 16-bits of lParam and that nMaxRange is in the most-significant 16-bits of lParam. Note also that it says nMaxRange "must be greater than nMinRange".
Now observe what you send as the lParam value:
Quote:SYS "SendDlgItemMessage", !dlg%, 666, 1025, 0,whatever% |
|
You are putting nMaxRange (I'm assuming here that this is what whatever% is supposed to be) in the least-significant 16-bits and zero in the most-significant 16-bits. THIS IS THE WRONG WAY ROUND!
Correcting your code as follows works fine for me:
Code: SYS "SendDlgItemMessage", !dlg%, 666, 1025, 0, whatever% << 16
SYS "SendDlgItemMessage", !dlg%, 666, 1029, 0, 0 Quote:Where does one find documentation on the various 4-digit codes, and what they refer to? |
|
http://www.bbcbasic.co.uk/bbcwin/faq.html#q8 http://www.bbcbasic.co.uk/bbcwin/faq.html#q9
Richard.
|
|
Logged
|
|
|
|
81RED
Guest
|
 |
Re: Progressbar problem.
« Reply #9 on: Jun 25th, 2009, 9:43pm » |
|
That's very interesting. Not the least because I already tried swapping those parameters as part of my own fault-finding efforts. I happen to be intellectually challenged when it comes to most vs. least significant bits, so that's part of my usual routine.
To add insult to injury, modifying the code to the *exact* same as you posted above, have now caused the program to unceremoniously crash the BB4W IDE at a later point in the code - and still no progress in the bar.
Will replace that sodding bar with a message saying "out to lunch" for the time being.
Anyway, thank you very much for your efforts.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #10 on: Jun 25th, 2009, 10:43pm » |
|
Quote:Will replace that sodding bar with a message saying "out to lunch" for the time being. |
|
This is ridiculous, and I'm beginning to think you're just winding me up.
I have listed below the entire code of DLGDEMO.BBC with the minimal modifications necessary to add a progress bar to the dialogue box. If that works (it jolly well ought to) you need only compare it with yours.
Richard.
Code: REM. Program to demonstrate a Dialogue Box
INSTALL @lib$+"WINLIB2"
dlg%=FN_newdialog("Dialogue box",20,20,160,128,8,1000)
PROC_groupbox(dlg%,"Group box",0,4,4,152,96,&20000)
PROC_editbox(dlg%,"Text box",101,12,20,64,12,&80)
PROC_editbox(dlg%,"123456",102,82,20,64,12,&2000)
PROC_dlgctrl(dlg%,"",109,0,0,12,12,&50000096,"msctls_updown32")
PROC_combobox(dlg%,"",103,12,40,64,60,3)
PROC_listbox(dlg%,"",104,82,40,64,48,0)
PROC_radiobutton(dlg%,"Radiobutton 1",105,12,64,64,10,0)
PROC_dlgctrl(dlg%,"",111,10,82,140,10,&50000000,"msctls_progress32")
PROC_pushbutton(dlg%,"OK",1,12,108,56,14,&20001)
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
SYS "SendDlgItemMessage",!dlg%,103,&143,0,"Combobox 1"
SYS "SendDlgItemMessage",!dlg%,103,&143,0,"Combobox 2"
SYS "SendDlgItemMessage",!dlg%,103,&143,0,"Combobox 3"
SYS "SendDlgItemMessage",!dlg%,103,&143,0,"Combobox 4"
SYS "SendDlgItemMessage",!dlg%,103,&14E,0,0
SYS "SendDlgItemMessage",!dlg%,104,&180,0,"Listbox item 0"
SYS "SendDlgItemMessage",!dlg%,104,&180,0,"Listbox item 1"
SYS "SendDlgItemMessage",!dlg%,104,&180,0,"Listbox item 2"
SYS "SendDlgItemMessage",!dlg%,104,&180,0,"Listbox item 3"
SYS "CheckRadioButton",!dlg%,105,106,105
SYS "SendDlgItemMessage",!dlg%,109,&465,0,999
PBM_SETRANGE = &401
PBM_SETPOS = &402
SYS "SendDlgItemMessage", !dlg%, 111, PBM_SETRANGE, 0, 100 << 16
SYS "SendDlgItemMessage", !dlg%, 111, PBM_SETPOS, 50, 0
Click%=0
ON SYS Click%=@wparam% AND &FFFF: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% 100
SYS "GetDlgItemText",!dlg%,101,text%,100
PRINT "Text box contained """$$text%""""
SYS "GetDlgItemInt",!dlg%,102,0,1 TO Val%
PRINT "Number box contained ";Val%
SYS "GetDlgItemText",!dlg%,103,text%,255
PRINT "Combobox selection was """$$text%""""
SYS "SendDlgItemMessage",!dlg%,104,&188,0,0 TO sel%
PRINT "Listbox selection index was ";sel%
SYS "IsDlgButtonChecked",!dlg%,105 TO rb1%
IF rb1% PRINT "Radiobutton 1 was checked" ELSE PRINT "Radiobutton 2 was checked"
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%)
END
|
|
Logged
|
|
|
|
81RED
Guest
|
 |
Re: Progressbar problem.
« Reply #11 on: Jun 26th, 2009, 11:34am » |
|
Not winding you up at all - I guess I was the one wound up yesterday after hearing God knows how many "bar"-related jokes from my Visual Studio-enabled colleagues in the office next door.
In the meantime, I have found out what the problem was. It would seem that the MSDN entry on PBM_STEPIT does not apply quite as expected: "Advances the current position for a progress bar by the step increment and redraws the bar to reflect the new position".
The bit in bold only works if I put in a PROC_showdialog(dlg%) following the call. Also, a repeat of any PBM_SETRANGE call is also required as it will revert to default values.
With those two details in order, the progressbar (finally) works in the same fashion that PROC_showprogressbar did.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #12 on: Jun 26th, 2009, 6:34pm » |
|
Quote:It would seem that the MSDN entry on PBM_STEPIT does not apply quite as expected: |
|
That's extremely unlikely.
Quote:The bit in bold only works if I put in a PROC_showdialog(dlg%) following the call |
|
It's 'impossible'. Calling PROC_showdialog() a second time does nothing. You can see that this is the case by looking at its code:
Code: DEF PROC_showdialog(dlg%) : LOCAL I% : DIM I% -1
IF !dlg% <> 0 ENDPROC The very first thing it does is test to see whether the dialogue box already exists (IF !dlg% <> 0) and if it does it exits immediately.
So adding a second PROC_showdialog() cannot possibly explain the effect you observed. I would suggest (if you have the time) some further investigation to discover exactly what is happening.
Richard.
|
|
Logged
|
|
|
|
dynamic35
New Member
member is offline


Gender: 
Posts: 34
|
 |
Re: Progressbar problem.
« Reply #13 on: Feb 1st, 2010, 8:06pm » |
|
I have searched this section to learn how to 'tune' or calibrate in real time the fill GCOL in the command like CIRCLE fill x,y radius
I cannot find the solution under the discussions here. Maybe this could be achived by a kind of horizontal ruler with value ticks 0,1,2....15 . While moving the ruler from 0 to 15 we should have various filler colors in the circle . Is there a kind of ruler boom available somewhere in BBC Basic libs Greetings N62E25
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Progressbar problem.
« Reply #14 on: Feb 1st, 2010, 10:42pm » |
|
Quote:I have searched this section to learn how to 'tune' or calibrate in real time the fill GCOL in the command like CIRCLE fill x,y radius... Maybe this could be achived by a kind of horizontal ruler with value ticks 0,1,2....15 . While moving the ruler from 0 to 15 we should have various filler colors in the circle |
|
The kind of 'ruler' you describe is a TrackBar or slider as documented here:
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#createtrackbar
You could easily create a program that used (for example) three TrackBars, one each for red, green and blue, to select the colour to be used to fill a circle. This could be based on the example program WIDGETS.BBC.
You might also want to consider using the ChooseColor dialog, which is designed specifically for choosing a colour (which could be used as the fill colour of a circle):
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#choosecolor
The example program GUIDEMO.BBC uses that method.
If you need further help ask here again.
Richard.
|
|
Logged
|
|
|
|
|