PlanetSquires Forums

Please login or register.

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

Author Topic: CWindow RC 13  (Read 9882 times)

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
CWindow RC 13
« on: July 15, 2016, 01:07:45 AM »

We are very close to the first official version.

Some changes that may affect to your code:

All the classes share the same namespace name, "Afx", so remove the Afx.CwindowClass, etc., that we have been using, an use only

USING Afx

The CBSTR.inc file has been renamed as CWSTR.inc.

All the procedures that did return a CBSTR have been modified to return the faster CWSTR.

CBSTR strings and CWSTR strings work very well together: you can assign a CBSTR to a CWSTR, and viceversa, as well as concatenate them with the + or & operators, append with the += or &= operators, also combining them with FB strings, wstrings and literals. Most FB operators and string functions, like MID, TRIM, etc., work with them. Notable exceptions are LEFT, RIGHT and VAL, that don't generate intermediate temporary strings and don't call the operators of the classes. They can still be used if you use double indirection (**).

You can use VARPTR or @ to pass the CWSTR or CBSTR variable to a function that expects to be passed by reference, but use the right one: CWSTR for out WSTRING parameters and CBSTR for out BSTR parameters. The equivalent to STRPTR is *cbs and *cws, although you can also use STRPTR(**cbs) and STRPTR(**cbs), but it is more compilcated. A double * dereferences the string data, e.g. **cbs, **cws.

A very useful feature is that both data types are dynamic. Therefore you don't have to specify its size in advance, unlike ZSTRING and WSTRING. No more problems to write functions that return an unicode string.

I also have adapted the templates for the winFBE editor.

Hope it all goes well despite the number 13 :)
« Last Edit: July 15, 2016, 03:27:18 PM by Jose Roca »
Logged

Johan Klassen

  • Junior Member
  • **
  • Posts: 107
  • FF3 User
Re: CWindow RC 13
« Reply #1 on: July 15, 2016, 03:19:36 PM »

thank you  :)
Logged

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #2 on: July 16, 2016, 06:08:01 AM »

For those that haven't followed previous discussions, be aware that you must use RETURN instead of FUNCTION = to return a CWSTR or a CBSTR type as the result of a function. FUNCTION = calls the destructor of the returned type before calling the constructor of the temporary copy to be returned, making it impossible to make a copy. While returning a CBSTR succeeds in most cases because, by default, Windows caches BSTR strings, if done with CWSTR it will crash.

This is a serious bug that invalidates FUNCTION = to return user defined types that have a constructor.

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #3 on: July 16, 2016, 08:36:44 AM »

AfxTime. inc.

An include file with many functions to deal with dates.
« Last Edit: July 16, 2016, 10:23:41 AM by Jose Roca »
Logged

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
Re: CWindow RC 13
« Reply #4 on: July 16, 2016, 09:10:39 AM »

Jose,

  This fails:
Code: [Select]
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'afxtime tests
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#include once "Afx/AfxTime.inc"
Dim As Word w1 = AfxLocalDay()
? w1
sleep

with

fbc  -s console "C:\FbRadAsm\Fb64\Examples\jcf\afxtime01.bas"
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(121) error 58: Illegal specification, at parameter 4 (ppTInfo) in 'GetTypeInfo as function(byval This as IXMLDOMImplementation ptr, byval iTInfo as UINT, byval lcid as LCID, byval ppTInfo as ITypeInfo ptr ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(122) error 58: Illegal specification, at parameter 6 (rgDispId) in 'GetIDsOfNames as function(byval This as IXMLDOMImplementation ptr, byval riid as const IID const ptr, byval rgszNames as LPOLESTR ptr, byval cNames as UINT, byval lcid as LCID, byval rgDispId as DISPID ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(123) error 58: Illegal specification, at parameter 2 (dispIdMember) in 'Invoke as function(byval This as IXMLDOMImplementation ptr, byval dispIdMember as DISPID, byval riid as const IID const ptr, byval lcid as LCID, byval wFlags as WORD, byval pDispParams as DISPPARAMS ptr, byval pVarResult as VARIANT ptr, byval pExcepInfo as EXCEPINFO ptr, byval puArgErr as UINT ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(154) error 58: Illegal specification, at parameter 4 (ppTInfo) in 'GetTypeInfo as function(byval This as IXMLDOMNode ptr, byval iTInfo as UINT, byval lcid as LCID, byval ppTInfo as ITypeInfo ptr ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(155) error 58: Illegal specification, at parameter 6 (rgDispId) in 'GetIDsOfNames as function(byval This as IXMLDOMNode ptr, byval riid as const IID const ptr, byval rgszNames as LPOLESTR ptr, byval cNames as UINT, byval lcid as LCID, byval rgDispId as DISPID ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(156) error 58: Illegal specification, at parameter 2 (dispIdMember) in 'Invoke as function(byval This as IXMLDOMNode ptr, byval dispIdMember as DISPID, byval riid as const IID const ptr, byval lcid as LCID, byval wFlags as WORD, byval pDispParams as DISPPARAMS ptr, byval pVarResult as VARIANT ptr, byval pExcepInfo as EXCEPINFO ptr, byval puArgErr as UINT ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(159) error 70: Incomplete type, before ')' in 'put_nodeValue as function(byval This as IXMLDOMNode ptr, byval value as VARIANT) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(168) error 70: Incomplete type, before ',' in 'insertBefore as function(byval This as IXMLDOMNode ptr, byval newChild as IXMLDOMNode ptr, byval refChild as VARIANT, byval outNewChild as IXMLDOMNode ptr ptr) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(181) error 70: Incomplete type, before ')' in 'put_nodeTypedValue as function(byval This as IXMLDOMNode ptr, byval typedValue as VARIANT) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(192) error 70: Incomplete type, before ')' in 'transformNodeToObject as function(byval This as IXMLDOMNode ptr, byval stylesheet as IXMLDOMNode ptr, byval outputObject as VARIANT) as HRESULT'
C:\FreeBASIC-1.05.0-win64\inc\win\msxml.bi(192) error 132: Too many errors, exiting


Logged

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #5 on: July 16, 2016, 09:30:08 AM »

Sorry, it was missing "using Afx". I have reuploaded the file.

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
Re: CWindow RC 13
« Reply #6 on: July 16, 2016, 09:49:26 AM »

Jose,
  A number of warnings now with the new upload.
James


fbc  -s console "C:\FbRadAsm\Fb64\Examples\jcf\afxtime01.bas"
C:\FreeBASIC-1.05.0-win64\inc\Afx\AfxTime.inc(723) warning 3(1): Passing different pointer types, at parameter 4 of VARBSTRFROMDATE()
C:\FreeBASIC-1.05.0-win64\inc\Afx\AfxTime.inc(733) warning 3(1): Passing different pointer types, at parameter 4 of VARBSTRFROMDATE()
C:\FreeBASIC-1.05.0-win64\inc\Afx\AfxTime.inc(743) warning 3(1): Passing different pointer types, at parameter 4 of VARBSTRFROMDATE()
C:\FbRadAsm\Fb64\Examples\jcf\afxtime01.c: In function 'AFXWEEKONE':
C:\FbRadAsm\Fb64\Examples\jcf\afxtime01.c:1193:32: warning: 'NFIRSTDAY$1' is used uninitialized in this function [-Wuninitialized]
  NFIRSTDAY$1 = (int32)(int64)-((int64)NFIRSTDAY$1 == ((int64)vr$2 + -1ll));
                                ^

Make done.
Logged

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #7 on: July 16, 2016, 10:24:22 AM »

I'm not getting these errors. You must be using different compiler switches.
New file uploaded.

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
Re: CWindow RC 13
« Reply #8 on: July 16, 2016, 11:18:43 AM »

I'm not getting these errors. You must be using different compiler switches.
New file uploaded.

fbc  -s console "C:\FbRadAsm\Fb64\Examples\jcf\afxtime01.bas"

New file seems to be fine on a quick retest.

James
Logged

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
Re: CWindow RC 13
« Reply #9 on: July 16, 2016, 03:02:26 PM »

Jose,
  How do you center the IFileOpenDialog if the hwndOwner is the Desktop?

James
 
Logged

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #10 on: July 16, 2016, 03:49:18 PM »

You can try to find the handle of the dialog and use MoveWindow or SetWindowPos.

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #11 on: July 17, 2016, 08:18:59 AM »

AfxPrinter.inc

Some useful printer procedures.
« Last Edit: July 17, 2016, 09:19:26 AM by Jose Roca »
Logged

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #12 on: July 17, 2016, 08:37:08 AM »

AfxNls.inc - National language support functions

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3282
Re: CWindow RC 13
« Reply #13 on: July 17, 2016, 09:21:41 AM »

Renamed the old AfxEnumPrinterPorts as AfxEnumLocalPrinterPorts and added a new AfxEnumPrinterPorts function that can also enumerate ports available for printing in the specified server.

New file reuploaded in the original post.

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: CWindow RC 13
« Reply #14 on: July 17, 2016, 09:49:40 AM »

Problems with AfxStrPathName. Jose, there were a couple of problems with the routine so I fixed them and include the modified source below:

1)  PATH did not return the trailing "\".
2)  NAME would return a blank string if the incoming file string did not have a path. In PB, a filename without a path will return the filename.
3)  NAMEX. Same problem as NAME.

Code: [Select]
Private Function AfxStrPathName (ByRef wszOption As WString, ByRef wszFileSpec As WString) As CWSTR
   Dim cws As CWSTR = ""
   If Len(wszFileSpec) = 0 Then Return cws
   Select Case Ucase(wszOption)
      Case "PATH"
         ' // Returns the path portion of file spec
         Dim nPos As Long = InstrRev(wszFileSpec, Any ":/\")
         If nPos Then cws = Mid(wszFileSpec, 1, nPos)
         Return cws
      Case "NAME"
         ' // Retrieve the full filename
         cws = wszFileSpec
         Dim nPos As Long = InstrRev(wszFileSpec, Any ":/\")
         If nPos Then cws = Mid(wszFileSpec, nPos + 1)
         ' // Retrieve the filename
         nPos = InstrRev(cws, ".")
         If nPos Then cws = Mid(cws, 1, nPos - 1)
         Return cws
      Case "NAMEX"
         ' // Retrieve the name and extension combined
         Dim nPos As Long = InStrRev(wszFileSpec, Any ":/\")
         If nPos Then cws = Mid(wszFileSpec, nPos + 1) Else cws = wszFileSpec
         Return cws
      Case "EXTN"
         ' // Retrieve the name and extension combined
         Dim nPos As Long = InstrRev(wszFileSpec, Any ":/\")
         If nPos Then cws = Mid(wszFileSpec, nPos + 1) Else cws = wszFileSpec
         ' // Retrieve the extension
         nPos = InStrRev(cws, ".")
         If nPos Then cws = Mid(cws, nPos) Else cws = ""
         Return cws
   End Select
End Function

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer
Pages: [1] 2 3 4