sizing common controls

This is a discussion on sizing common controls within the Windows Programming forums, part of the Platform Specific Boards category; i have a few contols(edit, listbox, 2buttons, and a few statics for output) that i create at runtime and size ...

  1. #1
    Nor
    Nor is offline
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299

    sizing common controls

    i have a few contols(edit, listbox, 2buttons, and a few statics for output) that i create at runtime and size myself.

    when you resize the window it just doesnt look right.
    anyone have any good tips/tricks for doing this?

    here is some code;
    Code:
            case WM_SIZE:
            {
                HWND hEdit       = GetDlgItem(hWnd, IDC_MAIN_OUTPUT);
                HWND hList       = GetDlgItem(hWnd, IDC_MAIN_LIST);
                HWND hStatic     = GetDlgItem(hWnd, IDC_STATIC);
                HWND hS_FILENAME = GetDlgItem(hWnd, IDC_MAIN_S_FILENAME);
                HWND hS_FILELEN  = GetDlgItem(hWnd, IDC_MAIN_S_FILELEN);
                RECT rcClient;
    
                GetClientRect(hWnd, &rcClient);
                
                //main edit
                SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom/4, SWP_NOZORDER);
                
                //main listbox ... acts like its stuck when its being resized.
                SetWindowPos(hList, NULL, rcClient.right - (rcClient.right/3),  // x
                                          rcClient.bottom/4,                    // y
                                          rcClient.right/3,                     //length
                                          rcClient.bottom - (rcClient.bottom/4),//height
                                            SWP_NOZORDER);
                //main static .. can't even get it to move where i want it
                SetWindowPos(hStatic, NULL, 0,                   // x
                                            rcClient.bottom/4,   // y
                                            2*(rcClient.right/3),//length
                                            rcClient.bottom - (rcClient.bottom/4),//height
                                              SWP_NOZORDER);
                //file name ... works fine
                SetWindowPos(hS_FILENAME, NULL, 5,                     // x
                                                rcClient.bottom/4 + 5, // y
                                                300,                   //length
                                                20,                    //height
                                                  SWP_NOZORDER);
                //file length ... works fine 
                SetWindowPos(hS_FILELEN, NULL, 5,
                                               rcClient.bottom/4 + 30,
                                               300,
                                               20,
                                                 SWP_NOZORDER);                                              
                                                
            }
    /* TODO add buttons */
            break;
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    Are you sure you wouldn't rather use MoveWindow(hwnd, left, top, width, height, repaint) instead of SetWindowPos?

  3. #3
    Nor
    Nor is offline
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    thx. i'll read up of the functions. found a list of them
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 11:53 AM
  2. common dialog controls
    By lambs4 in forum Windows Programming
    Replies: 2
    Last Post: 11-05-2002, 07:33 PM
  3. common controls and mouse clicks
    By bennyandthejets in forum Windows Programming
    Replies: 4
    Last Post: 09-11-2002, 04:50 AM
  4. common controls
    By neandrake in forum Windows Programming
    Replies: 2
    Last Post: 03-17-2002, 11:52 PM
  5. Site on Making Common Controls like BUttons
    By knight543 in forum Windows Programming
    Replies: 3
    Last Post: 03-02-2002, 06:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21