How to Force window_1 to have Focus ?
Posted: Wed Aug 10, 2016 7:50 pm
Hello & Thanks ,
I have a two window program (Window_0 and Window_1) , (pimClip.pb).
Whenever there is a 'copy text' to the clipboard ,
this code opens up Window_1 :
The StringGadget (NewTopic) shows the cursur blinking ,
But the Window_1 does not have the Focus .
How can I force Window_1 to have the Focus ?
If I manually click Window_1 , all works as intended .
I need Window_1 to show Focus , so user doesn't have to click it first .
I have a two window program (Window_0 and Window_1) , (pimClip.pb).
Whenever there is a 'copy text' to the clipboard ,
this code opens up Window_1 :
Code: Select all
If OpenFile(0,cliplogname$,#PB_File_Append |#PB_Ascii)
LogThisString$ = (dttime$ + " " + "NoTopic: " + clipstring$)
SaveClipText$ = clipstring$ ; Wait til SelectTopic Window_1 clicks then use SaveClipText$
If showTopicsCkBoxState
HideWindow(Window_1, #False) ; show Window_1
SetActiveWindow(Window_1)
SetWindowPos_(WindowID(Windomw_1),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE) ; Make Window_1 OnTop
Else
WriteStringN(0,(LogThisString$), #PB_Ascii) ; no showTopicsCkBox checked
EndIf ; If showTopicsCkBoxState
CloseFile(0)
EndIf ;If OpenFile(0,cliplogname$
The StringGadget (NewTopic) shows the cursur blinking ,
But the Window_1 does not have the Focus .
How can I force Window_1 to have the Focus ?
If I manually click Window_1 , all works as intended .
I need Window_1 to show Focus , so user doesn't have to click it first .
Code: Select all
Repeat code :
If WindowID = Window_1
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1 To MaxBtnCount
TopicBtn_clicked()
Case NewTopic
Select EventType()
Case #PB_EventType_Focus
SetActiveWindow(Window_1)
AddKeyboardShortcut(Window_1, #PB_Shortcut_Return, 1)
Debug "Case #PB_EventType_Focus"
Case #PB_EventType_LostFocus
RemoveKeyboardShortcut(Window_1, #PB_Shortcut_Return)
EndSelect ; Select EventType()
Case EditListBtn
RunProgram("TopicsBtnList.txt")
EndSelect ; Select EventGadget()
Case #PB_Event_Menu
; MessageRequester("Select EventMenu()","Select EventMenu()= "+Str(EventMenu()))
Select EventMenu()
Case 1
SelectedTopicText$ = GetGadgetText(NewTopic)
; MessageRequester("NewTopicText$ = ",SelectedTopicText$ )
SetActiveGadget(NewTopic)
LogSelectedTopic()
EndSelect ; Select EventMenu()
Case #PB_Event_CloseWindow
CloseWindow(Window_0)
CloseWindow(Window_1)
EndSelect ; Select Event
EndIf ; WindowID = #Window_0
ForEver ; OpenWindow_0()
End