LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I simulate a "text button" like some professional Software?

Hi,everyone.
I'm working on a ATE program for SMPS(switching mode power supply) testing.
Now my GUI wants a function like this: 
(1) normally displayed as a text message;
(2) when cusor moved on, text color changed blue and underlined;
(3) If left_click, call specified function and then text restored normal;
(4)if cursor moved off, text restored normal and do nothing.
 
Yes, it sounds like a hyperlink. I found some messages posted about this title ,but
the problem is even if I add callback function there is no Cursor Move_On or Move_OFF
events of textmessage control or any other useful controls. You know if only click-then-do function
implemented is not a good idea. So anyone has better ieas?
 
Another question, I use EasyTab lib functions to create multi page view GUI like modern
webpage explorer software.
(1)Firstly the tab button should have a "X" close button but it is hard to
code.
(2)Secondly when too many tabpages loaded/added the tab buttons become too crowed to
display the whole tab label. Is there anyway to make the easytab ceating TabControl displayed
as TabControl behaviror with a scroll if neccessary.
(3)Thirdly, because no solution of second
problem found I placed three picture buttons on the top right of the easytab creating control. But
when too many tabpages added these buttons are covered by tab labels.
 
What do your guys think about this question?
I will attach the GUI image to show these two questions to help you know what I met.
 
 
0 Kudos
Message 1 of 8
(4,448 Views)

Hello there,

quite a lot you are asking Smiley Wink But it is indeed important to make your User Interface look a little bit professional.

I attached a small example project to show you how to respond on mouse position. Therefore, the EnableExtendedMouseEvents function is used on the button control, to enable the callback function to be called with the EVENT_MOUSE_MOVE event. Then, all you have to do is check if the mouse is over the button or not, and adjust the label style. Just check the example code and you will see that it's actually quite easy.

Now, for the tab pages: I'm afraid that it is not possible to add a close button to each tab page (at least not on the tab button itselft). A solution would be to put it on another location on the tab page, with the small drawback that the user has to activate the tab page before it can be closed.

CVI 8.0 and higher versions have a built-in tab control. There, it is possible to create a scroll control when to many tab pages are created. If you have a lower CVI version, maybe you migh consider working with ActiveX Tab Controls, provided by Microsoft (Microsoft TabStrip Control). I have never used these controls, but they might have the functionality that you are looking for. To use these, open your uir file, drop down the Create menu (or right-click your panel) and select ActiveX.

Good Luck

0 Kudos
Message 2 of 8
(4,422 Views)
You can somewhat solve your tab problem by using the built-in tab control instead of the easytab control. You really should be using it anyway, since it is much better integrated into the rest of the UI library, and definitely has more functionality than the easytab. It still doesn't have an 'X' button by default, but you can place your three buttons there the way you show in your picture. The way you would solve the problem of the tabs covering the buttons would be to right-justify the tabs (using ATTR_TABS_LOCATION) and to then offset it from the corner using ATTR_TABS_START_OFFSET. You can see how this looks in the CVI environment itself: look in the tab control below the main source window (Find Results, Debug Output, etc..).

Also, if you have CVI 8.1, there are built-in mouse move events (EVENT_MOUSE_POINTER_MOVE), so you don't have to use the extended mouse events functionality of the toolbox (which can ramp up the CPU usage a bit). But Wim's solution works fine, and you'll have to use it if you have an older version of CVI.

Luis
0 Kudos
Message 3 of 8
(4,400 Views)
Wim S, LuisG ,thank you.
 
I use CVI8.0.1 and I notice there is a built-in tab control. I use this control in some place but the question is no LoadPanel or AddPanel functions  exist which can provide a way to Load/Add an independent panel I edited before. Built-in tab control  has fucntions like  InsertTabpage/CopyTabpage that means I must place panels which I prepared as templates on the tab control  and then hide them at first. That also means I cannot discard those templates panels from memory and reload them if I need to use again.  
 
To Wim S, may be I should try your MouseMove example.
 
To LuisG, about tab buttons your idea is much helpful. Our company bought CVI Feb,2006 so I think there is still a free software update. If I get CVI8.1 I will try built-in  EVENT_MOUSE_POINTER_MOVE. 
 
Thanks again for all your guys!
0 Kudos
Message 4 of 8
(4,384 Views)

Hmm, I'm not sure what you mean by placing template panels on the tab control and then hiding them. I suspect that you would be able to do what you need to do using InsertTabPage and CopyTabPage (and maybe with a little bit of ingenuity). However, the new function InsertPanelAsTabPage was added in 8.1, which allows you to add any existing panel to a tab control as a tab page. This sounds like exactly what you were describing.

 

As far as the hyperlink behavior, a panel callback like this would do the trick....

int CVICALLBACK PanelCB (int panel, int event, void *callbackData,
  int eventData1, int eventData2)
{
 Rect rect;
 switch (event)
  {
  case EVENT_MOUSE_POINTER_MOVE:
   GetCtrlBoundingRect(panel, PANEL_TEXTMSG,
    &rect.top, &rect.left, &rect.height, &rect.width);
   if (RectContainsPoint(rect, MakePoint(eventData2, eventData1)))
    {
    SetCtrlAttribute(panel, PANEL_TEXTMSG, ATTR_TEXT_COLOR, VAL_BLUE);
    SetCtrlAttribute(panel, PANEL_TEXTMSG, ATTR_TEXT_UNDERLINE, 1);
    }
   else
    {
    SetCtrlAttribute(panel, PANEL_TEXTMSG, ATTR_TEXT_COLOR, VAL_BLACK);
    SetCtrlAttribute(panel, PANEL_TEXTMSG, ATTR_TEXT_UNDERLINE, 0);
    }
   break;
  case EVENT_CLOSE:
   QuitUserInterface (0);
   break;
  }
 return 0;
}

Hope this helps,

- jared

0 Kudos
Message 5 of 8
(4,359 Views)
Hi jared ,
You have perfectly understood what I thought about that GUI.
(1) Text button ,you know ,mouse cusor on sense and click-then-do function;
(2) Tab pages, dynamiclly load/remove panels which are prepared before as templates. What I need are close button and scroll.Yes, built-in Tab Control provides similar functions. But I should put a template panel on a TabControl which placed on a top level panel and then can use CopyTabPage/InsertTabPage. This is not a simple way and what I want  is something like InsertPanelAsTabPage added in 8.1. I just called NI and they said the update package would be sent in the next 2 month. I cannot wait for this but I really don't know how to get these functions in another direct way.
 
And you see, what I need are mostly intergrated in CVI 8.1. EVENT_MOUSE_MOVE and nsertPanelAsTabPage, hehe! At present, I implement them in a complex way.
 
 
//-------------------------------------------------------------------
//Codes about  "text button" :
 
int CVICALLBACK CvWelCallBack (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
    Rect ctrlRect[4];  // size and position of the text messages
    int  ctrlID[4];    // control ID of the text messages
    int  i;
    static int blMoveOn=0;
 
    switch (event) {
        case EVENT_MOUSE_MOVE: 
   
        ctrlID[0] = TABP_WEL_TEXTMSG_1;
        ctrlID[1] = TABP_WEL_TEXTMSG_2;
        ctrlID[2] = TABP_WEL_TEXTMSG_3;
        ctrlID[3] = TABP_WEL_TEXTMSG_4;
   
        for(i=0;i<4;i++)
        {
             GetCtrlBoundingRect (panel, ctrlID[i], &ctrlRect[i].top, &ctrlRect[i].left,
                 &ctrlRect[i].height, &ctrlRect[i].width);
             blMoveOn = (panel ==GetActivePanel() ) &&
                 ( RectContainsPoint (ctrlRect[i], MakePoint (eventData2, eventData1)) );
             SetCtrlAttribute (panel, ctrlID[i], ATTR_TEXT_COLOR,
                 blMoveOn ? VAL_BLUE : VAL_BLACK);
             SetCtrlAttribute (panel, ctrlID[i], ATTR_TEXT_BOLD, blMoveOn );
             //SetCtrlAttribute (panel, ctrlID[i], ATTR_TEXT_UNDERLINE, blMoveOn );    
        }
        //set mouse cursor, must check all controls!!!
        
        blMoveOn= (panel ==GetActivePanel() ) && ( 
            RectContainsPoint (ctrlRect[0], MakePoint (eventData2, eventData1)) ||
            RectContainsPoint (ctrlRect[1], MakePoint (eventData2, eventData1)) ||
            RectContainsPoint (ctrlRect[2], MakePoint (eventData2, eventData1)) ||
            RectContainsPoint (ctrlRect[3], MakePoint (eventData2, eventData1)) );
    
        SetMouseCursor(blMoveOn ? VAL_POINTING_FINGER_CURSOR : VAL_DEFAULT_CURSOR); 
        break;
 }
 return 0;
}
 
 
 
Attachment:
Modified GUI,use built-in TAB Control (just because the scroll):
 
 

帖子被Whatcall在03-29-2007 09:21 PM时编辑过了

0 Kudos
Message 6 of 8
(4,343 Views)
Take a look at \samples\userint\tabpanels.prj
 
In that example, all the controls in an existing panel are copied into a new tab page, which is basically the same thing as inserting a panel into a tab control.
0 Kudos
Message 7 of 8
(4,310 Views)
Thanks for your reminding.
I've read the codes of \samples\userint\tabpanels.prj . The function ConvertChildPanelToTabPage() is the key point. I also found in  CVI8.1 they use InsertPanelAsTabPage to do the same thing. They intergrated the codes I think so I get the way to do what I want . 
 

帖子被Whatcall在04-01-2007 08:14 PM时编辑过了

0 Kudos
Message 8 of 8
(4,282 Views)