PlanetSquires Forums

Please login or register.

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

Author Topic: WinFBE 1.4.4 on GitHub (August 18, 2017)  (Read 514 times)

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
WinFBE 1.4.4 on GitHub (August 18, 2017)
« on: August 18, 2017, 04:30:21 PM »

Version 1.4.4 (August 18, 2017)
- Added: Determining if "Run Executable" file exists now checks for any defined "-x" compiler switch.
- Added: User Tool paths for Command and Working Folder will adjust drive letter to current drive should specified location be invalid. This allows you to run the tool on systems where the assigned drive letter may change (eg. when using a portable hard drive).
- Changed: Converted Find/Replace icons to PNG format and better optimized the Find/Replace dialog for High DPI settings.
- Changed: Updated the German language file.

File releases can be found at:  https://github.com/PaulSquires/WinFBE/releases
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #1 on: August 18, 2017, 05:25:43 PM »

Seems like you haven't take into account the DPI scaling ratio. Also, the combobox its now misplaced.

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #2 on: August 18, 2017, 06:06:26 PM »

That's strange. I swear I thought that I had it all positioned correctly and scaled correctly when I set WinFBE to use 144 dpi. I will look at this again and change the actual Windows system setting to be sure.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #3 on: August 18, 2017, 07:57:34 PM »

Ok, the images don't look too bad (at least versus the old icons that I used to use). The images are 16x16 PNG.

Here is a question: I am loading the PNG's using your GDI routines however I am not scaling them. How do I do that using the GDI routines? I will start looking for an answer (maybe it's easy) but I figured I'd ask in case you know quickly.

pData->hImgNormal = AfxGdipIconFromRes(pWindow->InstanceHandle, wszImgNormal)

So, I can easily get the image (as a  PNG converted to an Icon) but now I should upscale it based on the dpi scaling.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #4 on: August 18, 2017, 08:11:02 PM »

Easy. You don't scale the icons, but the size of them when you create the image list.

Code: [Select]
   ' // Calculate the size of the icon according the DPI
   DIM cx AS LONG = 16 * pWindow.DPI \ 96

   ' // Create an image list for the toolbar
   DIM hImageList AS HIMAGELIST
   hImageList = ImageList_Create(cx, cx, ILC_COLOR32 OR ILC_MASK, 4, 0)
   IF hImageList THEN
      AfxGdipAddIconFromRes(hImageList, hInstance, "IDI_ARROW_LEFT")
      ...
   END IF

Instead of 16 you can use another value, e.g. 20, if you want them a little bigger (usually when used with toolbars). 4 is the number of icons (change it).
« Last Edit: August 18, 2017, 08:13:47 PM by Josť Roca »
Logged

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #5 on: August 18, 2017, 08:32:57 PM »

Thanks Jose, yes, I am using that technique for the Toolbar and it works perfectly. However, the images in the Find/Replace dialog are all individual custom control image buttons (frmHotImgBtn.inc). I am displaying the icon using the DrawState api in WM_PAINT.

I will see if I can modify the code to use an imagelist for each button and then use ImageList_Draw to draw the icon contained in the imagelist.

Also, I was able to correct the combobox positioning. I was not calculating the position of the last separator in the toolbar correctly.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #6 on: August 18, 2017, 09:27:06 PM »

I just re-uploaded new EXE's to GitHub. I will create a new release once I know things are okay.

I am not 100% happy with the scaling of the icons because they are somewhat blurry. This is because the 16x16 PNG's are essentially screenshot created icons from the VSCode editor application. They have a number of different shaded pixels in them that I should convert to pure black in order to make the image sharper looking.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #7 on: August 18, 2017, 09:29:10 PM »

You can try using an XPButton.

Code: [Select]
' ########################################################################################
' Microsoft Windows
' File: CW_XpButton.fbtpl
' Contents: CWindow XpButton example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2016 Josť Roca. Freeware. Use at your own risk.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################

#define UNICODE
#define _WIN32_WINNT &h0602
#INCLUDE ONCE "Afx/CWindow.inc"
#INCLUDE ONCE "Afx/CXpButton.inc"
#INCLUDE ONCE "Afx/AfxGdiPlus.inc"
USING Afx

CONST IDC_BUTTON1 = 1001
CONST IDC_BUTTON2 = 1002
CONST IDC_BUTTON3 = 1003

DECLARE FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                          BYVAL hPrevInstance AS HINSTANCE, _
                          BYVAL szCmdLine AS ZSTRING PTR, _
                          BYVAL nCmdShow AS LONG) AS LONG

   END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)

' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
                  BYVAL hPrevInstance AS HINSTANCE, _
                  BYVAL szCmdLine AS ZSTRING PTR, _
                  BYVAL nCmdShow AS LONG) AS LONG

   ' // Set process DPI aware
   AfxSetProcessDPIAware

   ' // Create the main window
   DIM pWindow AS CWindow
   pWindow.Create(NULL, "XpButton example", @WndProc)
   pWindow.SetClientSize(215, 90)
   pWindow.Center

   ' // Create the first button
   DIM pXpButton1 AS CXpButton = CXpButton(@pWindow, IDC_BUTTON1, "&Ok", 50, 20, 114, 26)
   pXpButton1.SetIcon AfxGdipIconFromFile(ExePath & $"\replace.ico"), XPBI_NORMAL
   ' // Calculate the size of the icon according the DPI
   DIM cx AS LONG = 16 * pWindow.DPI \ 96
   pXpButton1.SetImageSize(cx, cx)

   ' // Dispatch Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

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

' ========================================================================================
' Main window callback procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT

   SELECT CASE uMsg

      CASE WM_COMMAND
         SELECT CASE GET_WM_COMMAND_ID(wParam, lParam)
            CASE IDCANCEL
               ' // If ESC key pressed, close the application by sending an WM_CLOSE message
               IF GET_WM_COMMAND_CMD(wParam, lParam) = BN_CLICKED THEN
                  SendMessageW hwnd, WM_CLOSE, 0, 0
                  EXIT FUNCTION
               END IF
         END SELECT

    CASE WM_DESTROY
         ' // Ends the application by sending a WM_QUIT message
         PostQuitMessage(0)
         EXIT FUNCTION

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = DefWindowProcW(hWnd, uMsg, wParam, lParam)

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

Change AfxGdipIconFromFile to AfxGdipIconFromRes.
« Last Edit: August 18, 2017, 09:36:24 PM by Josť Roca »
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #8 on: August 18, 2017, 09:33:29 PM »

This is how it looks using your replace.ico. Looks sharp to me.

With this control, you don't need to convert the image to .png.
« Last Edit: August 18, 2017, 09:36:56 PM by Josť Roca »
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #9 on: August 18, 2017, 09:42:16 PM »

You must have changed the size of the compiler results window and the "x" button has become inaccessible.

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #10 on: August 18, 2017, 09:44:29 PM »

Sorry, not inaccessible, but is not visible. You can click it, but you can't see it.

« Last Edit: August 18, 2017, 10:05:01 PM by Josť Roca »
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #11 on: August 18, 2017, 09:47:19 PM »

For a button without text, use:

Code: [Select]
   ' // Create the first button
   DIM pXpButton1 AS CXpButton = CXpButton(@pWindow, IDC_BUTTON1, "", 50, 20, 26, 26)
   pXpButton1.SetIcon AfxGdipIconFromFile(ExePath & $"\replace.ico"), XPBI_NORMAL
   ' // Calculate the size of the icon according the DPI
   DIM cx AS LONG = 16 * pWindow.DPI \ 96
   pXpButton1.SetImageSize(cx, cx)

And, of course, you can change the default window styles. The constructor has optional parameters for them:

Code: [Select]
      DECLARE CONSTRUCTOR (BYVAL pWindow AS CWindow PTR, BYVAL cID AS INTEGER, BYREF wszTitle AS WSTRING = "", _
         BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, _
         BYVAL dwStyle AS DWORD = 0, BYVAL dwExStyle AS DWORD = 0, BYVAL lpParam AS LONG_PTR = 0)
« Last Edit: August 18, 2017, 09:49:30 PM by Josť Roca »
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #12 on: August 18, 2017, 10:02:38 PM »

You can also set an image for the disabled state (you can even reuse the original image passing the dim scale -in percent values- and passing the flag to convert it to gray as TRUE).

Code: [Select]
   ' // Create the first button
   DIM pXpButton1 AS CXpButton = CXpButton(@pWindow, IDC_BUTTON1, "", 50, 20, 26, 26)
   pXpButton1.SetIcon AfxGdipIconFromFile(ExePath & $"\replace.ico"), XPBI_NORMAL
   pXpButton1.SetIcon AfxGdipIconFromFile(ExePath & $"\replace.ico", 60, TRUE), XPBI_DISABLED
   ' // Calculate the size of the icon according the DPI
   DIM cx AS LONG = 16 * pWindow.DPI \ 96
   pXpButton1.SetImageSize(cx, cx)
   EnableWindow pXpButton1.hWindow, FALSE   ' Disable the button

When the button is disabled, it will look like this:

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #13 on: August 18, 2017, 10:02:53 PM »

Sorry, not inaccessible, nut is not visible. You can click it, but you can't see it.
Yes, that's true of the 1.4.4 release upload. I noticed that X was missing as was the X for the Explorer window. I fixed those when I uploaded the raw EXE's about 40 minutes ago. Just download the two EXE's from GitHub and see if they are okay.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
« Reply #14 on: August 18, 2017, 10:08:08 PM »

Yes, it is visible again.
Pages: [1] 2