PlanetSquires Forums

Support Forums => WinFBE - Code Editor and Visual Designer => Topic started by: Paul Squires on August 18, 2017, 04:30:21 PM

Title: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires 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
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca 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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires 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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires 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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca 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.


   ' // 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).
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires 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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires 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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 18, 2017, 09:29:10 PM
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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca 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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca 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.

Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca 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.

Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 18, 2017, 09:47:19 PM
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)

Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca 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).


   ' // 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:
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires on August 18, 2017, 10:02:53 PM
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.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 18, 2017, 10:08:08 PM
Yes, it is visible again.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires on August 18, 2017, 10:08:17 PM
Yes, maybe I should switch over to the XPButton. Here are the things that I would need it to do:

- Be flat with no edges (or gradient)
- Allow me to draw a blue box around the edges to indicate a selected state (eg. the Match Case button).
- Allow hot tracking so when the mouse is over the button then the background color will change.
- Allow tooltips of course.

Also, a button control may look out of place in this situation because the pressing animation when the button is pressed down may not look right. Not sure.



Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires on August 18, 2017, 10:13:22 PM
Maybe I just need to steal the drawing code from the xp button to see if I am doing anything wrong that could help the sharpness of the image.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 18, 2017, 10:41:37 PM
> - Be flat with no edges (or gradient)

This can be achieved using the BS_FLAT style and disabling theming:


DIM pXpButton1 AS CXpButton = CXpButton(@pWindow, IDC_BUTTON1, "", 50, 20, 26, 26, _
       WS_VISIBLE OR WS_TABSTOP OR BS_PUSHBUTTON OR BS_CENTER OR BS_VCENTER OR BS_FLAT)
pXpButton1.DisableTheming


> - Allow hot tracking so when the mouse is over the button then the background color will change.

You can set an hot image and the control will do hot tracking.

> - Allow tooltips of course.

No problem.

> - Allow me to draw a blue box around the edges to indicate a selected state (eg. the Match Case button).
> Also, a button control may look out of place in this situation because the pressing animation when the button is pressed down may not look right. Not sure.

This will require some changes in the drawing code. Maybe setting a new flag.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 18, 2017, 11:03:22 PM
Anyway, although the replace icon looks sharp, the case.ico does not, but this is because the original icon image is very poor.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 18, 2017, 11:18:50 PM
The attached icons must look better.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: José Roca on August 19, 2017, 02:38:49 AM
Hi Paul,

See if changing


   ' Combobox to switch amongst the different build options
   ' Get the last button's rect and position the combobox immediately the right
'   HWND_FRMMAIN_COMBOBUILDS = _
'   pWindow->AddControl("COMBOBOX", hToolBar, IDC_FRMMAIN_COMBOBUILDS, "", _
'        pWindow->UnScaleX(rc.right) + 10, iif(pWindow->DPI = 96, 8, 2), 200, 20, _
'        WS_CHILD OR WS_VISIBLE OR WS_VSCROLL OR WS_BORDER OR WS_TABSTOP OR CBS_DROPDOWNLIST OR CBS_HASSTRINGS, _
'        WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR)
   HWND_FRMMAIN_COMBOBUILDS = _
   pWindow->AddControl("COMBOBOX", hToolBar, IDC_FRMMAIN_COMBOBUILDS, "", _
        pWindow->UnScaleX(rc.right + 10), pWindow->UnScaleX(10), 200, 20, _
        WS_CHILD OR WS_VISIBLE OR WS_VSCROLL OR WS_BORDER OR WS_TABSTOP OR CBS_DROPDOWNLIST OR CBS_HASSTRINGS, _
        WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR)


looks right at 96 DPI.

iif(pWindow->DPI = 96, 8, 2) is not correct because the value must be the same. What happens is that you must be trying it simulating 144 DPI with pWindow->DPI = 144, but that trick is not perfect because the window caption and the menu aren't scaled.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires on August 19, 2017, 10:30:54 AM
Thanks Jose, I made the change but I have used 8 instead of 10 because it seems to centre better in the toolbar. I also corrected a scaling error with the toolbar itself. I was using parenthesis around the scaling ratio calculation.

From:
   Dim cx As Long = 24 * (pWindow->DPI \ 96)

To:
   Dim cx As Long = 24 * pWindow->DPI \ 96


   ' Combobox to switch amongst the different build options
   HWND_FRMMAIN_COMBOBUILDS = _
   pWindow->AddControl("COMBOBOX", hToolBar, IDC_FRMMAIN_COMBOBUILDS, "", _
        pWindow->UnScaleX(rc.right + 10), pWindow->UnScaleY(8), 200, 20, _
        WS_CHILD OR WS_VISIBLE OR WS_VSCROLL OR WS_BORDER OR WS_TABSTOP OR CBS_DROPDOWNLIST OR CBS_HASSTRINGS, _
        WS_EX_LEFT Or WS_EX_LTRREADING Or WS_EX_RIGHTSCROLLBAR)


I have uploaded the new EXE's to GitHub.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires on August 22, 2017, 04:21:34 PM
Working on the visual designer portion of WinFBE now.
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Richard Kelly on August 22, 2017, 07:58:07 PM
I have small project in mind to test the designer out.

Rick
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Paul Squires on August 22, 2017, 08:01:02 PM
...does it involve SQLite :)
Title: Re: WinFBE 1.4.4 on GitHub (August 18, 2017)
Post by: Richard Kelly on August 23, 2017, 08:55:58 AM
Quote from: TechSupport on August 22, 2017, 08:01:02 PM
...does it involve SQLite :)

SQLite will be part of two efforts. One is to put a GUI on my calendaring class.

Rick