Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

windows - No matter what, I can't get this progress bar to update from a thread -


i have windows app written in c (using gcc/mingw) works pretty except few ui problems. one, cannot progress bar update thread. in fact, can't ui stuff update.

basically, have spawned thread processing, , thread attempt update progress bar in main thread. tried using postmessage() main hwnd, no luck though can other things open message boxes. however, it's unclear whether message box getting called within thread or on main thread.

here's code:

// in header/globally accessible hwnd wnd; // main application window hwnd progress_bar; //progress bar  typedef struct { //to pass thread     dword mainthreadid;     hwnd mainhwnd;     char *filename; } threadstuff;   //callback function lresult callback wndproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam){     switch (msg){         case wm_create:{             // create progress bar             progress_bar = createwindowex(                 0,                 progress_class,                 (lpctstr) null,                 ws_child | ws_visible,                 79,164,455,15,                 hwnd,                 (hmenu)20,                 null,                 null);              sendmessage(progress_bar, pbm_setstep, 1, 0 );             sendmessage(progress_bar, pbm_setpos, 0, 0 );             //test make sure works             sendmessage(progress_bar, pbm_stepit, 0, 0 ); //works fine             sendmessage(progress_bar, pbm_stepit, 0, 0 ); //works fine             sendmessage(progress_bar, pbm_stepit, 0, 0 ); //works fine             sendmessage(progress_bar, pbm_stepit, 0, 0 ); //works fine              break;         }          case wm_command: {             if(loword(wparam)==2){ //do processing in thread                  //struct of stuff need pass thread                 threadstuff *threadstuff;                 threadstuff = (threadstuff*)malloc(sizeof(*threadstuff));                 threadstuff->mainthreadid = getcurrentthreadid();                 threadstuff->mainhwnd = hwnd;                 threadstuff->filename = (void*)&filename;                 hthread1 = createthread(null,0,convertfile (lpvoid)threadstuff,0,null);              }else if(loword(wparam)==5){ //update progress bar                  messagebox(hwnd,"i got message!", "message",  mb_ok | mb_iconinformation);                 postmessage(progress_bar,pbm_stepit,0,0);             }             break;         }     } } 

this seems work okay. problem in thread:

dword winapi convertfile(lpvoid params){      //get passed params, works fine     threadstuff *tdata = (threadstuff*)params;      messagebox(tdata->mainhwnd,tdata->filename,"file name",mb_ok | mb_iconinformation); //yep      postmessage(tdata->mainhwnd,wm_command,5,0); //only shows message     postthreadmessage(tdata->mainthreadid,wm_command,5,0); //does nothing } 

when say, "only shows message," means messagebox() function in callback works, not postmessage() update position of progress bar.

if use postthreadmessage() send message main thread's message loop, can intercept , launch messageboxes it's working. however, if try update progress bar way. still won't update.

what missing?

from msdn documentation pbm_stepit:

wparam     must zero. lparam     must zero. 

clr_default defined 0xff000000l. happens if change code to:

postmessage(progress_bar, pbm_stepit, 0, 0); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -