Click here to Skip to main content
15,921,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to show a progress dialog to a no window procedure Pin
Hamid_RT15-May-07 22:00
Hamid_RT15-May-07 22:00 
GeneralRe: How to show a progress dialog to a no window procedure Pin
zhongwenjia15-May-07 23:40
zhongwenjia15-May-07 23:40 
QuestionRe: How to show a progress dialog to a no window procedure Pin
Mark Salsbery15-May-07 5:41
Mark Salsbery15-May-07 5:41 
AnswerRe: How to show a progress dialog to a no window procedure Pin
zhongwenjia15-May-07 23:36
zhongwenjia15-May-07 23:36 
AnswerRe: How to show a progress dialog to a no window procedure Pin
zhongwenjia15-May-07 23:52
zhongwenjia15-May-07 23:52 
GeneralRe: How to show a progress dialog to a no window procedure Pin
Hamid_RT16-May-07 2:08
Hamid_RT16-May-07 2:08 
GeneralRe: How to show a progress dialog to a no window procedure Pin
Mark Salsbery16-May-07 4:59
Mark Salsbery16-May-07 4:59 
GeneralRe: How to show a progress dialog to a no window procedure Pin
Mark Salsbery16-May-07 5:14
Mark Salsbery16-May-07 5:14 
Here's your code, modified to use a thread synchronization object...

#define WM_DLGCREATED WM_USER+1
#define WM_PROGRESS WM_USER+2

typedef struct
{
HWND hDlg;
HANDLE hDlgCreatedEvent;
HWND hProgress;
HINSTANCE hInst;
}MyParams, *ptMyParams;


/*-----------------------------------------------------------------------*/
BOOL CALLBACK MyDlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
void Thread1(PVOID pvoid);

/*------------------------------------------------------------------------*/
void Thread1(PVOID pvoid)
{
ptMyParams pt=(ptMyParams)pvoid;
DialogBoxParam(pt->hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, MyDlgProc, (LPARAM)pt);
_endthread();
}
/*------------------------------------------------------------------------*/
BOOL CALLBACK MyDlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
ptMyParams pt;

switch(Message)
{
case WM_INITDIALOG:
pt = (ptMyParams)lParam;
pt->hDlg = hWnd;
pt->hProgress = GetDlgItem(hWnd, IDC_PROGRESS1);
::PostMessage(hWnd, WM_DLGCREATED, 0, lParam);
return TRUE;
case WM_DLGCREATED:
pt = (ptMyParams)lParam;
::SetEvent(pt->hDlgCreatedEvent);
return TRUE;
}
return FALSE;
}


/*------------------------------------------------------------------------*/
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
INITCOMMONCONTROLSEX initcontrols;
initcontrols.dwSize = sizeof(INITCOMMONCONTROLSEX);
initcontrols.dwICC = ICC_PROGRESS_CLASS;
::InitCommonControlsEx(&initcontrols);


static MyParams myParam;
int i;

myParam.hInst=hInstance;
myParam.hDlgCreatedEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL);

_beginthread(Thread1, 0, &myParam);

::WaitForSingleObject(myParam.hDlgCreatedEvent, INFINITE);
::CloseHandle(myParam.hDlgCreatedEvent);
myParam.hDlgCreatedEvent = 0;

SendMessage(myParam.hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 30));
for(i=0;i<30;i++)
{
SendMessage(myParam.hProgress, PBM_SETPOS, i, 0);
Sleep(100);
}

Sleep(1000);
EndDialog(myParam.hDlg, 0);
return 0;
}


"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Questionerror C2106: '=' : left operand must be l-value Pin
Aint14-May-07 17:43
Aint14-May-07 17:43 
AnswerRe: error C2106: '=' : left operand must be l-value Pin
bob1697214-May-07 18:14
bob1697214-May-07 18:14 
GeneralRe: error C2106: '=' : left operand must be l-value Pin
Arman S.14-May-07 20:08
Arman S.14-May-07 20:08 
GeneralRe: error C2106: '=' : left operand must be l-value Pin
bob1697215-May-07 2:13
bob1697215-May-07 2:13 
AnswerRe: error C2106: '=' : left operand must be l-value Pin
John R. Shaw14-May-07 19:10
John R. Shaw14-May-07 19:10 
QuestionEvent Handler -Please help me Pin
prathuraj14-May-07 17:08
prathuraj14-May-07 17:08 
AnswerRe: Event Handler -Please help me Pin
Arman S.14-May-07 19:30
Arman S.14-May-07 19:30 
GeneralRe: Event Handler -Please help me Pin
prathuraj14-May-07 19:43
prathuraj14-May-07 19:43 
GeneralRe: Event Handler -Please help me Pin
Arman S.14-May-07 19:51
Arman S.14-May-07 19:51 
GeneralRe: Event Handler -Please help me Pin
prathuraj14-May-07 22:32
prathuraj14-May-07 22:32 
GeneralRe: Event Handler -Please help me Pin
Arman S.14-May-07 22:40
Arman S.14-May-07 22:40 
GeneralRe: Event Handler -Please help me Pin
Hamid_RT14-May-07 20:55
Hamid_RT14-May-07 20:55 
GeneralRe: Event Handler -Please help me Pin
prathuraj14-May-07 23:33
prathuraj14-May-07 23:33 
GeneralRe: Event Handler -Please help me Pin
Hamid_RT15-May-07 1:00
Hamid_RT15-May-07 1:00 
GeneralRe: Event Handler -Please help me Pin
prathuraj15-May-07 1:23
prathuraj15-May-07 1:23 
GeneralRe: Event Handler -Please help me Pin
Hamid_RT15-May-07 2:05
Hamid_RT15-May-07 2:05 
Questionwhat to include to use XMLReader? Pin
nathan714-May-07 16:41
nathan714-May-07 16:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.