vb.net - Detect if progress bar value was assigned before P/INVOKE PBM_SETSTATE -
i'm making library progressbar includes p/invoke native methods progress state.
<toolboxbitmap(gettype(progressbar))> public class myprogressbar : inherits progressbar private const pbm_setstate integer = &h400 + 16 private _state progressstates = progressstates.normal <dllimport("user32.dll", charset:=charset.auto, setlasterror:=false)> private shared function sendmessage(byval hwnd intptr, byval msg integer, byval wparam intptr, byval lparam string) intptr end function public sub new() mybase.new() end sub <category("appearance")> <defaultvalue(progressstates.normal)> <description("it sets progress state")> public property state progressstates return _state end set(value progressstates) _state = value me.recreatehandle() end set end property public enum progressstates normal = &h1 [error] = &h2 paused = &h3 end enum protected overrides sub oncreatecontrol() mybase.oncreatecontrol() sendmessage(me.handle, pbm_setstate, _state, intptr.zero) end sub end class
i have problem:
when pbm_setstate
called before value assigned, progressbar value 0.
is there way detect if value assigned progress bar before call pbm_setstate
p/invoke?
want this: when value assigned, automatically call pbm_setstate
.
you cannot set state of progressbar before assigning value
must assign value, @ least 1 time (before setting state).
i suppose .net framework sends pbm_setpos
when value
property changed.
the short question is:
how tell if pbm_setpos
called? pbm_setstate not work until pbm_setpos called.
did try send pbm_getpos
, check if it's null?
if sendmessage(progressbar.handle, pbm_getpos, 0, 0) isnot nothing 'do stuff here end if
Comments
Post a Comment