c++ - WinApi control doesn't show on the main window -
hello have following win32 program, , have edittext
control doesn't show on screen. there meant 2 edittext
controls drawn on main window, 1 shows, why this?
full code
#include <windows.h> #include <iostream> #include "resource.h" using namespace std; const int buffermax = 512; char server_ip[buffermax]; int port; const char windclassname[] = "windowclass"; lresult callback wndproc(hwnd hwnd,uint msg,wparam wparam,lparam lparam); int_ptr callback aboutdialog(hwnd hwnd,uint msg,wparam wparam,lparam lparam); int_ptr callback connectwin(hwnd hwnd,uint msg,wparam wparam,lparam lparam); int winapi winmain(hinstance hinstance,hinstance hprevinstance,lpstr lpcmdline,int ncmdshow){ wndclassex parent_window; hwnd hwnd; msg msg; parent_window.cbsize = sizeof(wndclassex); parent_window.style = 0; parent_window.lpfnwndproc = wndproc; parent_window.cbclsextra = 0; parent_window.cbwndextra = 0; parent_window.hinstance = hinstance; parent_window.hicon = loadicon(null,idi_application); parent_window.hcursor = loadcursor(null,idc_arrow); parent_window.hbrbackground = (hbrush)(color_window+1); parent_window.lpszmenuname = makeintresource(id_menu); parent_window.lpszclassname = windclassname; parent_window.hiconsm = loadicon(null, idi_application); //registering class use. if ( !registerclassex(&parent_window)){ messagebox(null,"could not register windowclass","error",mb_ok); return 0; } //creating window hwnd = createwindowex(ws_ex_clientedge,windclassname,"ui test",ws_overlappedwindow,cw_usedefault,cw_usedefault,250,350,null,null,hinstance,null); if ( hwnd == null ){ messagebox(null,"could not create window","error",mb_ok); return 0; } showwindow(hwnd,ncmdshow); updatewindow(hwnd); while ( getmessage(&msg,null,0,0) > 0 ) { translatemessage(&msg); dispatchmessage(&msg); } return msg.wparam; } lresult callback wndproc(hwnd hwnd,uint msg,wparam wparam,lparam lparam){ switch (msg){ case wm_create: hwnd chatbox_cntrl; hwnd message_text; chatbox_cntrl = createwindowex(ws_ex_clientedge,"edit","", ws_child | ws_visible | ws_vscroll | ws_hscroll | es_multiline | es_autovscroll | es_autohscroll, 0,0,240,260,hwnd,(hmenu)chatbox,getmodulehandle(null),null); message_text = createwindowex(ws_ex_clientedge,"edit","", ws_child,0,270,240,10,hwnd,(hmenu)messagetext,getmodulehandle(null),null); break; case wm_command: switch(loword(wparam)){ case id_mabout_info: dialogbox(getmodulehandle(null), makeintresource(id_mabout_info), hwnd,aboutdialog); break; case id_mcontrols_connect: int ret = dialogbox(getmodulehandle(null), makeintresource(id_mcontrols_connect), hwnd,connectwin); break; case id_mcontrols_exit: destroywindow(hwnd); break; } break; case wm_close: destroywindow(hwnd); break; case wm_destroy: postquitmessage(0); break; } return defwindowproc(hwnd,msg,wparam,lparam); } int_ptr callback aboutdialog(hwnd hwnd,uint msg,wparam wparam,lparam lparam){ switch (msg){ case wm_close: enddialog(hwnd,wm_close); break; default: return false; } return true; } int_ptr callback connectwin(hwnd hwnd,uint msg,wparam wparam,lparam lparam){ switch(msg){ case wm_command: switch(wparam){ case connect_button: int len = getwindowtextlength(getdlgitem(hwnd,edittext_connect)); int recv = getdlgitemtext(hwnd,edittext_connect,server_ip,len+1); port = getdlgitemint(hwnd,edittext_port,null,false); enddialog(hwnd,connect_button); break; } break; case wm_close: enddialog(hwnd,wm_close); break; default: return false; } return true; }
these 2 controls.
case wm_create: hwnd chatbox_cntrl; hwnd message_text; chatbox_cntrl = createwindowex(ws_ex_clientedge,"edit","", ws_child | ws_visible | ws_vscroll | ws_hscroll | es_multiline | es_autovscroll | es_autohscroll, 0,0,240,260,hwnd,(hmenu)chatbox,getmodulehandle(null),null); message_text = createwindowex(ws_ex_clientedge,"edit","", ws_child,0,270,240,10,hwnd,(hmenu)messagetext,getmodulehandle(null),null); break;
the message text window doesn't have same style flags first. specifically, missing ws_visible
. problem.
Comments
Post a Comment