Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

CNiKnob pointer's fillcolor not updated when ValuePairs change

I have a CNiKnob for setting volt ranges. The pointer fillstyle is "Fill to Value less than". This works fine until I change the knob's value pairs...

- I clear all value pairs.
- Add the new value pairs.
- Do a SetValuePairIndex() to update the pointer.

The new pointer value appears correct, but the fillcolor level does not match the new ValuepairIndex. The colour appears to stay pointing to the same spot as it was at before changing the valuepairs. If I use the mouse to change the pointer, the colour level will then match the value.

I've tried CNiKnob.Refresh() and others, to no avail. How can I force the fillcolor to redraw to match the pointer?
(See attached bitmaps to view the pro
blem)
Download All
0 Kudos
Message 1 of 7
(3,335 Views)
This worked for me. Is the knob in Value Pairs Only mode? Also, what version are you using (check the control's property pages)? I'm using the latest, version 6.0.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 7
(3,335 Views)
I use Value Pairs only mode - it suits my requirements. Is this a problem?

I'm using version 6.0 (build 589) also.

Any other ideas?
0 Kudos
Message 3 of 7
(3,335 Views)
I'm at a loss for why you are seeing what you are seeing. Everything works perfectly for me. I attached my project below that I was using to test this. See if you can see any differences in your project that may be the source of the problem.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 7
(3,335 Views)
Chris, maybe I should have explained better. The problem occurs when I programatically give the knob a new set of ValuePairs. Then the fillcolor can go out of synch with the pointer. It will resynch when the knob gets the focus (use tabs).

I've updated your sample app to show the problem. It seems to be eratic in that the fillcolor is correct in some instances, but often it sits between two values.
0 Kudos
Message 5 of 7
(3,335 Views)
I see the problem now. What is happening is there seems to be a problem with not ALL of the value pair data being updated immediately for the SetValuePairIndex function to move the pointer properly. You can fix this (or at least it fixed it for me), by putting a function call to m_knob.Refresh() after you add the value pairs. So in your code I inserted that call here:

for (int i = 0; i < iVoltValsCount; i++)
{
itoa(voltVals[i], sBuffer, 10);
strTmp = sBuffer + strSymbol;

CNiValuePair valPair = voltAxis.ValuePairs.Add();
valPair.Value = voltVals[i];
valPair.Name = strTmp;
}
m_knob.Refresh();//<----New line
// Set the pointer
m_knob.ValuePairIndex = 6;

Add the problem went away. Let me know if th
at fixes it for you.

Chris
0 Kudos
Message 6 of 7
(3,335 Views)
That line fixed the problem in the test app alright, BUT not in my real application.

I've found that a subsequent call to knob.SetFocus() however does force the knob to display properly:
- Set the new value pairs
- Call knob.Refresh()
- Set the new ValuePairIndex
- Call knob.SetFocus()

Thanks for you help.
Billy H.
0 Kudos
Message 7 of 7
(3,335 Views)