I can't fix my InitDir when i try to load from the Open Dialog...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: I can't fix my InitDir when i try to load from the Open Dialog...

  1. #1
    Join Date
    Jan 2006
    Posts
    82

    I can't fix my InitDir when i try to load from the Open Dialog...

    Hi Guys,

    I suppose we are able to fix the initial directory where the Open Dialog will start when we try to load a doc.

    However, for my application I cant seem to fix it. This is what happens:

    When i clicked on the Load command button, the Open dialog opens up. Lets say my .InitDir = "C:\Saved Bad Images" and so the Open dialog starts from this particular "C" Drive and "Saved Bad Images" folder.

    After which I decided to load a file from another directory say "C:\Saved Good Images" and it manages to load it successfully.

    The problem comes:
    When i try to load another doc again by clicking the same Load command button, instead of starting from the .InitDir = "C:\Saved Bad Images", it starts from the last folder ("C:\Saved Good Images") where I have just successfully loaded my last doc. Why is this happening? is it because of my coding? or is it that i have to clear any buffer or whatsoever so that this does not happen?

    Guys, please help me with this...thanks a million in advance

    Regards,
    Justin

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    if you always have
    .InitDir = "C:\Saved Bad Images"
    before .ShowOpen in the Load button Click event, it should work fine... can you post the button Click code?
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Jan 2006
    Posts
    82
    The following are the fragments of my program codes. Think it shld be sufficient. Hope you can help me out with this mstraf. Thanks a million bro...


    Option Explicit
    Const ErrCancel = 32755



    Private Sub cmdLoadGB_Click()
    If txtCurrentStatus.Text = "Paused" Then
    LoadGoldenBoard
    ctlImageDevice1.ActiveScene = ctlImageDevice1.DisplayScene
    ctlImageDevice1.LoadImage dlgCommonDialog1.FileName
    Exit Sub
    End If
    End Sub



    Private Sub LoadGoldenBoard()
    On Error Resume Next
    With dlgCommonDialog1
    .DialogTitle = "Open"
    .InitDir = "C:\Saved GoldenBoard Images\"
    .Filter = _
    "Bitmap Files (*.bmp)|*.bmp|IR Images 8 Bits (*.img)|*.img|IR Images 16 Bits (*.img)|*.img|" & _
    "All Images (*.bmp;*.img)|*.bmp;*.img|All Files (*.*)|*.*"
    .ShowOpen
    End With

    If Err.Number = ErrCancel Then
    Exit Sub
    ElseIf Err.Number <> 0 Then
    MsgBox "Error " & Format$(Err.Number) & _
    " selecting file." & vbCrLf & _
    Err.Description
    Exit Sub
    End If
    On Error GoTo 0
    End Sub

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Just reset the Filename property before setting InitDir:

    .FileName = ""
    .InitDir = ...
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Jan 2006
    Posts
    82
    alrite mstraf.....it works!!!....thanks alot dude....

    btw is there any way u can help me out with my the other thread titled "How to convert a grayscale image to a pseudo colored image?" I have posted for quite a while now and no one seems to reply...

    thanks a million in advance bro...

  6. #6
    Join Date
    Oct 2005
    Location
    Staffordshire, England
    Posts
    101
    Quote Originally Posted by ootnitsuj
    Const ErrCancel = 32755
    You don't need to set a Const for pressing the Cancel button. There is already one in VB.

    cdlCancel

    Exit Sub
    ErrHandler:
    If Err <> cdlCancel Then
    MsgBox Err.Description
    End If
    I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

    Martin2k

  7. #7
    Join Date
    Dec 2005
    Location
    South of Nowhere, Maine
    Posts
    309
    Another nit picky item.

    If Err <> cdlCancel Then

    Should be:

    IF Err.Number <> cdlCancel Then

    Using default properties in VB Classic can get you in trouble.

  8. #8
    Join Date
    Jan 2006
    Posts
    82
    Quote Originally Posted by Keithuk
    You don't need to set a Const for pressing the Cancel button. There is already one in VB.

    cdlCancel

    Exit Sub
    ErrHandler:
    If Err <> cdlCancel Then
    MsgBox Err.Description
    End If

    Thanks for the advice bro...yah i have noticed it after i have posted these codes...thanks again...

Similar Threads

  1. open file common dialog box
    By Y2D in forum VB Classic
    Replies: 5
    Last Post: 01-03-2006, 05:52 AM
  2. Replies: 0
    Last Post: 01-24-2001, 09:55 AM
  3. Replies: 0
    Last Post: 01-24-2001, 09:55 AM
  4. Replies: 10
    Last Post: 01-23-2001, 07:52 AM
  5. Replies: 0
    Last Post: 01-19-2001, 04:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center