LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

changes in NewPanel?

Solved!
Go to solution

In old compiler (CVI 😎 I used a few function to grab a panel with measurement status and publish it as BMP image to datasocket. On a remote computer, I link to the datasocket server, and display updates of the panel image. As existing exe-files for test, this runs on my new computer with Windows 7 x64.

With CVI2010, datasocket is not supported anymore. So I am switching the exchange to network variable. The conversion is not yet finished but I can send a demo panel to network variable and retrieve it in a second program. However, when I display the image then it is partly white/false. And when I move the panel, it seems as if I lose the panel/control ID.

 

The demo writer has its main (not existing in any real application) and a panel with dummy log-status.

The finalized reader should have to panels. One panel is for control; it is made as UIR. The second panel is made in the reader software. It is a panel without parent (parent panel handle = 0). In the panel, there is a picture control (CTRL_PICTURE) as large as the panel without borders. And there is a hidden, dimmed control that is used as link for a quit-callback.

 

I have inserted the code for making the panel for displaying the published copy. This code is identical for the old version (data socket version developed on Windows XP with CVI 😎 and the new version (network variable developed on Windows 7 x64 with CVI2010). I have attached a screen dump from both applications. Obvious the datasocket shows a correct copy, and the new version has an error. 

 

For debugging in the new version, I have saved the bitmapid (just before transferring it to the picture control with SetCtrlBitmap) after receiving from the network variable to a file with SaveBitmapToBMPFile (bitmapid, "D:\\Pobox\\Test001.bmp"). This stored picture is ok.

 

Does anybody have seen similar deviating behaviour with software-generated panels/controls on WIndows 7 or CVI 2010 ?

 

Regards, Jos

 

 

// generating the panel with dummy values for size

 if (bmpp < 0)
 {
  bmpp = NewPanel (0, "BMP Frame", 10, 10, 100, 100);
  if (bmpp < 0) return -1; /* no new panel could be made */
  SetPanelAttribute (bmpp, ATTR_CAN_MAXIMIZE, 0);
  SetPanelAttribute (bmpp, ATTR_SIZABLE, 0);
  SetPanelAttribute (bmpp, ATTR_CLOSE_ITEM_VISIBLE, 1);
  SetPanelAttribute (bmpp, ATTR_MOVABLE, 1);
  
  bmpc = NewCtrl (bmpp, CTRL_PICTURE, "", 0, 0);
  if (bmpc < 0) /* no control in new panel could be made */
  {
   DiscardPanel(bmpp);
   return -1;
  }
  quitc = NewCtrl (bmpp, CTRL_SQUARE_COMMAND_BUTTON_LS, "Quit", 0, 0);
  if (quitc < 0) /* no control in new panel could be made */
  {
   DiscardPanel(bmpp);
   return -1;
  }
  SetCtrlAttribute (bmpp, quitc, ATTR_ZPLANE_POSITION, 999);
  SetCtrlAttribute (bmpp, quitc, ATTR_VISIBLE, 0);
  SetCtrlAttribute (bmpp, quitc, ATTR_DIMMED, 1);
  InstallCtrlCallback (bmpp, quitc, NvReadQuitButton, 0);
  SetPanelAttribute (bmpp, ATTR_CLOSE_CTRL, quitc);
  SetCtrlAttribute (bmpp, bmpc, ATTR_FRAME_VISIBLE, 0);
  SetCtrlAttribute (bmpp, bmpc, ATTR_LABEL_VISIBLE, 0);
  Status = DisplayPanel(bmpp);
 }

 

 

 

Download All
0 Kudos
Message 1 of 4
(3,081 Views)

I see a difference between the code-generated panel (a 100 by 100 pixels square one) and the one shown in the attachment: if you are manually or programmatically resizing the panel you may need to resize the picture control as well. You could try setting on the Scale contents on resize panel attribute or trapping EVENT_PANEL_SIZE event and changing control dimensions accordingly.

Additionally, you never size the picture control you create: I don't know which are the default dimensions of the control when programmatically creating it, but consider that when you create a new one in the UIR editor it will be 64x64 pixel wide: adaptation of its dimensions to panel size is in my opinion necessary if you want to cover the entire panel area with the image.



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 2 of 4
(3,054 Views)

You are correct. The code shows creation of the (parent=0) panel with a picture control with default sizes. I do not know yet what the size will be of the next BMP data.

 

In the code for retrieving and showing the BMP picture,subsequently

- I get the BMP data,

- retrieve width and height,

- adapt the size of the panel and the picture control,

- get a bitmapid for the resized picture control,

- allocate memory for the new bitmapid,

- copy the BMP data to that allocated memory, and finally

- set the bitmapdata to the bitmapid.

 

The code below is resizing with bmpp as (global) panel id and bmpc als (global) control id. The BmpInfoHeader for the example has 400 pixels for width and 150 pixels for height. The value for FRAMEBORDER is here constant 5, but in the next version I will retrieve it from the picture control.

width = BmpInfoHeader.width;

height = BmpInfoHeader.height;

if ((width <= 0) || (height <= 0)) goto CleanUpMemory;

sprintf(MessageString, "%02d:%02d:%02d Resize BMP display panel", Hours, Minutes, Seconds);

SetPanelAttribute (bmpp, ATTR_WIDTH, width + 2 * FRAMEBORDER);

SetPanelAttribute (bmpp, ATTR_HEIGHT, height + 2 * FRAMEBORDER);

SetCtrlAttribute (bmpp, bmpc, ATTR_HEIGHT, height);

SetCtrlAttribute (bmpp, bmpc, ATTR_WIDTH, width);

SetCtrlAttribute (bmpp, bmpc, ATTR_TOP, FRAMEBORDER);

SetCtrlAttribute (bmpp, bmpc, ATTR_LEFT, FRAMEBORDER);

 

 

0 Kudos
Message 3 of 4
(3,049 Views)
Solution
Accepted by topic author JGS

Problem is partly solved.

 

The NewPanel was called from within a callback for a network variable update. This seems to be a different thread from the main. The panel and a picture-control got new values for size and width by using SetPanelAttribute and SetControlAttribute. It seems as if these values were not fully processed. The picture control was filled with SetCtrlBitmap but was subsequently clipped with the original dummy size of the picture control.

Strange in this behaviour is that the use of GetCtrlDisplayBitmap and GetBitmapData - immediately after setting the new sizes - give the correct new sizes.

 

Solution: add  ProcessDrawEvents after resizing panel and picture with SetPanelAttribute and SetControlAttribute

0 Kudos
Message 4 of 4
(3,014 Views)