c++ - want to change the edit style to es_number at run time -


while creating edit control, not add es_number. later based on boolean flag, want change style , make es_number , revert on other value of boolean flag.

the documentation has answer. excerpts:

to create edit control using createwindow or createwindowex function, specify edit class, appropriate window style constants, , combination of following edit control styles. after control has been created, these styles cannot modified, except noted.

so, may or may not able change style after creating control. let's see:

es_number

allows digits entered edit control. note that, set, still possible paste non-digits edit control.

to change style after control has been created, use setwindowlong.

to translate text entered edit control integer value, use getdlgitemint function. set text of edit control string representation of specified integer, use setdlgitemint function.

to add style this:

long style = getwindowlong(hwnd, gwl_style); setwindowlong(hwnd, gwl_style, style | es_number); 

or remove it:

long style = getwindowlong(hwnd, gwl_style); setwindowlong(hwnd, gwl_style, style & ~es_number); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -