LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

sizing controls by the mouse

Hello

I've got an application whith two tables. The content (rows) can varry a lot in both of them.

It would be practical if the user could  size  the height of them by dragging the mouse.

Regards Per

0 Kudos
Message 1 of 6
(3,531 Views)

This is something I have done in the past, using code similar to:

 

    case EVENT_LEFT_CLICK:              // This is in the control callback
        do {                            // Do it continuously
            GetRelativeMouseState (panel, 0, &x, &y, &down, 0, 0); // Get mouse position

            ...                         // Use x & y to draw/size the control

                                        // SetCtrlAttribute () with ATTR_HEIGHT, for example

                                        // You might not need to change its width - depends on your app

                                        // You probably want to constrain the xy values
            }
            ProcessDrawEvents ();       // Ensure the control is actually drawn
        } while (down);                 // Mouse release gives "commit" event

JR

0 Kudos
Message 2 of 6
(3,523 Views)

Per:

 

If you want to allow users to resize the row height, you need to set the size mode for all rows to USE EXPLICIT SIZE, and then enable row resizing for the table.

 

   SetTableRowAttribute (mainPanelHandle, PANEL_TABLE, -1, ATTR_SIZE_MODE, VAL_USE_EXPLICIT_SIZE);
   SetCtrlAttribute (mainPanelHandle, PANEL_TABLE, ATTR_ENABLE_ROW_SIZING, 1);

 

 

Then the user will be able to resize a row by dragging the border of the row.

Message Edited by Al S on 09-15-2009 12:11 PM
0 Kudos
Message 3 of 6
(3,517 Views)

Hey Per - 

 

I have one more suggestion to add to the list.  You may consider using splitter controls and attaching them to your tables.  Take a look at the sample code attached.

 

NickB

National Instruments  

Message Edited by nickb on 09-15-2009 12:42 PM
0 Kudos
Message 4 of 6
(3,503 Views)

Hello

I might not express clearly what I wanted to do.

 

What I want is to resize the table, eg. the number of rows, by draging the mouse

 

I tried to set the attributs as you proposed but I couldent see any effect, neither on individual rows.

0 Kudos
Message 5 of 6
(3,480 Views)

This code worked well for me:

 

    case EVENT_LEFT_CLICK:              // This is in the table callback
        do {

            GetRelativeMouseState (panel, control, 0, &y, &down, 0, 0);

            SetCtrlAttribute (panel, control, ATTR_HEIGHT, y);

            ProcessDrawEvents ();

        } while (down);

 

JR

0 Kudos
Message 6 of 6
(3,469 Views)