Hello there,
in this small prog. i'd like my StringGadgets to be activated all the time (alternate with 'Enter'). But when i use a ComboBox, i can't get my StringGadget focused again.  Does somebody know a way to bypass this problem ?
If OpenWindow(0, 200, 150, 200, 150,  #PB_Window_SystemMenu, "Problem with FOCUS")        
        If CreateGadgetList(WindowID(0))    
            ComboBoxGadget(1,10,10,180,120) 
            For a=1 To 5 : AddGadgetItem(1, -1, "Item "+Str(a)) : Next 
            SetGadgetState(1,0)
            StringGadget(2,10,60,180,20,"")
            StringGadget(3,10,100,180,20,"")
            ActivateGadget(2)
        EndIf        
        Repeat                
        EventID = WaitWindowEvent()
        GadgetID = EventGadgetID()
        Select EventID
            Case #wm_KeyDown
                If EventwParam() = 13 
                  Select GadgetID 
                    Case 2 
                      SetGadgetText(3,"")
                      ActivateGadget(3) 
                    Case 3 
                      SetGadgetText(2,"")
                      ActivateGadget(2) 
                  EndSelect 
                EndIf 
            Case #PB_EventGadget
                 Select GadgetID
                    Case 1
                        ;ActivateGadget(2)  ;can't be used!!! 
                 EndSelect                 
        EndSelect
        Until Eventid = #PB_EventCloseWindow
EndIf     
End
Thx for your help.
			
			
									
									
						ComboBoxGadget and ActivateGadget() : Problem
HI
I think the problem is when you go into the gadget the gadget id goes to 1 because of this the gadget 2 is activated and so on ....
I think you want to ask for the gadget state 1 first and in case of change or somethig else aktivate the 2nd gadget
 
in this case you only got the error if you change the gadget to the 2nd so you must remember the last ......
I hope this could help you
			
			
									
									
						I think the problem is when you go into the gadget the gadget id goes to 1 because of this the gadget 2 is activated and so on ....
I think you want to ask for the gadget state 1 first and in case of change or somethig else aktivate the 2nd gadget
Code: Select all
 
....
last=0
......
        Select GadgetID 
          Case 1 
            ab=GetGadgetState(1)
            ; gibt den aktuell gewählten Eintrag-Index zurück, -1 wenn nichts markiert ist. 
            If ab<>last
              ActivateGadget(2) 
              last=ab
            EndIf  
        EndSelect 
......
in this case you only got the error if you change the gadget to the 2nd so you must remember the last ......
I hope this could help you
I had quite a few problems using that method of trapping the enter key - I had to switch to the addkeyboardshortcut() method to get consistent results.. That might not be your trouble right now but be warned! 
			
			
									
									
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
						Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Thanx willib,
Your solution works fine if i change the item in the ComboBox but what's going on if i choose the same one !!! Then i still can't activate the StringGadget again !
Anyway i spent time with MSDN today and found a solution with WinAPI... (maybe it could interest somebody)
;************************************************
;****Activate a StringGagdget after releasing a ComboBox
;************************************************
If OpenWindow(0, 200, 150, 200, 150, #PB_Window_SystemMenu, "")
If CreateGadgetList(WindowID(0))
ComboBoxGadget(1,10,10,180,120)
For a=1 To 5 : AddGadgetItem(1, -1, "Item "+Str(a)) : Next
SetGadgetState(1,0)
StringGadget(2,10,60,180,20,"")
StringGadget(3,10,100,180,20,"")
ActivateGadget(2)
EndIf
Repeat
EventID = WaitWindowEvent()
GadgetID = EventGadgetID()
Select EventID
Case #wm_KeyDown
If EventwParam() = 13
Select GadgetID
Case 2
SetGadgetText(3,"")
ActivateGadget(3)
Case 3
SetGadgetText(2,"")
ActivateGadget(2)
EndSelect
EndIf
Case #PB_EventGadget
Select GadgetID
Case 1
Result = SendMessage_(GadgetID(1), #CB_GETDROPPEDSTATE, 0, 0)
If Result <> 1
ActivateGadget(2)
Endif
EndSelect
EndSelect
Until Eventid = #PB_EventCloseWindow
EndIf
End
Thanks again for Support
			
			
									
									
						Your solution works fine if i change the item in the ComboBox but what's going on if i choose the same one !!! Then i still can't activate the StringGadget again !
Anyway i spent time with MSDN today and found a solution with WinAPI... (maybe it could interest somebody)
;************************************************
;****Activate a StringGagdget after releasing a ComboBox
;************************************************
If OpenWindow(0, 200, 150, 200, 150, #PB_Window_SystemMenu, "")
If CreateGadgetList(WindowID(0))
ComboBoxGadget(1,10,10,180,120)
For a=1 To 5 : AddGadgetItem(1, -1, "Item "+Str(a)) : Next
SetGadgetState(1,0)
StringGadget(2,10,60,180,20,"")
StringGadget(3,10,100,180,20,"")
ActivateGadget(2)
EndIf
Repeat
EventID = WaitWindowEvent()
GadgetID = EventGadgetID()
Select EventID
Case #wm_KeyDown
If EventwParam() = 13
Select GadgetID
Case 2
SetGadgetText(3,"")
ActivateGadget(3)
Case 3
SetGadgetText(2,"")
ActivateGadget(2)
EndSelect
EndIf
Case #PB_EventGadget
Select GadgetID
Case 1
Result = SendMessage_(GadgetID(1), #CB_GETDROPPEDSTATE, 0, 0)
If Result <> 1
ActivateGadget(2)
Endif
EndSelect
EndSelect
Until Eventid = #PB_EventCloseWindow
EndIf
End
Thanks again for Support


