codingweek
codingweek

Reputation: 61

Resizing the text box with window in win32 api c

i am very new to win32 API coding. Currently i am facing a problem :

  1. I've created a mdi child window and have inserted a text box into it.The problem stands when I click the maximize button of the mdi child window,the window expands but the text box dimension remains constant as mentioned in the coding.My question is how to re-size the text box along with the window.

I am using turboc++ 4.5 editor.

thanks in advance.

Upvotes: 3

Views: 3357

Answers (2)

codingweek
codingweek

Reputation: 61

Thanks, problem solved:

LRESULT  CALLBACK _export ChildProc( HWND hChild, UINT iMessage, WPARAM wParam,LPARAM      lParam )

{

HWND    Edit1;
HINSTANCE hInstance1;
PAINTSTRUCT ps;
int nWidth,nHeight;
 switch (iMessage)
 {

         case WM_CREATE :


         case WM_SIZE:  ''''''mentioned  by Jerry Coffin
                                            hInstance1 = GetWindowWord(hChild,GWW_HINSTANCE);
                                        Edit1 = CreateWindow("EDIT","",WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|ES_MULTILINE|ES_READONLY| WS_VSCROLL|WS_HSCROLL| WS_BORDER,0,0,1000,500,hChild,100,hInstance1,NULL);
                                        nWidth = LOWORD(lParam);  /* width  */
                                        nHeight = HIWORD(lParam); /* height */

                                        MoveWindow (Edit1,0,0,nWidth,nHeight,1);
                                            ShowWindow(Edit1,SW_SHOWNORMAL);
                                        break;
         default :
                return DefWindowProc( hChild, iMessage, wParam, lParam );
 }
 return 0;

}

Upvotes: 3

Jerry Coffin
Jerry Coffin

Reputation: 490128

You'll need to handle the WM_SIZE message in the MDI child window. When you receive it, you'll want to use MoveWindow on the text box to resize it to fill the MDI child window.

As an aside: Turbo C++ 4.5? Really? That's...pretty old, to put it mildly. Much more modern tools are freely available.

Upvotes: 2

Related Questions