winapi - Win32 API : how to make Edit Text to accept unsigned float only in c++? -


i'm trying learn win32 api :)

i have edit text placed in dialogbox , want accept float numbers greater 0

i able make edit text accept integers using style "es_number" in resource file can't find way how make accept positive float values please need thanks

in addition handling en_change notification have option of subclassing window. allow restrict keystrokes valid , allow numbers, dot, etc. example below shows how create edit control, subclass , filter input specific characters allowed. not handle operations such pasting clipboard want expand meet specific requirements.

the benefits of approach not need add additional code parent window filter edit control. allows use throughout application without having duplicate lot of code. benefit eliminates possible flicker occurs updating contents of control remove unwanted characters.

static wndproc originaleditctrlproc = null;  lresult callback mywindowproc(     hwnd hwnd,     uint umsg,     wparam wparam,     lparam lparam) {     if(umsg == wm_char)     {         // make sure allow specific characters         if(!    ((wparam >= '0' && wparam <= '9')                 || wparam == '.'                 || wparam == vk_return                 || wparam == vk_delete                 || wparam == vk_back))         {             return 0;         }     }      return callwindowproc(originaleditctrlproc, hwnd, umsg, wparam, lparam); }  void createcustomedit(hinstance hinstance, hwnd hparent, uint id) {     hwnd hwnd;      hwnd = createwindowex(         ws_ex_clientedge,         _t("edit"),         _t(""),         ws_visible | ws_child | ws_border | es_left,         0, 0, 200, 40,         hparent,         reinterpret_cast<hmenu>(id),         hinstance,         null);     if(hwnd != null)     {         // subclass window can filter keystrokes         wndproc oldproc = reinterpret_cast<wndproc>(setwindowlongptr(             hwnd,             gwlp_wndproc,             reinterpret_cast<long_ptr>(mywindowproc)));         if(originaleditctrlproc == null)         {             originaleditctrlproc = oldproc;         }     } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -