KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

OpenFileDialog() does not appear (KF 3.2.14)

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Joe66
KiXforms Dabbler
KiXforms Dabbler


Joined: 25 Oct 2007
Posts: 7
Location: Kassel, Germany

PostPosted: Mon Apr 21, 2008 1:53 pm    Post subject: OpenFileDialog() does not appear (KF 3.2.14) Reply with quote

I have a problem with the OpenFileDialog, which does not appear.
I start each script, which contains forms, with

*** begin ***
Break On
$System = CreateObject("Kixforms.System")
If Not $System
$nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
*** end ***

Now in my special case I define this form:

*** begin ***
; Form1
$Form1 = $System.Form()
$Form1.FormBorderStyle=2
$Form1.Left = 0
$Form1.Size = $System.Size(692,505) ;(Width,Height)
$Form1.Tag = 1
$Form1.Text = "my form"
$Form1.Top = 0

$Form1.OpenFileDialog = CreateObject("Kixtart.System.OpenFileDialog()")
$Form1.OpenFileDialog.InitialDirectory = "C:\"
$Form1.OpenFileDialog.Filter = "All files (*.*)|*.*|Script files (*.kix,*.k2k)|*.kix;*.k2k|Text files (*.txt)|*.txt"
$Form1.OpenFileDialog.FilterIndex = 1
$Form1.OpenFileDialog.RestoreDirectory = 1
*** end ***

and somewhere in my form I have a button. This button has to open this "OpenFileDialog()".
if this dialog was finished properly, the value of this dialog will be written in a textbox.

*** begin ***
Function SearchForFile()
$Form1.OpenFileDialog.InitialDirectory = "C:\"
PLAY FILE "Ding.wav"
$x = $Form1.OpenFileDialog.ShowDialog()

If $x <> $System.DialogResult.Cancel
$TextBox4.Text = $Form1.OpenFileDialog.Filename
EndIf
EndFunction
*** end ***

the line, starting with "PLAY" is only for debug purpose.
the script is running until this line "PLAY FILE...", the OpenFileDialog is not coming up.

I have kixforms.NET version 3.2.14 in use.

Can anyone help me? Thanks in advance!
Back to top
View user's profile Send private message Send e-mail
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Mon Apr 21, 2008 6:06 pm    Post subject: Reply with quote

Hi Joe66,

Here's how OpenFileDialog works in KF.NET.

Code:

$System = CreateObject("Kixforms.System")

$openFileDialog = $System.OpenFileDialog()
;$openFileDialog.filter = "DLL (*.dll)|*.dll"
$openFileDialog.DefaultExt = ".dll"
$openFileDialog.Title = "Select DLL"

$frm = $System.Form()
$frm.Size = $System.Size(200, 100)
$frm.StartPosition = $System.FormStartPosition_CenterScreen

$btn = $frm.Controls.Add($System.Button())
$btn.Size = $System.Size(100, 20)
$btn.Location = $System.Point(45, 25)
$btn.Text = "Browse"
$btn.Click = 'btn_Click()'

$frm.Show
While $frm.Visible
   $=Execute($System.Application.DoEvents)
Loop

Function btn_Click()
   $openFileDialog.FileName = ""
   
   $openFileDialog.InitialDirectory = "C:\"
   $ = $openFileDialog.ShowDialog()
   If $ <> 2
      ? $openFileDialog.FileName
   EndIf
EndFunction
Back to top
View user's profile Send private message
Joe66
KiXforms Dabbler
KiXforms Dabbler


Joined: 25 Oct 2007
Posts: 7
Location: Kassel, Germany

PostPosted: Tue Apr 22, 2008 7:17 am    Post subject: Reply with quote

Hi Pearly,

thank you for reply!
When I modified my script with my names (i.e. "$Form1.OpenFileDialog...") it did not work.
The dialog was still missing, but the result (empty string) was written in my textbox.

Then I copied and pasted your naming convention "$openFileDialog" and "$ = $openFileDialog.ShowDialog()" and now it works.
Is there anything wrong in using "$x" than "$"?

And: where can I find out more about the naming convention, how to use KF.NET commands and methods?
The helpfile does not contain many examples, maybe in a future version this would be possible?
Back to top
View user's profile Send private message Send e-mail
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Tue Apr 22, 2008 5:01 pm    Post subject: Reply with quote

In .NET, the OpenFileDialog (OFD) is independent of the Form. You were assigning an OFD control as a child to the form. The code I posted above is just creating the OFD control and showing it when needed.

You can use $x instead of $. It does not matter. It's not really the naming convention per se, but the difference between creating a control as a child and creating it independent of the parent.

If there aren't any examples in the KF.NET chm help file, try searching this forum. I get most of my information from here. If not, feel free to ask Wink
Back to top
View user's profile Send private message
Joe66
KiXforms Dabbler
KiXforms Dabbler


Joined: 25 Oct 2007
Posts: 7
Location: Kassel, Germany

PostPosted: Wed Apr 23, 2008 6:35 am    Post subject: Reply with quote

Pearly,
I often search this forum, have a look at the UDFs and so on. I wrote a lot of scripts for WMI issues but now I want to use more forms (interaction). So I started not with conventional KF but with KF.NET -> and there some things are different.
As an example I found KIX2EXE_GUI, which uses a lot of elements. But I am a little bit surprised, because it starts with

$System = CreateObject("Kixtart.System")
(not KiXforms) ...... but it works.

Thank you for help!
Back to top
View user's profile Send private message Send e-mail
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Thu May 01, 2008 10:50 am    Post subject: Reply with quote

Hey Joe, </reminiscence>
KiXtart.System is an object first introduced to kf.Classic which is the preferred way to start a forms script these days,
The System object, among others, has those neat methods like .Form or .Math with which you can build on ....

It seem to be upward compatible with kf.Net, funny. I should really start to work with kf.net someday. If only the laggy first initialization was fixed Sad

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Thu May 01, 2008 5:49 pm    Post subject: Reply with quote

I think the lag you're talking about is the .NET framework. I see what you're saying, but it's really not that bad Wink
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Thu May 01, 2008 8:37 pm    Post subject: Reply with quote

Oh well, maybe I should retry with the current framework distribution... It has been a while since I tried the last time Wink
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group