multiple dialog processes to controls? winapi / C++ -
i've created multiple edit boxes (11x11 controls) based on article: https://msdn.microsoft.com/en-us/library/windows/desktop/hh298433%28v=vs.85%29.aspx well, not same, used code in case wm_create: block create huge number of controls.
i use dialog process on parent window:
int_ptr callback startupdialogproc(hwnd dialog, uint msg, wparam wparam, lparam lparam) { switch (msg){ case wm_initdialog: init_startup(dialog); return 1; /* case en_change: case wm_ctlcoloredit: { hdc hdc = (hdc)wparam; colorref crcolorbackground = rgb(255,0,0); if (crcolorbackground) setbkcolor(hdc, crcolorbackground); settextcolor( hdc, rgb(12,112,212) ); setbkmode( hdc, transparent ); rect rect; getclientrect( (hwnd)lparam, &rect ); hbrush hbrush = createsolidbrush( rgb(209,209,209) ); //framerect( hdc, &rect, hbrush ); rectangle( hdc, (int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom ); deleteobject( hbrush ); logbrush lb; lb.lbstyle = bs_solid; lb.lbcolor = rgb(249,249,249); lb.lbhatch = 0; createbrushindirect(&lb); // lresult // getstockobject(null_brush); return 1; } break; */ case wm_destroy: setts.options.page = getdlgitemint(dialog, idc_o_startup_page, null, false); setts.options.recent = getdlgitemint(dialog, idc_o_startup_recent, null, false); break; case wm_close: enddialog(dialog, false); break; case wm_command: if (wparam == idok) { enddialog(dialog, true); return 0; } } return 0; }
there few things unclear me: 1) if change color of border edit controls id 5001 id 5121, how that? me, commented code not work (when uncommented). looks have in incorrect place. 2) how correctly create dialog processes controls? because there big number , yet few times higher, should call loop 5001 id 5121 , call function: int_ptr callback editdlgproc(hwnd dialog, uint msg, wparam wparam, lparam lparam) - won't work, because every function need have different name.
to change border color of edit control, have subclass edit control , override wm_ncpaint
. that's little advanced, , don't need it. can use ws_ex_clientedge
flag:
createwindowex(ws_ex_clientedge, l"edit" ...
also make sure project manifest setup modern window's look.
this error if had not been commented out:
case en_change: case wm_ctlcoloredit:
each case should end in break;
or return 0;
moreover, wm_ctlcoloredit
should return brush created on heap. should not return 1. see documentation :
there other errors in section, should rid of that. see example painting.
Comments
Post a Comment