How to create mult trackbar?

Hi guys.
I want to create mult trackbar in one window to control 3 parament like H,S and V in one pic.
I use this code to create:

namedWindow(bar);
createTrackbar(H,bar,NULL,1,inrange,(void *)(&image));
setTrackbarMin(H,bar,0);
setTrackbarMax(H,bar,255);
setTrackbarPos(S,bar,10);
createTrackbar(S,bar,NULL,1,inrange,(void *)(&image));
setTrackbarMin(S,bar,0);
setTrackbarMax(S,bar,255);
setTrackbarPos(H,bar,244);
createTrackbar(V,bar,NULL,1,inrange,(void *)(&image));
setTrackbarMin(V,bar,0);
setTrackbarMax(V,bar,255);
setTrackbarPos(V,bar,200);

In the callback code,I use getTrackbarPos() to get the value of each trackbar:

int h=getTrackbarPos(H,bar);
int s=getTrackbarPos(S,bar);
int v=getTrackbarPos(V,bar);

When I run with it,there is a error like this:

OpenCV(4.5.4) Error: Assertion failed (trackbar) in getTrackbarPos, file D:\lib\opencv-4.5.4\modules\highgui\src\window.cpp, line 868

I set some check piont between each trackbar create code.
Seems that when the first trackbar value set function runing,it went to run the callback function once,at this time,the other trackbar were not created,so in the callback funtion getTrackbarPos() can’t find those trackbar which named “S”,“V”.

Am I right?
And should I let all the setTrackbarPos() be after all the create funtion?