• Welcome to PlanetSquires Forums.
 

WinFBE 1.4.4 on GitHub (August 18, 2017)

Started by Paul Squires, August 18, 2017, 04:30:21 PM

Previous topic - Next topic

Paul Squires

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
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

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

Paul Squires

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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

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


   ' // 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).

Paul Squires

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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#7
You can try using an XPButton.


' ########################################################################################
' Microsoft Windows
' File: CW_XpButton.fbtpl
' Contents: CWindow XpButton example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2016 Jose 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.

José Roca

#8
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.

José Roca

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


José Roca

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


José Roca

#11
For a button without text, use:


   ' // 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:


      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)


José Roca

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).


   ' // 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

Quote from: Jose Roca on August 18, 2017, 09:44:29 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.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca