Announcement

Collapse
No announcement yet.

Newbie question - what control does what?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie question - what control does what?

    I decided this morning to make a little program, more to teach myself than for any other reason, that will have a little box that will list the various drives on my computer and hopefully on my home network and then, when I've picked a drive, show me the folders on that drive and let me navigate to some folder where I can view it's files. Probably eventually to select those files for some purpose.

    I keep coming up with ideas for little tools for myelf that would probably be simple to make if I knew how to do the above but I dismiss the ideas because I haven't learned how to do any of that. I never really looked closely at why I don't or just what I don't know.

    Today I started to do that and I ran right into the first problem: what control can best list the drives? What control for navigating folders? What control for listing the files?

    I looked at the various controls and it seems like maybe the combobox might be good for the drives, or maybe a listbox. Maybe the listview or maybe a treeview for the folder navigation and maybe a listbox or a listview or a combox or a multi-line edit box for the files.

    This isn't really a programming problem. I don't know enough about windows and it's controls. I use them all the time but I guess I don't think about them; I just use them.

    Can anyone either explain some of this to me or give me some links to some basic information about what controls do what and which is best for a given common function or at least for the functions I've listed above? I did a little googling and found all sorts of stuff but nothing that really seemed on point. it was about how to program it not about how to decide which controls to use.

    Thanks in advance for any links or tips.

    Barry

  • #2
    This thread - which I retrieved using the keywords "directory" and "treiview" BTW shows two approaches to doing the directory part of what you want. If you search for "network drive" you will probably find more!

    Comment


    • #3
      Originally posted by Chris Holbrook View Post
      This thread - which I retrieved using the keywords "directory" and "treiview" BTW shows two approaches to doing the directory part of what you want. If you search for "network drive" you will probably find more!
      Thanks for a valiant attempt but I think you left out the link to the thread.

      Barry

      Comment


      • #4
        If you have PbWin9.0 -> DISPLAY OPENFILE

        James

        Comment


        • #5
          I guess I could use display openfile but this is for learning and that won't teach me how to do it.

          Thanks,
          Barry

          Comment


          • #6
            Originally posted by Barry Marks View Post
            Thanks for a valiant attempt but I think you left out the link to the thread.

            Barry
            Do the search then - it comes out number 1.

            Comment


            • #7
              Barry,

              Two places on my site that should help you.

              Here's a summary page on all the controls. The top half of the page especially answers your question.

              http://www.garybeene.com/power/pb-tutor-controls.htm

              And I have a page dedicated to each control, showing several examples/variations on the controls, along with the code to generate them.

              http://www.garybeene.com/power

              Look down the left side of the page and you'll see the links for each control.

              These should help you out.

              Comment


              • #8
                Originally posted by Chris Holbrook View Post
                Do the search then - it comes out number 1.
                I found this thread:
                http://www.powerbasic.com/support/pb...ctory+treeview

                I guess that's the one you mean. It gives me some good sample code and discussion for what I want to do and that'll help get me going. Thanks.

                My question is really more general. I'm trying to get some understanding of what controls to use when. This problem was what made me realize that I don't really understand the controls and what to use when. This sample will get me started but I'd really like some more general information about the various controls and what they do and when to use them and when not to.

                Barry

                Comment


                • #9
                  On your comment about drives, here a short program that puts drive letters in a string.

                  Code:
                     #Compile Exe
                     #Dim All
                     #Include "win32api.inc"
                     Global hDlg As Dword
                     Function PBMain() As Long
                        Dialog New Pixels, 0, "Button Test",300,300,200,200, _
                                                        %WS_SysMenu, 0 To hDlg
                        Control Add Button, hDlg, 100,"Push", 50,50,100,20
                        Dialog Show Modal hDlg Call DlgProc
                     End Function
                  
                     CallBack Function DlgProc() As Long
                        If Cb.Msg = %WM_Command And Cb.Ctl = 100 And _
                                          Cb.CtlMsg = %BN_Clicked Then
                            Local sDrives As String
                            sDrives = String$(128,".")  'arbitrary length, content
                            GetLogicalDriveStrings 128, ByVal StrPtr(sDrives)
                            Replace Any $Nul With " " In sDrives
                            MsgBox sdrives
                       End If
                     End Function

                  Comment


                  • #10
                    Thanks. That'll also help.

                    Barry

                    Comment


                    • #11
                      Originally posted by Barry Marks View Post
                      This sample will get me started but I'd really like some more general information about the various controls and what they do and when to use them and when not to.
                      Barry, I strongly recommend trial and error, that way yours skills and knowledge will grow at the same time. My approach is to search the internet for a likely solution then look just at these forums and take the best as tutorial material. Others will take a textbook example (Petzold has a following) and follow that through. There are probably one or two wrong ways to do most things but there is often a choice of right ways too. Good luck.

                      Comment


                      • #12
                        Barry,

                        There are no 'rules' for what controls to use where. You can pretty much use any/all of them as you see fit. I tend to use the listview control quite a bit because I like its flexibility.

                        The best thing to do, IMO, is to look at the programs you use on a regular basis. Its not hard to see what controls were used to do various things. This will give you a good idea of how the controls are used in the "real world".

                        I'll often find that I use one way, a way I'm more comfortable with, then down the line change things a bit. I hardly ever used the Treeview control because of some issues the first time I tried playing with it. Then one day a customer asked for a change that the Treeview control was perfect for. Now that app uses the Treeview instead of the Listview.

                        I would simply suggest looking at how the apps you already own are designed and try do duplicate what you like, and improve what you don't.
                        Software makes Hardware Happen

                        Comment


                        • #13
                          There are no 'rules' for what controls to use where. You can pretty much use any/all of them as you see fit
                          To reinforce Joe's point... Just look at your own example application: a list of directories and files.

                          You have the "DISPLAY OPENFILE" intrinsic and a treeview version mentioned above.

                          I have to believe that somewhere here is a demo of a DlgDirList function, and I know there are examples of using the SHBrowseForFolder function (which will actually browse for a lot more than folders).

                          Plus there are demos in the Source code section for a multi-column listview with some bells and whistles (Listview: User-Friendly replacement for GetOpenFileName March 02, 2002), a simple display which handles Unicode file names (Directory List with Non-ASCII (Unicode) characters in file names 5-31-08) and an example of how to customize the Windows Standard "GetOpenFile" dialog (Explorer-Style hook Procedures for OpenFileDialog and SaveFileDialog 3-31-07)

                          I guess that means it's not even so much a "multiple choice" question as it is an "essay question."

                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Originally posted by Barry Marks View Post
                            ...
                            My question is really more general. I'm trying to get some understanding of what controls to use when. This problem was what made me realize that I don't really understand the controls and what to use when. This sample will get me started but I'd really like some more general information about the various controls and what they do and when to use them and when not to.

                            Barry
                            Reading the messages in this thread, I've noticed that Barry has had to ask his question in several different ways, and still hasn't gotten an answer that meets his need. As I understand the original question, he is looking for (if I were writing the documentation) something that says: what each control does, explains what it is best suited for (and why), what it should NOT be used for (and why), and perhaps even compares one control against another for a particular use in order to show why the one is more appropriate than the other, then ideally, would show some in actual use.

                            IOW, what Barry is trying to "DO" here is learn. He mentioned the directory program as one means of getting that knowledge. The directory program is NOT the thing that he is trying to do, it is only a means to that end, and any number of other "projects" could help him achieve his primary goal.

                            Yet the answers that have been posted seem to have focused on the directory program, or various ways it could be done, or code that has already done it, etc. (and even the finer points of some pretty technical details...)

                            While I have great respect and appreciation for everyone who posts here to help out a fellow programmer, it struck me how frustrated I was to not see anyone offer Barry what he really asked for, and it reminded me of the frustration I felt when I was first here learning.

                            So I felt compelled to raise this point, to bring some focus and awareness to what beginners mean when they say they have difficulties posting questions on the forums - the experienced folks have a completely different perspective, and it's really really hard for them to get "simple enough" to reach the newbie where he's at.

                            I applaud everyone for wanting to help the newbie get his program written, but I sympathize with the newbie for trying to get a grasp on his tools and materials first!!

                            Comment


                            • #15
                              Which case I would recommend reading up about the Windows Controls under User Interface Services, specifically the primary, err, click under the Individual Control Information category. Every one has an overview link you can select and basically read the control's, heh, bio.
                              Furcadia, an interesting online MMORPG in which you can create and program your own content.

                              Comment


                              • #16
                                Yet the answers that have been posted seem to have focused on the directory program, or various ways it could be done, or code that has already done it, etc. (and even the finer points of some pretty technical details...)

                                While I have great respect and appreciation for everyone who posts here to help out a fellow programmer, it struck me how frustrated I was to not see anyone offer Barry what he really asked for, and it reminded me of the frustration I felt when I was first here learning.
                                Are we reading the same post? It seems to me that there are plenty of references to Barry's question, some specific to the example he used, and other specific to the general nature of his question. My reply didn't mention the directory at all, as just ONE example, but Gary pointed him to a web reference discussing the exact questions he asked.

                                What more can one offer?
                                Last edited by Joe Byrne; 14 Feb 2009, 09:36 PM.
                                Software makes Hardware Happen

                                Comment


                                • #17
                                  I double ditto everything John said.

                                  Barry, here's an example to get you started on a Directory program:
                                  '
                                  Code:
                                  'PBWIN 9.00 - WinApi 05/2008 - XP Pro SP3
                                  #Compile Exe                                
                                  #Dim All 
                                  #Include "WIN32API.INC"
                                  #Include "COMDLG32.INC"
                                   
                                  Function PBMain         
                                    ErrClear   
                                    Local s$
                                   
                                    s$ = GetFolder
                                    ? s$
                                  End Function 'Applikation beenden
                                  '------------------------------------------------------------------------------
                                  'Clipped from forum somewhere years ago, original authir unknown
                                  Function GetFolder As String
                                      Local PathID As Dword
                                      Local bInf As BROWSEINFO
                                      Local szPath As Asciiz * %MAX_PATH
                                  '    bInf.hWndOwner = hParent 'Set some properties for the BFF dialog
                                      bInf.ulFlags   = %BIF_RETURNONLYFSDIRS Or %BIF_DONTGOBELOWDOMAIN
                                      bInf.lpszTitle = VarPtr(szPath)
                                      PathID = SHBrowseForFolder(bInf) 'Show the Browse-For-Folder dialog
                                      Function = "Nothing Found"
                                      If PathID Then
                                          If SHGetPathFromIDList(ByVal PathID, szPath) Then
                                              Local gStartPath$
                                              Function = Extract$(szPath, Chr$(0))
                                          End If
                                          CoTaskMemFree PathID 'Free allocated memory
                                      End If
                                  End Function
                                  '------------------------------------------------------------------------------
                                  '
                                  ========================================
                                  "Sanity is a madness put to good uses."
                                  George Santayana (1863-1952)
                                  ========================================
                                  It's a pretty day. I hope you enjoy it.

                                  Gösta

                                  JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                                  LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                                  Comment


                                  • #18
                                    My question is really more general. I'm trying to get some understanding of what controls to use when..
                                    As has been suggested in a couple of the replies above - a good entry point is to observe what solutions have been applied
                                    in commercial / real world applications that you are familiar with and try to copy/tune those.

                                    This tool can be a boon in that regard..
                                    PB WinSpy++++ 1.17 "captures" existing dialogs and controls, generating PowerBASIC DDT or SDK-style code to
                                    duplicate the look of existing GUI applications. A great RAD tool and excellent way to learn about Windows!
                                    Freeware by Borje Hagsten.
                                    http://www.powerbasic.com/files/pub/...ols/WinSpy.zip
                                    With it you can examine for example, which controls are put to use in a dialog brought up by Display Openfile..


                                    Another suggestion made was to make use of a good reference book. These have been recomended on the forums in the past:

                                    ..Programming Windows 5th Ed. by Charles Petzold
                                    ..Win32 Programming by Brent E. Rector and Joseph M. Newcomer
                                    ..Windows 98 (or 2000) Programming from the Ground Up by Herbert Schildt
                                    ..Windows 95, a Developers Guide by Jeffrey Richter and Jonathan Locke
                                    ..Programming Applications for Microsoft Windows (fourth edition) by Jeffrey Richter

                                    For a detailed examination of the set of 'common controls' available in ComCtl32.dll take a look at
                                    "Control Spy Exposes the Clandestine Life of Windows Common Controls"
                                    By Mark Finocchio http://www.microsoft.com/msj/0798/controlspy.aspx


                                    The problem with asking a general question on the forum is that you will have to do a bit of work winnowing out some
                                    of the 'Chaff' you'll invariably get but que sera - that comes with the territory!

                                    I hope you took up Gary's invitation to visit his website - some relevant stuff there I think.

                                    HTH
                                    Rgds, Dave

                                    Comment


                                    • #19
                                      Well, I think you're all correct. And all mistaken.

                                      While it's true that no one person precisely answered all my questions a lot of information was included that got me looking in some useful places. Then I got pulled away into something outside the computer for a couple days but after tomorrow I'll be back and this thread and it's many answers have given me what I need to get started.

                                      By the way, I'm not a beginner. I'm a rusty old hand with the emphasis on old. My mind doesn't grasp things like it used to but I have a many decade background in programming even though I've gone over a decade without doing any of it till the past year or so.

                                      The first thing I did before asking the question was spend a bit of time in MSDN and then googling. The problem was that I found too much information and had little idea of what was important. I have very little Windows experience except as a user. My programming was done mostly before there was a Windows and when it came along I was in other areas.

                                      Reading the thread and it's many suggestions, both particular and general, I have some ideas where to go next. I think the best suggestion was just to use trial and error. That's how I learn best and I'm just playing these days anyway so there's no rush. I guess I should have known to do that but I let myself get a little flustered.

                                      As for the problem with newbies getting frustrated here, if I was a newbie this thread might have frustrated me a little. Actually it did but I saw the value of it and I ignore that and got past it. But that would have been more difficult if I hadn't learned some of the lessons over the years that I seem to have to relearn now. So yes, a newbie probably would have found this very frustrating. Some would get discouraged and give up. Some would get past it and learn and keep going. I see no problem with any of that. Programming is mostly learning how to deal with frustration.

                                      So, thanks for all your help. I did ask both particular and general questions and I think both were covered pretty well in the discussion.

                                      Barry

                                      Comment

                                      Working...
                                      X