fzgny5
December 16th, 2004, 09:04 AM
I am new to VC++ and have a problem. I have an application that does several things and I wish to have a single dialog with a listbox that I periodically write to to give a status of the initialization to the user. Here is what I have so far but I cannot figure out how to write additional messages to the dialog. Every time I try it appears to get into an infinite loop. Any help is appreciated...
BTW... this is a Win32 Application not using MFC
------------------------------------------------------------------------------------------------------
#include<windows.h>
#include"Resource.h"
BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
HWND hDlg;
hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_UserInterface), NULL, DialogProc);
if (hDlg == NULL)
return 0;
ShowWindow(hDlg, SW_SHOWNORMAL);
// *** I do numerous function calls here that need to write to the listbox
//UpdateWindow(hDlg);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch(uMsg) {
case WM_INITDIALOG:
SetFocus(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)"hello");
return TRUE;
break;
//case WM_PAINT: // Seems to get me into an infinite loop!
// SendDlgItemMessage(hwndDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)"paint");
// return TRUE;
// break;
case WM_COMMAND:
if(wParam == IDCANCEL) {
DestroyWindow(hwndDlg);
return TRUE;
}
break;
default:
return FALSE;
}
return FALSE;
}
BTW... this is a Win32 Application not using MFC
------------------------------------------------------------------------------------------------------
#include<windows.h>
#include"Resource.h"
BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
HWND hDlg;
hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_UserInterface), NULL, DialogProc);
if (hDlg == NULL)
return 0;
ShowWindow(hDlg, SW_SHOWNORMAL);
// *** I do numerous function calls here that need to write to the listbox
//UpdateWindow(hDlg);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch(uMsg) {
case WM_INITDIALOG:
SetFocus(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)"hello");
return TRUE;
break;
//case WM_PAINT: // Seems to get me into an infinite loop!
// SendDlgItemMessage(hwndDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)"paint");
// return TRUE;
// break;
case WM_COMMAND:
if(wParam == IDCANCEL) {
DestroyWindow(hwndDlg);
return TRUE;
}
break;
default:
return FALSE;
}
return FALSE;
}