My resource code hasnt changed...I think theres a problem with DIALOGEX, it should be DIALOG. Could that be causing any of my problems? (I would prefer to have DIALOGEX because it makes the dialog box look much nicer)
Here is one way that I'm calling the dialog box. The only problem with this one is that I dont know how to initialize myFunction(...) after the dialog box has been created and displayed.
Code:
DialogBox(hInst, "PROGRESSDLG", hWndDlg, DlgProc);
Here is the other way that I'm calling the dialog box. Two problems with this one. 1 - WM_LBUTTONDOWN message never gets called resulting in a dialog box that cant be repositioned. 2 - The LTEXT control isnt displayed, but the progress bar is.
Code:
HWND hDialog = CreateDialog(hInst, "PROGRESSDLG", hWndDlg, DlgProc);
ShowWindow(hDialog, SW_SHOWNORMAL);
if(hDialog) {
myFunction(hDialog);
DestroyWindow(hDialog);
}
Here is my procedure function:
Code:
INT_PTR CALLBACK DlgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam) {
switch(Message) {
case WM_INITDIALOG:
//CreateWindowEx(0,"Static","Please wait...",WS_CHILD | WS_VISIBLE,5,5,40,12,hWndDlg,0,hInst,NULL);
hProgress = CreateWindowEx(0,PROGRESS_CLASS,NULL,WS_CHILD | WS_VISIBLE,5,35,76,20,hWndDlg,0,hInst,NULL);
SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0,100));
SendMessage(hProgress, PBM_SETSTEP, (WPARAM)5, 0);
return true;
case WM_COMMAND:
myFunction(hWndDlg);
EndDialog(hWndDlg,0);
return true;
case WM_LBUTTONDOWN:
SendMessage(hWndDlg, WM_NCLBUTTONDOWN, HTCAPTION, lParam);
// The next line allows me to initiate myFunction(...) after I click and release the left mouse button within the progress bar dialog box
SendMessage(hWndDlg, WM_COMMAND, 0, 0);
return true;
default:
return false;
}
}
I comment out the case WM_COMMAND portion and the Send WM_COMMAND portion when I try the second way of creating the dialog box.
EDIT:
If I wanted to, I could replace the WM_COMMAND SendMessage (which is located in the WM_LBUTTONDOWN message) with myFunction(...); EndDialog(...); and it would do the same thing. Thats kinda what I meant in my previous post.
EDIT EDIT:
One thing I tried to do for automatically initializing the myFunction() function was to put it in the default case. I assumed WM_INITDIALOG is the very first message that gets sent and the second message, no matter what, would initialize myFunction() and close the dialog box. However, that never displays the dialog box. I then attempted to put myFunction() within the WM_PAINT message (since WM_PAINT is another message that is automatically sent), but then the LTEXT control is not displayed, but it works.
Also, I just realized that if I'm in the middle of executing myFunction, there isnt going to be any messages sent and since I want myFunction to execute automatically and when its done, I want it to close the dialog box, the user will have no possible way of moving the dialog box so I can remove that message.