PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: FBWinSpy - Preliminary work  (Read 1227 times)

James Fuller

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 274
  • FF3 User
Re: FBWinSpy - Preliminary work
« Reply #15 on: June 10, 2017, 09:35:59 AM »

JosÚ,
  I have investigated this type of app previously and found not knowing the font name, size of the Window/Dialog/Control places them quite low on my must have utilities list.
Have you found (or created) an api that will give you this info?

James

Logged

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #16 on: June 10, 2017, 09:47:50 AM »

As the title of the thread says, it is a preliminary work. The code to retrieve and display information about the controls has not been yet implemented. I have posted it because I knew that Pierre would be interested. The others will have to wait.

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #17 on: June 10, 2017, 07:34:17 PM »

JosÚ,
  I have investigated this type of app previously and found not knowing the font name, size of the Window/Dialog/Control places them quite low on my must have utilities list.
Have you found (or created) an api that will give you this info?

James

To get the size of a window is a piece of cake.

Regarding the font, there is not guarantee that this info can be obtainable, except for Windows standard controls. I will display it if the info is retrievable.

This function retrieves the font. See Remaks.

Code: [Select]
' ========================================================================================
' Retrieves the font used by the specified window.
' Parameters:
' - hwnd = Handle to the window.
' - lplfw = Pointer to a LOGFONTW stucture.
' Return value:
'   If the function succeeds, and lplfw is a valid pointer, the return value is the number
'   of bytes stored into the buffer.
'   If the function succeeds, and lplfw is NULL, the return value is the number of bytes
'   required to hold the information the function would store into the buffer.
'   If the function fails, the return value is zero.
' Remarks:
'    WM_GETFONT works fine cross-process, provided that the window you're sending it to
'    responds to this message. This is only guaranteed for standard Windows controls. If the
'    standard Windows control is using the system font, it returns NULL.
'    The WM_GETFONT message does not return a font handle if the message is sent to a dialog
'    box created by the DialogBoxParam, DialogBoxIndirectParam, CreateDialogParam, or
'    CreateDialogIndirectParam function.
'    A window can use an arbitrary font for rendering, or even multiple fonts.
' ========================================================================================
FUNCTION FBWS_GetFont (BYVAL hwnd AS HWND, BYVAL lplfw AS LOGFONTW PTR) AS LONG
   IF IsWindow(hwnd) = FALSE THEN EXIT FUNCTION
   DIM hFont AS HFONT = CAST(HFONT, SendMessageW(hwnd, WM_GETFONT, 0, 0))
   IF hFont = 0 THEN EXIT FUNCTION
   FUNCTION = GetObjectW(hFont, SIZEOF(LOGFONTW), lplfw)
END FUNCTION
' ========================================================================================

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #18 on: June 10, 2017, 11:59:03 PM »

Added information of the controls, including font name and point size if available.

Code reuploaded in the first post.

James Fuller

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 274
  • FF3 User
Re: FBWinSpy - Preliminary work
« Reply #19 on: June 11, 2017, 07:43:31 AM »

JosÚ,
  Thank you for the confirmation.
Now to be any use for DDT -> SDK (CWindow) you will need to add functionality to query the user for the font name and pont size for the Dialog and controls.
I had visions of doing this but lost interest.

James
Logged

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #20 on: June 11, 2017, 09:20:47 AM »

It already retrieves the font of the controls.

To retrieve the font used by the dialog, it's simply a matter of adding

Code: [Select]
   ' // Get the font, if available
   DIM lfw AS LOGFONTW
   IF FBWS_GetFont(hwndMain, @lfw) THEN
      TreeView_AddItem(hTreeView, __hMainWindowNode, NULL, "Font mame: " & lfw.lfFaceName)
      TreeView_AddItem(hTreeView, __hMainWindowNode, NULL, "Font point size: " & AfxGetFontPointSize(lfw.lfHeight))
   END IF

I have checked it and DDT dialogs respond to the WM_GETFONT message.

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #21 on: June 11, 2017, 09:26:50 AM »

BTW I don't have any interest in translating DDT code to SDK. I'm allergic to dialogs in general and to DDT in particular.

At most, we could translate the GUI, but what is going to do with this the typical DDTer, without  much knowledge of SDK code (Pierre is an exception), with the rest of DDT code?
« Last Edit: June 11, 2017, 09:31:51 AM by JosÚ Roca »
Logged

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #22 on: June 11, 2017, 02:52:04 PM »

Added menu information and other changes.

Code reuploaded in the first post.

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #23 on: June 12, 2017, 07:14:04 AM »

Added information about rebars and other changes.

Code reuploaded in the first post.

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #24 on: June 12, 2017, 10:33:00 AM »

Now it searches recursively if a child window or control (e.g. a tab control) has also children and displays full information.

Code reuploaded in the first post.

Pierre Bellisle

  • FireFly3 User
  • Junior FireFly Member
  • *
  • Posts: 57
Re: FBWinSpy - Preliminary work
« Reply #25 on: June 15, 2017, 11:24:02 PM »

Hey JosÚ,

On my machine, using Control-A in the "Code TAB" edit control will beep.
Also Control-E is assigned to "Ŕ" on my keyboard making the character to be inserted.
All seem's fine if I use the modified code, except that, of course, the code for "Ŕ" is not a valid solution

Is Control-E is standard for selection in Spanish? 

Pierre

Code: [Select]
' ========================================================================================
' Code text box window procedure
' ========================================================================================
FUNCTION FBWS_Edit_CodeView_WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

   SELECT CASE uMsg

#If 0 'Genuine JosÚ code
      CASE WM_KEYDOWN
         ' // If Ctrl+A or Ctrl+E pressed, select all the text
         IF wParam = VK_A OR wParam = VK_E THEN
            IF GetAsyncKeyState(VK_CONTROL) THEN
               PostMessage hwnd, EM_SETSEL, 0, -1
            END IF
         END IF

         ' // Eat the Escape key to avoid the page being destroyed
         IF wParam = VK_ESCAPE THEN EXIT FUNCTION

#Else 'Modified code
      CASE WM_CHAR
        SELECT CASE wParam
          CASE 1, 232 '1 = Control-A, 232 = Ŕ 
            'Using WM_CHAR/1 instead of WM_KEYDOWN/VK_A will not beep
            'On my keyboard Control-e give "Ŕ". So it add "Ŕ" to the text before selection
            SendMessage(hWnd, EM_SETSEL, 0, - 1) 'Select everything
            EXIT FUNCTION
        END SELECT

      CASE WM_KEYDOWN
         IF wParam = VK_ESCAPE THEN EXIT FUNCTION     
#EndIf

      CASE WM_DESTROY
         ' // REQUIRED: Remove control subclassing
         SetWindowLongPtrW hwnd, GWLP_WNDPROC, CAST(LONG_PTR, RemovePropW(hwnd, "OLDWNDPROC"))

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = CallWindowProcW(GetPropW(hwnd, "OLDWNDPROC"), hwnd, uMsg, wParam, lParam)

END FUNCTION
' ========================================================================================

« Last Edit: June 15, 2017, 11:29:39 PM by Pierre Bellisle »
Logged

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #26 on: June 16, 2017, 01:58:25 AM »

As I normally have my speaker off because of these annoying web pages with sound, I didn't have noticed the beep :)

Maybe better to use only

Code: [Select]
      CASE WM_CHAR
         SELECT CASE wParam
            CASE 1   ' // Ctrl+A
               SendMessage(hWnd, EM_SETSEL, 0, - 1) 'Select everything
               EXIT FUNCTION
         END SELECT

Otherwise, we can't use Ŕ.

> Is Control-E is standard for selection in Spanish?

Explorer and Notepad use it.
« Last Edit: June 16, 2017, 02:48:01 PM by JosÚ Roca »
Logged

Pierre Bellisle

  • FireFly3 User
  • Junior FireFly Member
  • *
  • Posts: 57
Re: FBWinSpy - Preliminary work
« Reply #27 on: June 16, 2017, 03:25:35 PM »

Hey,

The "Ŕ" is certainly no big deal for me, I might be the only one having it cause I got my own layout using MS-Keyboard-Layout-Creator.
It's not a french keyboard standard asignment, still other may have the letter "e" inserted with a beep.

This is interesting stuff, one more thing to take care about... :-) Comparison of shortcuts in English and Spanish

Pierre
Logged

JosÚ Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • JosÚ Roca Software
Re: FBWinSpy - Preliminary work
« Reply #28 on: June 16, 2017, 03:42:10 PM »

These differences came because they try to choose a shortcut that is easier to remember according the language of the user.

For example:

Ctrl+F (for English "Find"), Ctrl+B (for Spanish "Buscar")
Ctrl+O (for English "Open"), Ctrl+A (for Spanish "Abrir")
Ctrl+E (for English "All"), Ctrl+E (could have been Ctrl+T, for Spanish "Todo", but Ctrl+T is already used for "Tama˝o", i.e. "Size")
Ctrl+U (for English "Underline"), Ctrl+S (for Spanish "Subrayado")
etc.

In Notepad, using the Spanish Windows version, to do a "Find" you have to use Ctrl+B (not Ctrl+F) and to select all Ctrl+E (not Ctrl-A).

Pages: 1 [2]