Code:
Case %WM_NCActivate Static hWndSaveFocus As Dword If IsFalse Cb.WParam Then ' Save control focus hWndSaveFocus = GetFocus() ElseIf hWndSaveFocus Then ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 End If
Case %WM_NCActivate Static hWndSaveFocus As Dword If IsFalse Cb.WParam Then ' Save control focus hWndSaveFocus = GetFocus() ElseIf hWndSaveFocus Then ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 End If
#Compile Exe #Dim All %WM_Command = &H111 %EN_SetFocus = &H100 %ES_Left = &H0& %ES_AutoHScroll = &H80& %WS_Ex_ClientEdge = &H00000200 Declare Function MessageBox Lib "USER32.DLL" Alias "MessageBoxA" (ByVal hWnd As Dword, lpText As Asciiz, lpCaption As Asciiz, ByVal dwType As Dword) As Long CallBack Function DlgProc Select Case CbMsg Case %WM_Command Select Case CbCtl Case 100 If CbCtlMsg = %EN_SetFocus Then Control Set Focus CbHndl, 1 '<--- Set focus away from control BEFORE Opening Child Dialog/Window MessageBox CbHndl, "%EN_SetFocus msg recievd", " ", 0 End If Case 1, 2 Dialog End CbHndl, 0 End Select End Select End Function Function PBMain () As Long Local hDlg As Long Dialog New 0, "Test %EN_SetFocus Response",,,200, 60 To hDlg Control Add TextBox, hDlg, 100, "Click Here", 10, 10, 180, 12, %ES_AutoHScroll Or %ES_Left, %WS_Ex_ClientEdge ' NOT A TAB STOP Control Add Button, hDlg, 1, "Cancel", 20, 30, 50, 20 Control Add Button, hDlg, 2, "Ok", 130, 30, 50, 20 Dialog Show Modal hDlg, Call DlgProc End Function
#Compile Exe #Dim All %WM_Command = &H111 %EN_SetFocus = &H100 %ES_Left = &H0& %ES_Center = &H1& %ES_Right = &H2& %ES_MultiLine = &H4& %ES_Uppercase = &H8& %ES_Lowercase = &H10& %ES_Password = &H20& %ES_AutoVScroll = &H40& %ES_AutoHScroll = &H80& %ES_NoHideSel = &H100& %ES_OEMConvert = &H400& %ES_ReadOnly = &H800& %ES_WantReturn = &H1000& %ES_Number = &H2000& %WS_Ex_ClientEdge = &H00000200 CallBack Function DlgProc Static x As Dword Select Case CbMsg Case %WM_Command Select Case CbCtl Case 100 If CbCtlMsg = %EN_SetFocus Then If x < 10 Then ? "%EN_SetFocus msg recievd" Incr x End If Case 1, 2 Dialog End CbHndl, 0 End Select End Select End Function Function PBMain () As Long Local hDlg As Long Dialog New 0, "Test %EN_SetFocus Response",,,200, 60 To hDlg Control Add TextBox, hDlg, 100, "Click Here", 10, 10, 180, 12, %ES_AutoHScroll Or %ES_Left, %WS_Ex_ClientEdge ' NOT A TAB STOP Control Add Button, hDlg, 1, "Cancel", 20, 30, 50, 20 Control Add Button, hDlg, 2, "Ok", 130, 30, 50, 20 Dialog Show Modal hDlg, Call DlgProc End Function
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: