Hello, all:
I am writing a program that uses a modeless dialog box as its main window.
I am using Borland C 4.5. My problem is the text I place in the edit boxes
with SetWindowText during WM_CREATE does not show up. However, if I perform
the SetWindowText during a button press, they show up, but the styles ES_RIGHT
and ES_READONLY are ignored.
Any help solving this problem would be greatly appreciated. Below are the
relavant code fragments.
Here is how the dialog box is initialized in WinMain:
if ( !hPrevInstance )
{
BWCCRegister( hInstance );
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon( hInstance, "ICON_WAITING" );
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclass.hbrBackground = COLOR_WINDOW + 1;
wndclass.lpszMenuName = "MENU_1";
wndclass.lpszClassName = BORGRAYCLASS;
RegisterClass( &wndclass );
}
hwnd = CreateDialog( hInstance, szAppName, 0, NULL );
ShowWindow( hwnd, nCmdShow );
Here is how the messages are processed in WndProc:
switch ( message )
{
case WM_CREATE: //create main window and initialize
if ( !LoadConfiguration() )
{
MessageBox( hwnd, "Unable to create or read REMAILER.INI, quitting...",
"FILE CREATE/READ FAILURE", MB_ICONEXCLAMATION | MB_OK );
PostQuitMessage( 0 );
}
else
{
// this doesn't work
...
itoa( sInMail.iCheckTime, szTemp, 10 );
SetWindowText( GetDlgItem( hwnd, IDC_EDITTIMETONEXT ), szTemp );
...
}
return 0;
case WM_COMMAND:
switch( wParam )
{
case IDC_PUSHBUTTONSTART:
// this works, but ES_READONLY and ES_RIGHT ignored
...
itoa( sInMail.iCheckTime, szTemp, 10 );
SetWindowText( GetDlgItem( hwnd, IDC_EDITTIMETONEXT ), szTemp );
...
return 0;
Here is the resource file for this dialog box:
WinSockRemailer DIALOG 13, 52, 300, 134
STYLE WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
CLASS "BorDlg_Gray"
CAPTION "WinSock Remailer"
MENU MENU_1
FONT 8, "MS Sans Serif"
{
...
EDITTEXT IDC_EDITREMBATCH, 93, 40, 30, 12, ES_RIGHT | ES_READONLY | NOT WS_TABSTOP | WS_BORDER
EDITTEXT IDC_EDITREM24, 149, 40, 30, 12, ES_RIGHT | ES_READONLY | NOT WS_TABSTOP | WS_BORDER
EDITTEXT IDC_EDITREMDATE, 205, 40, 30, 12, ES_RIGHT | ES_READONLY | NOT WS_TABSTOP | WS_BORDER
...
}
Regards,
Joey Grasty