Results 1 to 3 of 3

Thread: [RESOLVED] Maximising and laying out a common dialog box

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    2

    Resolved [RESOLVED] Maximising and laying out a common dialog box

    Im developing a in-house project for serial transfer of some text files,which are read by the connected machine into operating recipes.
    To make it easier for the operator, ive laid the front end out all nice so that they can use a touch screen panel.

    However, because i dont know any better, ive used the common dialog control for when they click on the "select recipe" button. A standard window opens up and they can then select the correct file.

    The window that opens up is too small, and the icons that show up are also too small for them to select the correct one by touching the screen.

    Ideally, i would like this window to open up maximised, and id like the files within it to open up as thumbnails. This would give our operators plenty of room to press the correct file for downloading into the machine, without fear of selecting the wrong one.
    I have figured out how to point the control to the correct directory
    commondialog1.initdir = "C:\*****"

    but i cant see the expected
    commondialog1.maximise
    or
    commondialog1.arrangeicons = thumbs
    (i know these dont exist, but just to give you the idea of what i want to do)

    Everyone i have spoken to says that the common dialog control is too limited for this, and that i would be best to make up my own recipe select form where i could have total control of layout and font size etc.

    Before i do this, (and i dont have clue where to start, so it will take me a while) i thought i would post a thread here, to see if anyone out there had seen or heard of a way of maximising the common diaglog box, and laying the icons as thumbnails

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Maximising and laying out a common dialog box

    there are ways to manipulate the commondialog, i found this http://www.vbaccelerator.com/codelib/cmdlgd/cmdlgct.htm with google, there will be many others,

    you can look at this to open with thumbnails, but will help if you can read german, http://www.kpries.de/index.htm?Entwi...filedialog.htm
    also see this example at vbnet http://vbnet.mvps.org/index.html?cod...hooklvview.htm
    Last edited by westconn1; Oct 20th, 2008 at 05:10 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    2

    Re: Maximising and laying out a common dialog box

    Thanks for the tips. found some well laid out code by changing my search string in google (was searching on "common dialog box thumbnail view", but changed to cmdlg thumbnail).
    ive posted it below in case it helps any other user out:
    This allows you to set a default view mode on the common dialog box



    Place a command button and a common dialog control on the form and insert the following code.
    ___

    Private Sub Command1_Click()
    SetDetailsView
    On Error Resume Next
    CommonDialog1.CancelError = True
    CommonDialog1.ShowOpen
    If Err = cdlCancel Then Exit Sub
    MsgBox CommonDialog1.FileName
    End Sub
    ___

    The following code goes in a module.
    ___

    Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
    Private Declare Function GetActiveWindow Lib "user32" () As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Const WM_COMMAND = &H111&
    Const ID_DETAILS = 28716
    Dim TimerId As Long
    Sub SetDetailsView()
    TimerId = SetTimer(0, 0, 0, AddressOf TimerProc)
    End Sub
    Private Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
    hWnd = FindWindowEx(GetActiveWindow, 0, "SHELLDLL_DefView", vbNullString)
    SendMessage hWnd, WM_COMMAND, ID_DETAILS, ByVal 0&
    KillTimer 0, TimerId
    End Sub



    You may also like to try other views by chaning the wParam argument in the SendMessage function call.
    ___

    Const ID_VIEW_ICONS = 28713
    Const ID_VIEW_SMALLICONS = 28714 '98 only
    Const ID_VIEW_LIST = 28715
    Const ID_VIEW_DETAILS = 28716
    Const ID_VIEW_THUMBNAIL = 28717 'xp only
    Const ID_VIEW_TILES = 28718 'xp only
    ...
    SendMessage hWnd, WM_COMMAND, ID_VIEW_XXX, ByVal 0&



    this works a treat - thanks to hypetia for the code example.now i just have to figure out how to maximise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width