Author Topic: OpenFileDialog  (Read 25724 times)

0 Members and 4 Guests are viewing this topic.

Aurel

  • Guest
Re: OpenFileDialog
« Reply #30 on: April 23, 2012, 08:52:55 AM »
Thanks Charles... ;)
As you can see controls like bstring as type of string which is show properly.
What is bstring2  ???
I also try extract strings from line with GetLine subroutine with FOR loop but seems that
not work, infact crush  :-\ ( old friend - DrWatson jump like crazy  ;D )

Aurel

  • Guest
Re: OpenFileDialog
« Reply #31 on: April 23, 2012, 10:08:06 AM »
Hi ...
I get it to work defining Space(255).
Here is testing subroutine.On the end of subrotine is comment.
I think that speed is very good...cca 7 second,file long 12560 lines of text... :)
Code: [Select]
SUB GetLine
INT Lpos
INT LLen
bstring LText=""
string pText

FOR Lpos = 0 TO LCount-1
LLen = SendMessage richedit1, EM_LINELENGTH,Lpos, 0 ' not important
'print "LineLen;" + str(LLen)
pText = Space (255)  ' it use 255 without error
SendMessage richedit1,EM_GETLINE,Lpos,*pText
'print "LineText;" + pText
'convert to bstring & show line in edit control
LText = pText
SendMessage edit1,WM_SETTEXT,0,LText
UpdateWindow(edit1)
Next

'test - load file
'with 12560 lines of text
'read line by line ,finished
'cca 7 seconds

END SUB

Charles Pegge

  • Guest
Re: OpenFileDialog
« Reply #32 on: April 23, 2012, 01:33:53 PM »

I still have a problem with strptr in one of my test programs. It is not quite there yet. But low level access to string pointers will remain.

Charles

Aurel

  • Guest
Re: OpenFileDialog
« Reply #33 on: April 23, 2012, 01:41:34 PM »
Hi Charles ...
Just take your time , will be... ;)
Yes you right sometimes this work around strings & pointers , huh is tuff :-\

And yea, i just compare speed of Oxygen with(with same load) :
PureBasic - cca 13 seconds
Emergence Basic - cca 10 seconds

So o2 is faster ... ;)
And looks to me that work far smooth then PB,EB.
I mean in first place to updating edit control each time is content changed ...cool

Aurel

  • Guest
Re: OpenFileDialog
« Reply #34 on: April 30, 2012, 01:42:37 AM »
Just a small addition to filter creation.
Quote
sep=chr(0)
filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep

On this way first visible filter is Text files *.txt .
 ;)

Charles Pegge

  • Guest
Re: OpenFileDialog
« Reply #35 on: May 01, 2012, 02:00:43 AM »
Good idea!

This my latest effort, with a cleaned-up header. I've included it in the latest Oxygen in examples/GUI/.

Code: [Select]


'no case sensitivity

% OFN_READONLY                 0x00000001
% OFN_OVERWRITEPROMPT          0x00000002
% OFN_HIDEREADONLY             0x00000004
% OFN_NOCHANGEDIR              0x00000008
% OFN_SHOWHELP                 0x00000010
% OFN_ENABLEHOOK               0x00000020
% OFN_ENABLETEMPLATE           0x00000040
% OFN_ENABLETEMPLATEHANDLE     0x00000080
% OFN_NOVALIDATE               0x00000100
% OFN_ALLOWMULTISELECT         0x00000200
% OFN_EXTENSIONDIFFERENT       0x00000400
% OFN_PATHMUSTEXIST            0x00000800
% OFN_FILEMUSTEXIST            0x00001000
% OFN_CREATEPROMPT             0x00002000
% OFN_SHAREAWARE               0x00004000
% OFN_NOREADONLYRETURN         0x00008000
% OFN_NOTESTFILECREATE         0x00010000
% OFN_NONETWORKBUTTON          0x00020000
% OFN_NOLONGNAMES              0x00040000     '// force no long names for 4.x modules
% OFN_EXPLORER                 0x00080000     '// new look commdlg
% OFN_NODEREFERENCELINKS       0x00100000
% OFN_LONGNAMES                0x00200000     '// force long names for 3.x modules
% OFN_ENABLEINCLUDENOTIFY      0x00400000     '// send include message to callback
% OFN_ENABLESIZING             0x00800000
% OFN_DONTADDTORECENT          0x02000000
% OFN_FORCESHOWHIDDEN          0x10000000     '// Show All files including System and hidden files


type OPENFILENAMEA
  DWORD  lStructSize
  SYS    hwndOwner
  SYS    hInstance
  CHAR*  lpstrFilter
  CHAR*  lpstrCustomFilter
  DWORD  nMaxCustFilter
  DWORD  nFilterIndex
  CHAR*  lpstrFile
  DWORD  nMaxFile
  CHAR*  lpstrFileTitle
  DWORD  nMaxFileTitle
  CHAR*  lpstrInitialDir
  CHAR*  lpstrTitle
  DWORD  Flags
  WORD   nFileOffset
  WORD   nFileExtension
  CHAR*  lpstrDefExt
  LONG   lCustData
  SYS    lpfnHook
  CHAR*  lpTemplateName
end type

typedef OPENFILENAMEA OPENFILENAME

Declare GetModuleHandle      lib "kernel32.dll" alias "GetModuleHandleA" (optional char*n) as sys
Declare GetOpenFileName      Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OPENFILENAME*opfn) As sys
Declare CommDlgExtendedError Lib "comdlg32.dll" () as dword


'FileDialog( $ iDir , $ filter ,$ title , % parent , flag )


Function FileDialog(string iDir, filter, Title, sys Hwnd, Flags) As String
'==================

def FileNameLen 256

OPENFILENAME ofn
char         filename[FileNameLen]
int          retval

 ofn.lStructSize       = sizeof(OPENFILENAME)
 ofn.hwndOwner         = hWnd
 ofn.hInstance         = GetModuleHandle
 ofn.lpstrFilter       = filter
 ofn.lpstrCustomFilter = null
 ofn.nMaxCustFilter    = 0
 ofn.nFilterIndex      = 1
 ofn.lpstrFile         = FileName 'coupling to char buffer
 ofn.nMaxFile          = FileNameLen
 ofn.lpstrFileTitle    = null
 ofn.nMaxFileTitle     = 0
 ofn.lpstrInitialDir   = idir
 ofn.lpstrTitle        = title
 ofn.Flags             = flags
 ofn.nFileOffset       = 0
 ofn.nFileExtension    = 0
 ofn.lpstrDefExt       = null
 ofn.lCustData         = 0
 ofn.lpfnHook          = 0
 ofn.lpTemplateName    = null


sys retval = GetOpenFileName(ofn)
'
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms646916(v=vs.85).aspx
'if retval=0 then print "Dialog Error " CommDlgExtendedError
return filename

'#recordof FileDialog

'
End Function

'dir="C:\cevp\projects\opcode\OxygenBasic\examples\GUI"

sys    hwnd
string dir=""
string sep=chr(0)
string filter=
  "all files"+sep+"*.*"+sep+
  "text"+sep+"*.txt"+sep+
  "basic"+sep+"*.bas;*.o2bas"+sep+
  "include"+sep+"*.inc"+sep+
  "header"+sep+"*.h"+sep+
  sep

string title = "Test File Opening Dialog"
sys    flags = OFN_EXPLORER or OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY
string fi   = FileDialog(dir,filter,title,hwnd,flags)

if fi then print fi

Aurel

  • Guest
Re: OpenFileDialog
« Reply #36 on: May 01, 2012, 08:57:46 AM »
Thanks Charles...
Do i can ask you something ?
This is just suggestion...
Do you can put somwhere here on forum one board or topic in
which we can found latest (bugfixed or improved) oxygen.dll & latest gxo2.exe.
I think that this will be remove any confusion and conflicts with headers for GUI
or anthing else .
I have for example one version of o2h on disk C and one on disk D.
And sometimes i have made mess up which is which.

i hope that i don't ask to much.
« Last Edit: May 01, 2012, 01:03:39 PM by Aurel »

Charles Pegge

  • Guest
Re: OpenFileDialog
« Reply #37 on: May 01, 2012, 12:55:18 PM »

Hi Aurel,

All the major release go onto the Website downloads page, then onto SourceForge. I'm currently checking the latest with thinBasic examples. When all is well, I will release it as A039.

Unfortunately backwards-compatibility is not assured with these Alpha releases, so the examples from earlier versions may lose compatibility. But I do my best to avoid breakages.

For instance null should no longer be defined in headers.

Charles

Aurel

  • Guest
Re: OpenFileDialog
« Reply #38 on: May 01, 2012, 12:59:03 PM »
Ok.
Yes i see that null is not in header,which is ok for me ;)
I think that i will wait for 039... :)

Aurel

  • Guest
Re: OpenFileDialog
« Reply #39 on: June 27, 2014, 02:52:40 PM »
Charles...
what a heck is now wrong with FileDialog function and with last oxygen dll  >:(
string pointers are not properly detected?

Charles Pegge

  • Guest
Re: OpenFileDialog
« Reply #40 on: June 28, 2014, 04:07:02 AM »
I don't see any file dialog problems, Aurel. Could you please demo.

Aurel

  • Guest
Re: OpenFileDialog
« Reply #41 on: June 28, 2014, 05:19:15 AM »
Charles
I think that main problem is in FileDialog function connected with string pointers.
When you do some internal changes in core dll then this function not work properly .
So what to use now?

Code: [Select]
Function FileDialog(char Dir, filter , Title , sys Hwnd, Flags, defext) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
INT retval

ofn.lStructSize = 76
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = ?filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = @filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = ?dir
ofn.lpstrTitle = title
IF Flags = 0 then ofn.Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
IF Flags = 1 then ofn.Flags = OFN_EXPLORER Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = @defext
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL

' Execute the dialog box
IF Flags = 0 then retval = GetOpenFileName(ofn)
IF Flags = 1 then retval = GetSaveFileName(ofn)

Return filename

End Function

and here is structure...

Code: [Select]
Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As sys
    lpstrCustomFilter As sys
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As sys
    nMaxFile As Long
    lpstrFileTitle As sys
    nMaxFileTitle As Long
    lpstrInitialDir As sys
    lpstrTitle As sys
    flags As Long
    nFileOffset As word
    nFileExtension As word
    lpstrDefExt As sys
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As sys
End Type

problematic parts are:
ofn.lpstrFilter = ?filter
ofn.lpstrFile = @filename  ' the most critical member
ofn.lpstrInitialDir = ?dir
ofn.lpstrDefExt = ?defext

Charles Pegge

  • Guest
Re: OpenFileDialog
« Reply #42 on: June 28, 2014, 06:23:34 AM »
The Defext param should be a string, not sys.

We picked this up before, do you must be working with an older version.

from awinh.inc

Code: [Select]
'FileDialog( $ iDir , $ filter ,$ title , % parent ,% flag )
Function FileDialog(String Dir, filter , Title , long Hwnd, Flags, string defext) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
INT retval

ofn.lStructSize = 76
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = strptr filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = strptr filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = strptr dir
ofn.lpstrTitle = strptr title
IF Flags = 0 then ofn.Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
IF Flags = 1 then ofn.Flags = OFN_EXPLORER Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = strptr defext
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL

' Execute the dialog box
IF Flags = 0 then retval = GetOpenFileName(ofn)
IF Flags = 1 then retval = GetSaveFileName(ofn)

Return filename

Aurel

  • Guest
Re: OpenFileDialog
« Reply #43 on: June 28, 2014, 08:20:43 AM »
No Charles
I use latest awinh so defext must be string ....and i really don't know how then
work like sys with old oxygen dll ...looks like a mistery...ok
i will try new version. ;)

Aurel

  • Guest
Re: OpenFileDialog
« Reply #44 on: June 28, 2014, 09:04:04 AM »
sorry Charles but someting is wrong ..I look again into include for EBasic

Code: [Select]
TYPE OPENFILENAME
DEF lStructSize AS INT
DEF hwndOwner AS INT
DEF hInstance AS INT
DEF lpstrFilter AS POINTER
DEF lpstrCustomFilter AS POINTER
DEF nMaxCustFilter AS INT
DEF nFilterIndex AS INT
DEF lpstrFile AS POINTER
DEF nMaxFile AS INT
DEF lpstrFileTitle AS POINTER
DEF nMaxFileTitle AS INT
DEF lpstrInitialDir AS POINTER
DEF lpstrTitle AS POINTER
DEF flags AS INT
DEF nFileOffset AS WORD
DEF nFileExtension AS WORD
DEF lpstrDefExt AS POINTER
DEF lCustData AS INT
DEF lpfnHook AS INT
DEF lpTemplateName AS POINTER
ENDTYPE

and we have in oxygen this:
Code: [Select]
Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As string
    lpstrCustomFilter As string
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As string
    nMaxFile As Long
    lpstrFileTitle As string
    nMaxFileTitle As Long
    lpstrInitialDir As string
    lpstrTitle As string
    flags As Long
    nFileOffset As word
    nFileExtension As word
    lpstrDefExt As string
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As string
End Type

i will add in attachment awinh and AsciEdit so you can try and see what a heck is wrong  ::)
« Last Edit: June 28, 2014, 02:25:01 PM by Aurel »