en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en en en ga en en ja de en en en en en nl en en en en en ja en en en en en en en nl en en ga en en en fr en da en en en en en en en nl en en en ga en en en en ja en en en en en en en nl en en fa en en en en en en en en en en ja en en en en en en en nl en en en en en en en en fr en da en en en en en en en nl vi en en en en en en ja en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Programming only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Interesting Issue with %EN_SETFOCUS msg between PBWin8 & PBWin9
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
I have been working on some code that was originally written a long time ago in PBDLL version 6, and it has always ported to the newer compilers without any problem. Recently I compiled using PBWin 9.01 and have noticed something odd happening with the %EN_SetFocus message. I am using this message on a textbox control that is not a tabstop. Whenever a user clicks on the field one would expect to be able to process the %EN_SetFocus message. This is working, but I am getting 2 messages in the queue when compile with PBWin 9.01 rather than the 1 that I have always gotten in the past.
Below is a fully working piece of code to demonstrate what I am talking about. Compile this code with PBWin 8 and it works as expected. Compile with 9 and you get 2 messages instead of the expected 1.
compile the code and then click in the TextBox area. You should only get one message box for the code to be working as expected.
#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
Summit Computer Networks, Inc.
Join Date: Aug 1999
3 Aug 2009, 12:49 PM
Another interesting thing to note. This has to do with the dialog losing then regaining focus. If you switch out the ? statement with the API function MessageBox (will need the declare added) it will lock into an endless cycle of message boxes opening when the subsequent one is closed when compile with PBWin 9. That is the reason for the static variable x being in place to stop it after 10 times.
Summit Computer Networks, Inc.
Join Date: Aug 1998
3 Aug 2009, 01:12 PM
Send code to PB support?
Port Washington WI USA
Join Date: Aug 1999
3 Aug 2009, 01:22 PM
Originally posted by Michael Mattias View Post
Send code to PB support?
I am in the process of doing so. I just wanted to be sure that it wasn't my mistake first.
Summit Computer Networks, Inc.
Join Date: Aug 1999
3 Aug 2009, 05:24 PM
I guess this was a previously broken feature that I was taking advantage of that has now been fixed.
Version 9.01 is correctly setting the focus back to the last control that had focus after the messagebox is closed. This was a problem in previous versions, where DDT was not setting the focus back to the correct control after the dialog box lost focus.
So here is what I am doing in PBWin9. The code won't compile in 8 anyway because it is now using objects (the reason for to port to 9 in the first place)
#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
The above functions as expected in PBWin9, but it would have to have the text field clicked twice in prior versions of PB.
Last edited by Scott Slater; 3 Aug 2009, 05:45 PM. Reason: Found better solution
Summit Computer Networks, Inc.
Join Date: Aug 1998
3 Aug 2009, 06:45 PM
Version 9.01 is correctly setting the focus back to the last control that had focus after the messagebox is closed
"Correctly?" Is that a change in MSGBOX behavior or a change in DDT-generated code?
MSGBOX has never reset the focus anywhere as far as I can tell. I've always had to do that myself; and there is no "changes to existing statments and functions" for MSGBOX in the 9.0.1 help file. Or is that omission an error?
Port Washington WI USA
Join Date: Aug 1999
3 Aug 2009, 08:42 PM
My take on this is that DDT now performs this internally.
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
Summit Computer Networks, Inc.
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 04:26 AM.
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.