On Tue Sep 2 22:03:46 2025 +0000, Esme Povirk wrote:
I'm not sure if this covers all potential option type+constraint combinations. We should probably print a FIXME if we get something unexpected, and maybe initialize these fields to something invalid?
This block repeats the initialization of the parameters in the InitializeDialog function. I have saved only the necessary operations to generate the parameters.
` else if (opt.type == TYPE_FIXED) { int pos, min, max, *sf;
if (opt.constraint.range.quant) { min = opt.constraint.range.min / opt.constraint.range.quant; max = opt.constraint.range.max / opt.constraint.range.quant; } else { min = MulDiv( opt.constraint.range.min, 100, 65536 ); max = MulDiv( opt.constraint.range.max, 100, 65536 ); }
SendMessageA(control,SBM_SETRANGE,min,max);
sf = calloc( opt.size, sizeof(int) ); sane_option_get_value( i, sf );
/* Note that conversion of float -> SANE_Fixed is lossy; * and when you truncate it into an integer, you can get * unfortunate results. This calculation attempts * to mitigate that harm */ if (opt.constraint.range.quant) pos = *sf / opt.constraint.range.quant; else pos = MulDiv( *sf, 100, 65536 );
free(sf); SendMessageW(control, SBM_SETPOS, pos, TRUE); UpdateRelevantEdit(hwnd, &opt, pos); } `