From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

make custom picture button

Hello,
I want to us a picture button that eacth time user press it
the picture of it change form one state to another state.
for this I use following code that work correctlly:
 CVICALLBACK PoloCB (...)                       
{                                                                                  
   switch (event)                                                                
   {                                                                             
      case EVENT_COMMIT:                                                        
                                                                                  
      GetFullPathFromProject ("", projectpath);                             
                                                                                  
      if(Cooker == 0)                                                       
      {                                                                     
 Cooker = 1;                                                       
 MakePathname (projectpath, "ON.bmp", fullpath);            
 SetCtrlAttribute (Panel,PANEL_POLO,ATTR_IMAGE_FILE,fullpath);                                      
      }                                                                     
      else                                                                  
      {                                                                     
 Cooker = 0;                                                       
 MakePathname (projectpath, "OFF.bmp", fullpath);           
 SetCtrlAttribute (Panel,PANEL_POLO,ATTR_IMAGE_FILE,fullpath);                                
      }                                                                      
      break;                                                                
   }                                                                             
}                                                                                 
But problem is with this method, everyone can see these bmp file in my project
dir and use them and loading file form hard is time consuming. I want to load this image in the "edit picture button" menu
so the picture is embedded in the source code.But it'snot possible to define
image for each state in the "edit picture button".
I also try to use two picture in the same position
and visible/unvisible them but with this method should also use two
fuction call(beacuse the one vissible is active button) that this is not
good and my code get really complex.(I have a lot of these kind button in
 my project)
In labview I can use simple button and change it's images with my images.
Is it possible to do that in labwindows?
0 Kudos
Message 1 of 8
(4,043 Views)
I think you can achieve what you want if you replace your Picture Button control with a Picture Ring.

Check out the picture sample project in the samples\userint folder.

0 Kudos
Message 2 of 8
(4,033 Views)

Thanks for your solution, the ring picture is what I want but it doesn't look like the a button.

I need a button with picture on it that each time use press it the icon change.

0 Kudos
Message 3 of 8
(4,029 Views)
is it possible to use "edit custom control" for creating a new button with properties that I needed?
0 Kudos
Message 4 of 8
(4,028 Views)

Finally I solve the problem,

I put a picture ring in my panel with hidden attribute and load all of my picture to it.

in my begining of program use GetCtrlBitmap to variables.

and use these variables as refrences to bitmap with SetCtrlBitmap.

something like this:

int CVICALLBACK PoloCB (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 static Cooker = 0;
 
 switch (event)
 {
  case EVENT_COMMIT:

   SetCtrlBitmap (panel, MAINPANEL_POLO, 0, (Cooker) ? BMP_CookerOFF : BMP_CookerON);
   Cooker ^= 1;
   break;
 }
 return 0;
}

0 Kudos
Message 5 of 8
(4,010 Views)
never mind, my solution has already been posted Smiley Happy


Message Edited by Wim S on 05-05-2008 09:25 AM
0 Kudos
Message 6 of 8
(4,005 Views)

please help me how to fill balck color in white space....in icon.....pls check attathed image please..

0 Kudos
Message 7 of 8
(3,246 Views)

Duplicated post: see here



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 8
(3,230 Views)