Wesley,
I think that what happens is that the message pump keeps querying the control
with the focus for notifications. And like Russ said, if your callback does not
have code to isolate the notifications, that msgbox will just keep coming up.
At least, this is how I envision what is happening, and if I'm wrong, would
someone (Lance) please correct me. I know I have stumbled into this problem
over and over, trying to use a msgbox for debugging. It can be quite frustrating
because the only way to recover is to ctrl-alt-del and end the task. For that
reason I often times just reset the text of a label control rather than depend
on a msgbox for my debugging.
------------------
Announcement
Collapse
No announcement yet.
Self Calling Callback??
Collapse
X
-
Wesley,
What Lance is saying is that in the Callback function you have to
test to see what kind of event called it. Without that test the
callback will react to the control losing focus as easily as as it
reacts to getting the focus or what you really want, to react
when the option button is clicked. So what you probably need is:
CALLBACK FUNCTION something()
IF CBCTLMSG=BN_CLICKED THEN dosomething
END FUNCTION
------------------
Leave a comment:
-
I too have not had time to run your code, but the "problem" seems most likely to be that your callback(s) are receiving notification messages, yet your code is not discriminating the message. Rather, it is just accepting the callback event regardless of it's nature.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment:
-
Hi Bern, Scott, & Charles,
I thank you all for your input. I changed the equates to different names. It certainly
does make the code easier to follow. It seems that setting focus solved the problem.
I am quiet happy to have "it" solved but I am a long way from understanding exactly why
it solved the problem.
As I read/study/learn more and more (mostly from this forum) I make myself comments in
what will one day be my own personal skeleton program. It it not meant to be an exact
road map, but rather a reminder to myself of where things go and why they go where they
do.
Tonight I addedCode:Control Set Focus hDlg1, %Quit 'Set Focus To Keep Things From Getting Screwy
I would appreciate it if someone could respond with:
(1) an explination of what was going on before I added the 'Control Set Focus' line
and
(2) why adding the line fixed things
The discussion of 'Control Set Focus' in the help files is not much help at all.
I often fear that my frequent posts may be abusing the generousity of all you
guys who give your time here, I certainly hope that is not the case
I sincerely appreciate your help,
Wesley
------------------
Leave a comment:
-
Set focus to %Quit button as shown below:
Code:CALLBACK FUNCTION Dialog_Callback() SELECT CASE CBMSG CASE %WM_INITDIALOG CONTROL SET FOCUS hDlg1, %Quit END SELECT END FUNCTION
and focus on it.
------------------
Leave a comment:
-
Correct me if I'm wrong but does the item itself have a %WM_INITDIALOG and %WM_CREATE
If so, you are experiencing WM_CREATE and may need to parse down to CASE ELSE or whatever your callback is doing.
------------------
Scott
Leave a comment:
-
Wesley, I have not tested your code, but it is confusing to see
equates with the same name as your callback procs. Have you tried
changing your code so that the equates/callback Fns are uniquely named?
------------------
Bernard Ertl
Leave a comment:
-
Self Calling Callback??
Hello Everyone,
Often times, when I try to reduce a portion of my program down to a size that can be posted,
I figure out what the problem is in the process. This is not one of those times
Consider the following:
Code:'TestProg.bas, PowerBasic/DLL 6.00 'Wesley Brown, March 26, 2001 #Compile Exe #Register None #Include "Win32Api.Inc" 'Define Constants %ACom0 = 100 : %BCom0 = 200 : %CCom0 = 300 : %LCom0 = 400 %ACom1 = 101 : %BCom1 = 201 : %CCom1 = 301 : %LCom1 = 401 %ACom2 = 102 : %BCom2 = 202 : %CCom2 = 302 : %LCom2 = 402 %ACom3 = 103 : %BCom3 = 203 : %CCom3 = 303 : %LCom3 = 403 %ACom4 = 104 : %BCom4 = 204 : %CCom4 = 304 : %LCom4 = 404 %ACom5 = 105 : %BCom5 = 205 : %CCom5 = 305 : %LCom5 = 405 %ACom6 = 106 : %BCom6 = 206 : %CCom6 = 306 : %LCom6 = 406 %ACom7 = 107 : %BCom7 = 207 : %CCom7 = 307 : %LCom7 = 407 %ACom8 = 108 : %BCom8 = 208 : %CCom8 = 308 : %LCom8 = 408 %ACom9 = 109 : %BCom9 = 209 : %CCom9 = 309 : %LCom9 = 409 %AComN = 110 : %BComN = 210 : %CComN = 310 : %LComN = 410 %DevLbl = 500 %Device1 = 510 %Device2 = 511 %Device3 = 512 %DevMag = 520 %DevEZP = 521 %DevEZC = 522 %Quit = 540 '======================================================================================== 'Define Variables (Note: All Variables Are Global) Global ACom As String 'Com Port Connected To Device A Global BCom As String 'Com Port Connected To Device B Global CCom As String 'Com Port Connected To Device C Global hDlg1 As Long Global Result As Long '======================================================================================== CallBack Function AComN() : ACom = "Null" : End Function CallBack Function ACom0() ACom = "Com0" ' MsgBox "Device A - Com 0" End Function CallBack Function ACom1() : ACom = "Com1" : End Function CallBack Function ACom2() : ACom = "Com2" : End Function CallBack Function ACom3() : ACom = "Com3" : End Function CallBack Function ACom4() : ACom = "Com4" : End Function CallBack Function ACom5() : ACom = "Com5" : End Function CallBack Function ACom6() : ACom = "Com6" : End Function CallBack Function ACom7() : ACom = "Com7" : End Function CallBack Function ACom8() : ACom = "Com8" : End Function CallBack Function ACom9() : ACom = "Com9" : End Function '============================================= CallBack Function BComN() : BCom = "Null" : End Function CallBack Function BCom0() : BCom = "Com0" : End Function CallBack Function BCom1() : BCom = "Com1" : End Function CallBack Function BCom2() : BCom = "Com2" : End Function CallBack Function BCom3() : BCom = "Com3" : End Function CallBack Function BCom4() : BCom = "Com4" : End Function CallBack Function BCom5() : BCom = "Com5" : End Function CallBack Function BCom6() : BCom = "Com6" : End Function CallBack Function BCom7() : BCom = "Com7" : End Function CallBack Function BCom8() : BCom = "Com8" : End Function CallBack Function BCom9() : BCom = "Com9" : End Function '============================================= CallBack Function CComN() : CCom = "Null" : End Function CallBack Function CCom0() : CCom = "Com0" : End Function CallBack Function CCom1() : CCom = "Com1" : End Function CallBack Function CCom2() : CCom = "Com2" : End Function CallBack Function CCom3() : CCom = "Com3" : End Function CallBack Function CCom4() : CCom = "Com4" : End Function CallBack Function CCom5() : CCom = "Com5" : End Function CallBack Function CCom6() : CCom = "Com6" : End Function CallBack Function CCom7() : CCom = "Com7" : End Function CallBack Function CCom8() : CCom = "Com8" : End Function CallBack Function CCom9() : CCom = "Com9" : End Function '======================================================================================== CallBack Function Dialog_Callback() : End Function CallBack Function ExitProg() As Long : Dialog End hDlg1, 0 : End Function Function PbMain ACom = "" : BCom = "" : CCom = "" Dialog New 0, "Test Program",,, 300, 150, %Ws_PopUp Or %Ws_Visible Or %Ws_ClipChildren _ Or %Ws_Caption Or %Ws_SysMenu Or %Ws_MinimizeBox, 0 To hDlg1 Control Add Label, hDlg1, %DevLbl, "Device", 15, 19, 25, 13 Control Add Label, hDlg1, %DevMag, "DeviceA", 5, 33, 50, 16 Control Add Label, hDlg1, %DevEZP, "DeviceB", 5, 54, 50, 16 Control Add Label, hDlg1, %DevEZC, "DeviceC", 5, 75, 50, 16 Control Add Label, hDlg1, %LComN, "N/C", 59, 19, 25, 13 Control Add Label, hDlg1, %LCom0, "Com0", 79, 19, 25, 13 Control Add Label, hDlg1, %LCom1, "Com1", 100, 19, 25, 13 Control Add Label, hDlg1, %LCom2, "Com2", 121, 19, 25, 13 Control Add Label, hDlg1, %LCom3, "Com3", 142, 19, 25, 13 Control Add Label, hDlg1, %LCom4, "Com4", 163, 19, 25, 13 Control Add Label, hDlg1, %LCom5, "Com5", 184, 19, 25, 13 Control Add Label, hDlg1, %LCom6, "Com6", 205, 19, 25, 13 Control Add Label, hDlg1, %LCom7, "Com7", 226, 19, 25, 13 Control Add Label, hDlg1, %LCom8, "Com8", 247, 19, 25, 13 Control Add Label, hDlg1, %LCom9, "Com9", 268, 19, 25, 13 Control Add Option, hDlg1, %AComN, "", 62, 32, 10, 10, %Ws_Group Call AComN Control Add Option, hDlg1, %ACom0, "", 83, 32, 10, 10 Call ACom0 Control Add Option, hDlg1, %ACom1, "", 104, 32, 10, 10 Call ACom1 Control Add Option, hDlg1, %ACom2, "", 125, 32, 10, 10 Call ACom2 Control Add Option, hDlg1, %ACom3, "", 146, 32, 10, 10 Call ACom3 Control Add Option, hDlg1, %ACom4, "", 167, 32, 10, 10 Call ACom4 Control Add Option, hDlg1, %ACom5, "", 188, 32, 10, 10 Call ACom5 Control Add Option, hDlg1, %ACom6, "", 209, 32, 10, 10 Call ACom6 Control Add Option, hDlg1, %ACom7, "", 230, 32, 10, 10 Call ACom7 Control Add Option, hDlg1, %ACom8, "", 251, 32, 10, 10 Call ACom8 Control Add Option, hDlg1, %ACom9, "", 272, 32, 10, 10 Call ACom9 Control Add Option, hDlg1, %BComN, "", 62, 53, 10, 10, %Ws_Group Call BComN Control Add Option, hDlg1, %BCom0, "", 83, 53, 10, 10 Call BCom0 Control Add Option, hDlg1, %BCom1, "", 104, 53, 10, 10 Call BCom1 Control Add Option, hDlg1, %BCom2, "", 125, 53, 10, 10 Call BCom2 Control Add Option, hDlg1, %BCom3, "", 146, 53, 10, 10 Call BCom3 Control Add Option, hDlg1, %BCom4, "", 167, 53, 10, 10 Call BCom4 Control Add Option, hDlg1, %BCom5, "", 188, 53, 10, 10 Call BCom5 Control Add Option, hDlg1, %BCom6, "", 209, 53, 10, 10 Call BCom6 Control Add Option, hDlg1, %BCom7, "", 230, 53, 10, 10 Call BCom7 Control Add Option, hDlg1, %BCom8, "", 251, 53, 10, 10 Call BCom8 Control Add Option, hDlg1, %BCom9, "", 272, 53, 10, 10 Call BCom9 Control Add Option, hDlg1, %CComN, "", 62, 74, 10, 10, %Ws_Group Call CComN Control Add Option, hDlg1, %CCom0, "", 83, 74, 10, 10 Call CCom0 Control Add Option, hDlg1, %CCom1, "", 104, 74, 10, 10 Call CCom1 Control Add Option, hDlg1, %CCom2, "", 125, 74, 10, 10 Call CCom2 Control Add Option, hDlg1, %CCom3, "", 146, 74, 10, 10 Call CCom3 Control Add Option, hDlg1, %CCom4, "", 167, 74, 10, 10 Call CCom4 Control Add Option, hDlg1, %CCom5, "", 188, 74, 10, 10 Call CCom5 Control Add Option, hDlg1, %CCom6, "", 209, 74, 10, 10 Call CCom6 Control Add Option, hDlg1, %CCom7, "", 230, 74, 10, 10 Call CCom7 Control Add Option, hDlg1, %CCom8, "", 251, 74, 10, 10 Call CCom8 Control Add Option, hDlg1, %CCom9, "", 272, 74, 10, 10 Call CCom9 Control Add Button, hDlg1, %Quit, "Exit", 125, 120, 50, 14, Call ExitProg Dialog Show Modal hDlg1, Call Dialog_Callback To Result End Function
have any idea what is going on with this? To really see what I mean, uncomment
MsgBox "Device A - Com 0" and run the program.
I have spent the better part of today playing around with this and have gotten no where.
During one experiment I made it so that whenever an option was clicked, that option would
disable itself. An example of what happened: (among several other weird things)
When Device A - Com1 was clicked, Device B - Com 2 would become disabled.
As always, I appreciate any and all help
Wesley
------------------
[This message has been edited by Wesley Brown (edited March 26, 2001).]Tags: None
Leave a comment: