Finding out control IDs
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 34

Thread: Finding out control IDs

  1. #1
    Join Date
    Jul 2004
    Posts
    105

    Question Finding out control IDs

    Can anyone tell me how to find the control IDs for the "Name","size","type", and "Modified" buttons that come up in an Open/Save dialog box when the Details button is pressed? Or does anyone know these control IDs?

    Thanks!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421
    Do you mean the header control titles of a ListCtrl?
    I think there is no Control ID for a column header.

  3. #3
    Join Date
    Jul 2004
    Posts
    105
    I don't know what they are called. they are the buttons that appear when you press the Details button in any Open/Save dialog. They are the ones that allow you to sort the files by name, type, size, or modified. What I want to do is have the list of files sorted by one of these before the open/save dialog opens to the user. I already know how to simulate a button being pressed but i need the control id.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421
    See the post #2.
    These "buttons" are not the Buttons. They are the part (parts) of the Header control, not the controls themselves!

  5. #5
    Join Date
    Jul 2004
    Posts
    105
    So does that mean there is no way to access or control them?

  6. #6
    Join Date
    Jul 2004
    Posts
    105

    Angry

    I dont know. I am a beginner at this stuff. Why did you get mad at me and give me a bad reputation. I am learning. Thanks a lot.

  7. #7
    Join Date
    Jul 2004
    Posts
    105

    Question

    What? now my reputation is green. Before it was red. What happened? Who controls the reputations?

  8. #8
    Join Date
    Aug 2001
    Location
    Germany
    Posts
    1,384
    Well I have never tried it myself but you can something like
    • Use FindWindow/EnumChildWindow to find a widow with class "SysListView32".
    • Send message LVM_GETHEADER or use macro ListView_GetHeader to get the handle of headerctrl of the ListView.
    • Now you need to know against which HeaderItem i.e. size, date, name etc you want to sort. Either hardcode the index (i think it is always the same) or move on the HeaderControl to get the correct index with messages like HDM_GETITEMCOUNT or HDM_GETITEMCOUNT.
    • Now send a notify-message to HeaderCtrl's Parent like...
      Code:
      SendMessage(GetParent(hHeaderCtrl), WM_NOTIFY, NULL, (LPARAM)&NMHeader);
      Look into MSDN for how you should fillout the NMHeader struct.

    May be there is anyother easier way to do the same, but sorry i am not aware of it.
    Hope this helps,
    Regards,
    Usman.
    Btw, your repo is still green

  9. #9
    Join Date
    Jul 2004
    Posts
    105

    Red face

    Thanks for the post. I know, my rep is now green but for a while there is was showing red.
    I think I am following you on your explanation but where does the list get sorted by the specified header? Is there a function call or do I put the header items in a specific order with the item that i want to sort by first? thanks again!

  10. #10
    Join Date
    Aug 2001
    Location
    Germany
    Posts
    1,384
    Well to sort a ListView you click on the ListView HeaderItem and that Item tells its PARENTWINDOW that a click has happened and do whatever needs to be done. What i told you to is the get HeaderCtrl handle (with handle you can get the info about the HeaderItem, that you can use to fillin the struct NMHEADER, and after filling that struct you do the same (by sending the WM_NOTIFY to parentwnd) that a click even has happened. The ListView should then sort itself. Hope its clear enough.
    Regards,
    Usman.
    Btw I wouldn't mind if you would like to add something to my repo .

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421
    Quote Originally Posted by senkyoshi
    So does that mean there is no way to access or control them?
    Take a look at these (and, perhaps, you will find some more) usefull Paul DiLascia's articles:
    http://msdn.microsoft.com/msdnmag/issues/0800/c/
    http://msdn.microsoft.com/msdnmag/issues/02/01/c/

  12. #12
    Join Date
    Jul 2004
    Posts
    105

    Talking

    Hey Usman,

    I think that is going to work. I am going to go ahead and try it now but if I have any problems I will add another reply. thanks to both of you. You both should now have a reputation point added to your names!

    thanks again

  13. #13
    Join Date
    Jul 2004
    Posts
    105

    Question

    usman,

    After I get the handle to the HeaderCtrl, how do I get the information that I need for the NMHEADER struct?

  14. #14
    Join Date
    Aug 2001
    Location
    Germany
    Posts
    1,384
    Hi!
    Please don't create new threads for the same problem. Now you want to fill in the NMHEADER struct. Its defined in MSDN like...
    Code:
    typedef struct tagNMHEADER {
        NMHDR hdr;
        int iItem;
        int iButton;
        HDITEM *pitem;
    } NMHEADER, *LPNMHEADER
    The first three members of the struct should be pretty straight forward, for the last one use HDM_GETITEM that message will give the HDITEM for the item you are interested in then u can assing the address of the returned HDITEM to the last member of the struct and send the WM_NOTIFY. So you have all the four params filled in.
    Hope this helps,
    Regards,
    Usman.

  15. #15
    Join Date
    Jul 2004
    Posts
    105

    Question

    Problem: i am trying to use FindWindow with class "SysListView32" but it isnt returning anything. any other way to get a reference to CListCtrl in the CFileDialog?
    thanks

Page 1 of 3 123 LastLast

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center