Results 1 to 4 of 4

Thread: Resize: WS_SIZE? [Resolved]

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Resize: WS_SIZE? [Resolved]

    I want to be able to resize my controls when the user resizes my form. I tried:

    Code:
      case WM_SIZE:
        if ((HWND)lParam == hwnd)
        {
          MessageBox(hwnd, "You resized", "Resize", MB_OK | MB_ICONINFORMATION);	
        }
    How do I get this to work?
    Last edited by The Hobo; Feb 14th, 2002 at 03:35 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Member
    Join Date
    Feb 2001
    Posts
    57
    I think the best way would be to catch all the WM_SIZE messages that are sent to your main window. Then have a procedure that can make the proper sizing calculations based on the current size of the main window. These calculations are then applied to each control within the main window. Perhaps you can use enumeration to cycle through all the controls...

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I know what I have to do, but I don't know how. With my source in the previous post, the MessageBox doesn't fire when being resized. Why?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Member
    Join Date
    Feb 2001
    Posts
    57
    Try this...

    PHP Code:
    #include <windows.h>

    int fwSizeType=0;
    int nWidth=0;
    int nHeight=0;

    LRESULT CALLBACK WndProcHWND hWndUINT uMsgWPARAM wParamLPARAM lParam )
    {        
    //Run through messages that window receives
       
    switch (uMsg)
        {

          case 
    WM_SIZE:

                  
    fwSizeType wParam;      // resizing flag 
                  
    nWidth LOWORD(lParam);  // width of client area 
                  
    nHeight HIWORD(lParam); // height of client area 
     
                  
    MessageBox(hWnd"You resized""Resize"MB_OK MB_ICONINFORMATION);    
                    


                  break;
          
          case 
    WM_DESTROY:
            
                    
                  
    PostQuitMessage(0);
                  
                  break;
          
          default:
                return(
    DefWindowProc(hWnduMsgwParamlParam));
       }

       return(
    0L);
    }


    int APIENTRY WinMain(HINSTANCE hInstanceHINSTANCE hPrevInstance,
                         
    LPTSTR lpCmdLineint nCmdShow)
    {    
    //Create the Window
       
    MSG      msg;
       
    HWND     hWnd
       
    WNDCLASS wc;

       
    wc.style         CS_HREDRAW CS_VREDRAW;
       
    wc.lpfnWndProc   = (WNDPROC)WndProc;       
       
    wc.cbClsExtra    0;                      
       
    wc.cbWndExtra    0;                      
       
    wc.hInstance     hInstance;              
       
    wc.hIcon         NULL
       
    wc.hCursor       LoadCursor(NULLIDC_ARROW);
       
    wc.hbrBackground = (HBRUSH)(GRAY_BRUSH-1);
       
    wc.lpszMenuName  "TEST";              
       
    wc.lpszClassName "TEST";              

       if (!
    RegisterClass(&wc))
          return(
    0L);

       

       
    hWnd CreateWindow("TEST"
                           
    "TEST",    
                           
    DS_CENTER WS_OVERLAPPEDWINDOW
                           
    1010750500
                           
    NULL,              
                           
    NULL,              
                           
    hInstance,         
                           
    NULL);

       

       
    ShowWindow(hWndnCmdShow); 
       
    UpdateWindow(hWnd);        
       
       
       while (
    GetMessage(&msgNULL00))   
         {
           
    TranslateMessage(&msg); 
           
    DispatchMessage(&msg);  
         }

       return(
    msg.wParam); 


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width