PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: windowsx.bi and CWindow  (Read 310 times)

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
windowsx.bi and CWindow
« on: August 05, 2017, 09:38:22 AM »

Hi Jose,

As you know, the windowsx.bi file that ships with the FB compiler is not a very good translation. You include that file in your AfxCtl.inc file. Would you consider changing that behaviour to include the much better windowsxx.bi attached and include it as part of your CWindow package distribution? It would make it much easier when I update my CWindow files each time make a release candidate.

'#include once "win/windowsx.bi"
#include once "Afx/windowsxx.bi"

No problem if you don't think it is a good idea.

Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • Josť Roca Software
Re: windowsx.bi and CWindow
« Reply #1 on: August 05, 2017, 11:07:33 AM »

IMO having two files with incompatible contents is a recipe for disaster. What if somebody that uses your modified file also includes, directly or indirectly, the original one?

What I can do is to add an AfxWindowsX.inc file that includes windowsx.bi and adds the modified macros, but with AFX_ added to its names.

These seems to be the macros that you have changed (don't know if the list is complete):

Code: [Select]
' It already exists an AfxSetWindowFont function
#Define SetWindowFont(HWnd, _hfont, fRedraw) FORWARD_WM_SETFONT((HWnd), (_hfont), (fRedraw), SNDMSG)
#Define DeletePen(_hpen) DeleteObject(Cast(HGDIOBJ, Cast(HPEN, (_hpen))))
#Define SelectPen(hdc, _hpen) Cast(HPEN, SelectObject((hdc), Cast(HGDIOBJ, Cast(HPEN, (_hpen)))))
#Define DeleteRgn(_hrgn) DeleteObject(Cast(HGDIOBJ, Cast(HRGN, (_hrgn))))
#Define DeleteFont(_hfont) DeleteObject(Cast(HGDIOBJ, Cast(HFONT, (_hfont))))
#Define SelectFont(hdc, _hfont) Cast(HFONT, SelectObject((hdc), Cast(HGDIOBJ, Cast(HFONT, (_hfont)))))
#Define Static_SetIcon(hwndCtl, _hIcon) Cast(HICON, Cast(UINT_PTR, SNDMSG((hwndCtl), STM_SETICON, Cast(WPARAM, Cast(HICON, (_hIcon))), Cast(LPARAM, 0))))
#Define Static_GetIcon(hwndCtl, _hIcon) Cast(HICON, Cast(UINT_PTR, SNDMSG((hwndCtl), STM_GETICON, Cast(WPARAM, 0), Cast(LPARAM, 0))))

#Define HANDLE_MSG(HWnd,message,fn) Case message: Return HANDLE_##message(HWnd,wParam,lParam,fn)
#Define HANDLE_WM_COMPACTING(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)))
#Define HANDLE_WM_WININICHANGE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(LPCTSTR, (lParam)))
#Define HANDLE_WM_SYSCOLORCHANGE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_PALETTEISCHANGING(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_PALETTECHANGED(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_FONTCHANGE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_SPOOLERSTATUS(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), CLng(CShort(Loword(lParam))))
#Define HANDLE_WM_DEVMODECHANGE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(LPCTSTR, (lParam)))
#Define HANDLE_WM_TIMECHANGE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_POWER(HWnd, wParam, lParam, fn) fn((HWnd), CLng(wParam))
#Define HANDLE_WM_ENDSESSION(HWnd, wParam, lParam, fn) fn((HWnd), Cast(WINBOOL, (wParam)))
#Define HANDLE_WM_QUIT(HWnd, wParam, lParam, fn) fn((HWnd), CLng(wParam))
#Define HANDLE_WM_DESTROY(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_NCDESTROY(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_SHOWWINDOW(HWnd, wParam, lParam, fn) fn((HWnd), Cast(WINBOOL, (wParam)), Cast(UINT, (lParam)))
#Define HANDLE_WM_SETREDRAW(HWnd, wParam, lParam, fn) fn((HWnd), Cast(WINBOOL, (wParam)))
#Define HANDLE_WM_ENABLE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(WINBOOL, (wParam)))
#Define HANDLE_WM_SETTEXT(HWnd, wParam, lParam, fn) fn((HWnd), Cast(LPCTSTR, (lParam)))
#Define HANDLE_WM_WINDOWPOSCHANGED(HWnd, wParam, lParam, fn) fn((HWnd), Cast(Const LPWINDOWPOS, (lParam)))
#Define HANDLE_WM_MOVE(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))))
#Define HANDLE_WM_SIZE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))))
#Define HANDLE_WM_CLOSE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_GETMINMAXINFO(HWnd, wParam, lParam, fn) fn((HWnd), Cast(LPMINMAXINFO, (lParam)))
#Define HANDLE_WM_PAINT(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_NCPAINT(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HRGN, (wParam)))
#Define HANDLE_WM_DROPFILES(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HDROP, (wParam)))
#Define HANDLE_WM_ACTIVATE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, Loword(wParam)), Cast(HWnd, (lParam)), Cast(WINBOOL, Hiword(wParam)))
#Define HANDLE_WM_ACTIVATEAPP(HWnd, wParam, lParam, fn) fn((HWnd), Cast(WINBOOL, (wParam)), Cast(DWORD, (lParam)))
#Define HANDLE_WM_SETFOCUS(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_KILLFOCUS(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_KEYDOWN(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), CTRUE, CLng(CShort(Loword(lParam))), Cast(UINT, Hiword(lParam)))
#Define HANDLE_WM_KEYUP(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), False, CLng(CShort(Loword(lParam))), Cast(UINT, Hiword(lParam)))
#Define HANDLE_WM_CHAR(HWnd, wParam, lParam, fn) fn((HWnd), Cast(TCHAR, (wParam)), CLng(CShort(Loword(lParam))))
#Define HANDLE_WM_DEADCHAR(HWnd, wParam, lParam, fn) fn((HWnd), Cast(TCHAR, (wParam)), CLng(CShort(Loword(lParam))))
#Define HANDLE_WM_SYSKEYDOWN(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), CTRUE, CLng(CShort(Loword(lParam))), Cast(UINT, Hiword(lParam)))
#Define HANDLE_WM_SYSKEYUP(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), False, CLng(CShort(Loword(lParam))), Cast(UINT, Hiword(lParam)))
#Define HANDLE_WM_SYSCHAR(HWnd, wParam, lParam, fn) fn((HWnd), Cast(TCHAR, (wParam)), CLng(CShort(Loword(lParam))))
#Define HANDLE_WM_SYSDEADCHAR(HWnd, wParam, lParam, fn) fn((HWnd), Cast(TCHAR, (wParam)), CLng(CShort(Loword(lParam))))
#Define HANDLE_WM_MOUSEMOVE(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_LBUTTONDOWN(HWnd, wParam, lParam, fn) fn((HWnd), False, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_LBUTTONDBLCLK(HWnd, wParam, lParam, fn) fn((HWnd), CTRUE, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_LBUTTONUP(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_RBUTTONDOWN(HWnd, wParam, lParam, fn) fn((HWnd), False, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_RBUTTONDBLCLK(HWnd, wParam, lParam, fn) fn((HWnd), CTRUE, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_RBUTTONUP(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_MBUTTONDOWN(HWnd, wParam, lParam, fn) fn((HWnd), False, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_MBUTTONDBLCLK(HWnd, wParam, lParam, fn) fn((HWnd), CTRUE, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_MBUTTONUP(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_MOUSEWHEEL(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), CLng(CShort(Hiword(wParam))), Cast(UINT, CShort(Loword(wParam))))
#Define HANDLE_WM_NCMOUSEMOVE(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCLBUTTONDOWN(HWnd, wParam, lParam, fn) fn((HWnd), False, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCLBUTTONDBLCLK(HWnd, wParam, lParam, fn) fn((HWnd), CTRUE, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCLBUTTONUP(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCRBUTTONDOWN(HWnd, wParam, lParam, fn) fn((HWnd), False, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCRBUTTONDBLCLK(HWnd, wParam, lParam, fn) fn((HWnd), CTRUE, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCRBUTTONUP(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCMBUTTONDOWN(HWnd, wParam, lParam, fn) fn((HWnd), False, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCMBUTTONDBLCLK(HWnd, wParam, lParam, fn) fn((HWnd), CTRUE, CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_NCMBUTTONUP(HWnd, wParam, lParam, fn) fn((HWnd), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))), Cast(UINT, (wParam)))
#Define HANDLE_WM_CANCELMODE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_TIMER(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)))
#Define HANDLE_WM_INITMENU(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HMENU, (wParam)))
#Define HANDLE_WM_INITMENUPOPUP(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HMENU, (wParam)), Cast(UINT, Loword(lParam)), Cast(WINBOOL, Hiword(lParam)))
#Define HANDLE_WM_MENUSELECT(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HMENU, (lParam)), Iif(Hiword(wParam) And MF_POPUP, 0, CLng(Loword(wParam))), Iif(Hiword(wParam) And MF_POPUP, GetSubMenu(Cast(HMENU, lParam), Loword(wParam)), Cast(HMENU, 0)), Cast(UINT, Iif(CShort(Hiword(wParam)) = (-1), &hFFFFFFFF, Hiword(wParam))))
#Define HANDLE_WM_COMMAND(HWnd, wParam, lParam, fn) fn((HWnd), CLng(Loword(wParam)), Cast(HWnd, (lParam)), Cast(UINT, Hiword(wParam)))
#Define HANDLE_WM_HSCROLL(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (lParam)), Cast(UINT, Loword(wParam)), CLng(CShort(Hiword(wParam))))
#Define HANDLE_WM_VSCROLL(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (lParam)), Cast(UINT, Loword(wParam)), CLng(CShort(Hiword(wParam))))
#Define HANDLE_WM_CUT(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_COPY(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_PASTE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_CLEAR(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_UNDO(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_RENDERALLFORMATS(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_DESTROYCLIPBOARD(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_DRAWCLIPBOARD(HWnd, wParam, lParam, fn) fn(HWnd)
#Define FORWARD_WM_SIZECLIPBOARD(HWnd, hwndCBViewer, lprc, fn) fn((HWnd), WM_SIZECLIPBOARD, Cast(WPARAM, Cast(HWnd, (hwndCBViewer))), Cast(LPARAM, Cast(LPRECT, (lprc))))
#Define HANDLE_WM_VSCROLLCLIPBOARD(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)), Cast(UINT, Loword(lParam)), CLng(CShort(Hiword(lParam))))
#Define HANDLE_WM_HSCROLLCLIPBOARD(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)), Cast(UINT, Loword(lParam)), CLng(CShort(Hiword(lParam))))
#Define HANDLE_WM_ASKCBFORMATNAME(HWnd, wParam, lParam, fn) fn((HWnd), CLng(wParam), Cast(LPTSTR, (lParam)))
#Define HANDLE_WM_CHANGECBCHAIN(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)), Cast(HWnd, (lParam)))
#Define HANDLE_WM_SYSCOMMAND(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), CLng(CShort(Loword(lParam))), CLng(CShort(Hiword(lParam))))
#Define HANDLE_WM_MDIDESTROY(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_MDIACTIVATE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(WINBOOL, -(lParam = Cast(LPARAM, HWnd))), Cast(HWnd, (lParam)), Cast(HWnd, (wParam)))
#Define HANDLE_WM_MDIRESTORE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_MDIMAXIMIZE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)))
#Define HANDLE_WM_MDIICONARRANGE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_CHILDACTIVATE(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_PARENTNOTIFY(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, Loword(wParam)), Cast(HWnd, (lParam)), Cast(UINT, Hiword(wParam)))
#Define HANDLE_WM_ENTERIDLE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), Cast(HWnd, (lParam)))
#Define HANDLE_WM_SETFONT(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HFONT, (wParam)), Cast(WINBOOL, (lParam)))
#Define FORWARD_WM_SETFONT(HWnd, _hfont, fRedraw, fn) fn((HWnd), WM_SETFONT, Cast(WPARAM, Cast(HFONT, (_hfont))), Cast(LPARAM, Cast(WINBOOL, (fRedraw))))
#Define HANDLE_WM_DRAWITEM(HWnd, wParam, lParam, fn) fn((HWnd), cptr(Const DRAWITEMSTRUCT Ptr, (lParam)))
#Define HANDLE_WM_MEASUREITEM(HWnd, wParam, lParam, fn) fn((HWnd), cptr(MEASUREITEMSTRUCT Ptr, (lParam)))
#Define HANDLE_WM_DELETEITEM(HWnd, wParam, lParam, fn) fn((HWnd), cptr(Const DELETEITEMSTRUCT Ptr, (lParam)))
#Define HANDLE_WM_QUEUESYNC(HWnd, wParam, lParam, fn) fn(HWnd)
#Define HANDLE_WM_COMMNOTIFY(HWnd, wParam, lParam, fn) fn((HWnd), CLng(wParam), Cast(UINT, Loword(lParam)))
#Define HANDLE_WM_DISPLAYCHANGE(HWnd, wParam, lParam, fn) fn((HWnd), Cast(UINT, (wParam)), Cast(UINT, Loword(lParam)), Cast(UINT, Hiword(wParam)))
#Define HANDLE_WM_CONTEXTMENU(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)), Cast(UINT, Loword(lParam)), Cast(UINT, Hiword(lParam)))
#Define HANDLE_WM_COPYDATA(HWnd, wParam, lParam, fn) fn((HWnd), Cast(HWnd, (wParam)), Cast(PCOPYDATASTRUCT, lParam))
#Define HANDLE_WM_HOTKEY(HWnd, wParam, lParam, fn) fn((HWnd), CLng(wParam), Cast(UINT, Loword(lParam)), Cast(UINT, Hiword(lParam)))

' I don't notice a difference with the original one
#Macro HANDLE_WM_PAINTCLIPBOARD(HWnd, wParam, lParam, fn)
   scope
      fn((hwnd), cast(HWND, (wParam)), cast(const LPPAINTSTRUCT, GlobalLock(cast(HGLOBAL, (lParam)))))
      GlobalUnlock(cast(HGLOBAL, (lParam)))
      cast(LRESULT, 0)
   end scope
#endmacro

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • Josť Roca Software
Re: windowsx.bi and CWindow
« Reply #2 on: August 05, 2017, 11:18:57 AM »

Of course, the only good solution is that the FB developers will modify windowsx.bi and made it available to download.

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • Josť Roca Software
Re: windowsx.bi and CWindow
« Reply #3 on: August 05, 2017, 11:28:57 AM »

Since you already have modified it, they would only need to make it available and post a message saying that the old one should we replaced with the new.

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: windowsx.bi and CWindow
« Reply #4 on: August 05, 2017, 11:46:52 AM »

Thanks Jose, I had posted messages about the problems before but they have not been fixed yet:
http://www.freebasic.net/forum/viewtopic.php?f=6&t=24663
http://www.freebasic.net/forum/viewtopic.php?f=6&t=24674

I will go with your suggestion of simply telling users that if they want to compile the WinFBE source that they need to use my version of windowsx.bi rather than the original.

Thanks!
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2785
    • Josť Roca Software
Re: windowsx.bi and CWindow
« Reply #5 on: August 06, 2017, 11:45:05 AM »

I have posted a reminder. Let's see if we have luck.

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: windowsx.bi and CWindow
« Reply #6 on: August 06, 2017, 12:25:02 PM »

I noticed. St W said that he committed the file to the repository so hopefully it will make it into the next release unless of course someone runs another automated conversion of the Windows includes and it overwrites it.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor