Problem using dialog box as main window

Problem using dialog box as main window

Post by Joey Gras » Mon, 15 May 1995 04:00:00



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


 
 
 

Problem using dialog box as main window

Post by John Gra » Tue, 16 May 1995 04:00:00



>Hello, all:

>I am writing a program that uses a modeless dialog box as its main window.

                                    ^^^^^^^^^
[...]

        Try making it a modal dialog box instead.

--

Airborne Geophysics
Geological Survey of Canada, Ottawa

 
 
 

1. Problem: Using a dialog-box as main window.


keyboard messages aren't going to the dialog box.  They are going to the
control in the dialog box which has the focus.
--
Robert Mashlan             R2M Software Company           Programmer for Hire

Resources for Windows Developers    -     http://www.csn.net/~rmashlan/windev
Windows Developers FAQ    -    http://www.csn.net/~rmashlan/win-developer-FAQ

2. README!!!!

3. Using accelerators when a modeless dialog box is the main window

4. CD32 for $320

5. Using Dialog Box as Main Window - How?

6. Voice and data over a leased line?

7. TAB doesn't work when using dialog box as main window

8. HTML Editor Bug

9. Using a dialog box resource as main window?

10. Dialog box as main window, using VC++

11. Problem with dialog box as main window and WM_CREATE

12. Problem with dialog box as main window

13. Dialog with minimize box as main window -> Problems!